[PHP] Newbie Question - Parse XML with PHP...

2013-04-19 Thread dealTek
Hi all,

newbie - just starting with trying to parse XML...


$mylist = simplexml_load_file('thelist.xml');

then use a foreach to echo the data...

title;
$artist=$songinfo->artist;
$date=$songinfo['dateplayed'];
echo $title.' --- ';
echo $artist.' --- ';
echo $date.' --- ';
echo '  ';
}

?>

that I get ...

Question: how do you use $mylist when the xml is not as a file but is returned 
on a web page?


an example of the real xml I am trying to work with is like this demo below 

Goal : when this response comes back - I would like to be able to get the data 
as php and then update the database


example


  1
  SUCCESS
  1865264174
  100
  123456
  N
  N
  sale
  12.00
  ::1
  ecommerce
  ccprocessora
  USD
  Small Order
  Red
  Medium
  1234
  2.00
  0.00
  
John
Smith
1234 Main St.
Beverly Hills
CA
90210
US
555-555-
t...@example.com
Acme, Inc.
40**0002
0118
  
  
Mary
Smith
1234 Main St.
Beverly Hills
CA
90210
US
Unit #2
  
  
SKU-123456
test product description
abc
1
5.
1.
7.00
2.00
1.00
2.00
1.00
sales
12345
  
  
SKU-123456
test 2 product description
abc
2
2.5000
2.
7.00
2.00
1.00
2.00
1.00
sales
12345
  









--
Thanks,
Dave - DealTek
deal...@gmail.com
[db-3]



Re: [PHP] Newbie Question - Parse XML with PHP...

2013-04-19 Thread Sebastian Krebs
A "webpage" is a file, that (usually) a browser downloads and parses.
You'll do exactly the same :-) I don't know exactly, but you can try to
pass the URL directly to simplexml_load_file(). If this doesn't work,
download the content (for example with file_get_contents()) and pass it to
simplexml_load_string(). There are obviously many other approaches, but you
should now have an idea :-)

Or you use a specialized library like Guzzle.
Am 19.04.2013 22:17 schrieb "dealTek" :

> Hi all,
>
> newbie - just starting with trying to parse XML...
>
>
> $mylist = simplexml_load_file('thelist.xml');
>
> then use a foreach to echo the data...
>
>  $mysongs = simplexml_load_file('songs.xml');
>
> foreach ($mysongs as $songinfo) {
> $title=$songinfo->title;
> $artist=$songinfo->artist;
> $date=$songinfo['dateplayed'];
> echo $title.' --- ';
> echo $artist.' --- ';
> echo $date.' --- ';
> echo '  ';
> }
>
> ?>
>
> that I get ...
>
> Question: how do you use $mylist when the xml is not as a file but is
> returned on a web page?
>
>
> an example of the real xml I am trying to work with is like this demo
> below 
>
> Goal : when this response comes back - I would like to be able to get the
> data as php and then update the database
>
>
> example
> 
> 
>   1
>   SUCCESS
>   1865264174
>   100
>   123456
>   N
>   N
>   sale
>   12.00
>   ::1
>   ecommerce
>   ccprocessora
>   USD
>   Small Order
>   Red
>   Medium
>   1234
>   2.00
>   0.00
>   
> John
> Smith
> 1234 Main St.
> Beverly Hills
> CA
> 90210
> US
> 555-555-
> t...@example.com
> Acme, Inc.
> 40**0002
> 0118
>   
>   
> Mary
> Smith
> 1234 Main St.
> Beverly Hills
> CA
> 90210
> US
> Unit #2
>   
>   
> SKU-123456
> test product description
> abc
> 1
> 5.
> 1.
> 7.00
> 2.00
> 1.00
> 2.00
> 1.00
> sales
> 12345
>   
>   
> SKU-123456
> test 2 product description
> abc
> 2
> 2.5000
> 2.
> 7.00
> 2.00
> 1.00
> 2.00
> 1.00
> sales
> 12345
>   
> 
>
>
>
>
>
>
>
>
> --
> Thanks,
> Dave - DealTek
> deal...@gmail.com
> [db-3]
>
>


[PHP] mysql_connect noob question

2013-04-19 Thread Glob Design Info

I know this has probably been answered already.

When I pass a user name and password from a form to my PHP script and 
then pass those to mysql_connect it doesn't connect. When I paste those 
exact same values into mysql_connect as string literals it works.


Can anyone tell me why this happens?

I know the strings are identical to the literals I try in a test but 
they don't work when submitted via form.


$form_user = $_POST[ 'user' ];
$form_pass = $_POST[ 'password' ];

# Connect to remote DB

$LINK = mysql_connect( $host, $form_user, $form_pass );

And yes, my $host param is correct.

Thanks,

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] mysql_connect noob question

2013-04-19 Thread Matijn Woudt
On Fri, Apr 19, 2013 at 10:43 PM, Glob Design Info wrote:

> I know this has probably been answered already.
>
> When I pass a user name and password from a form to my PHP script and then
> pass those to mysql_connect it doesn't connect. When I paste those exact
> same values into mysql_connect as string literals it works.
>
> Can anyone tell me why this happens?
>
> I know the strings are identical to the literals I try in a test but they
> don't work when submitted via form.
>
> $form_user = $_POST[ 'user' ];
> $form_pass = $_POST[ 'password' ];
>
> # Connect to remote DB
>
> $LINK = mysql_connect( $host, $form_user, $form_pass );
>
> And yes, my $host param is correct.
>
> Thanks,
>
>
Try printing the $form_user and form_pass values, it might be that it's
just an error elsewhere, maybe field name is different in the html?
Otherwise, it might be you have some php init setting, like magic quotes
that does something with the input data.

- Matijn


Re: [PHP] mysql_connect noob question

2013-04-19 Thread Glob Design Info
Already did that. I printed the form values in the PHP script after they 
are received and they print exactly as entered in the form. Even checked 
for extra spaces.


Any functions I can pass the values to to remove the magic quotes?

Thanks,

On 4/19/13 1:47 PM, Matijn Woudt wrote:

On Fri, Apr 19, 2013 at 10:43 PM, Glob Design Info wrote:


I know this has probably been answered already.

When I pass a user name and password from a form to my PHP script and then
pass those to mysql_connect it doesn't connect. When I paste those exact
same values into mysql_connect as string literals it works.

Can anyone tell me why this happens?

I know the strings are identical to the literals I try in a test but they
don't work when submitted via form.

$form_user = $_POST[ 'user' ];
$form_pass = $_POST[ 'password' ];

# Connect to remote DB

$LINK = mysql_connect( $host, $form_user, $form_pass );

And yes, my $host param is correct.

Thanks,



Try printing the $form_user and form_pass values, it might be that it's
just an error elsewhere, maybe field name is different in the html?
Otherwise, it might be you have some php init setting, like magic quotes
that does something with the input data.

- Matijn



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Newbie Question - Parse XML with PHP...

2013-04-19 Thread dealTek

On Apr 19, 2013, at 1:33 PM, Sebastian Krebs  wrote:

> A "webpage" is a file, that (usually) a browser downloads and parses. You'll 
> do exactly the same :-) I don't know exactly, but you can try to pass the URL 
> directly to simplexml_load_file(). If this doesn't work, download the content 
> (for example with file_get_contents()) and pass it to 
> simplexml_load_string(). There are obviously many other approaches, but you 
> should now have an idea :-)
> 

Thanks Sebastian for the help

Actually what is happening in my case is:

page1.php is sending out to credit card company - getting processed - then 
coming back to the *same page1.php* with the XML data listed below...

- so I'm not going to some other page to get it - it is coming to me to the 
same page I am on..

so - after the XML result comes in - I need to assign the php to the XML 
somehow...

I hope I am making myself clear

Thanks in advance for the help


> Or you use a specialized library like Guzzle.
> 
> Am 19.04.2013 22:17 schrieb "dealTek" :
> Hi all,
> 
> newbie - just starting with trying to parse XML...
> 
> 
> $mylist = simplexml_load_file('thelist.xml');
> 
> then use a foreach to echo the data...
> 
>  $mysongs = simplexml_load_file('songs.xml');
> 
> foreach ($mysongs as $songinfo) {
> $title=$songinfo->title;
> $artist=$songinfo->artist;
> $date=$songinfo['dateplayed'];
> echo $title.' --- ';
> echo $artist.' --- ';
> echo $date.' --- ';
> echo '  ';
> }
> 
> ?>
> 
> that I get ...
> 
> Question: how do you use $mylist when the xml is not as a file but is 
> returned on a web page?
> 
> 
> an example of the real xml I am trying to work with is like this demo below 
> 
> 
> Goal : when this response comes back - I would like to be able to get the 
> data as php and then update the database
> 
> 
> example
> 
> 
>   1
>   SUCCESS
>   1865264174
>   100
>   123456
>   N
>   N
>   sale
>   12.00
>   ::1
>   ecommerce
>   ccprocessora
>   USD
>   Small Order
>   Red
>   Medium
>   1234
>   2.00
>   0.00
>   
> John
> Smith
> 1234 Main St.
> Beverly Hills
> CA
> 90210
> US
> 555-555-
> t...@example.com
> Acme, Inc.
> 40**0002
> 0118
>   
>   
> Mary
> Smith
> 1234 Main St.
> Beverly Hills
> CA
> 90210
> US
> Unit #2
>   
>   
> SKU-123456
> test product description
> abc
> 1
> 5.
> 1.
> 7.00
> 2.00
> 1.00
> 2.00
> 1.00
> sales
> 12345
>   
>   
> SKU-123456
> test 2 product description
> abc
> 2
> 2.5000
> 2.
> 7.00
> 2.00
> 1.00
> 2.00
> 1.00
> sales
> 12345
>   
> 
> 
> 
> 
> 
> 
> 
> 
> 
> --
> Thanks,
> Dave - DealTek
> deal...@gmail.com
> [db-3]
> 


--
Thanks,
Dave - DealTek
deal...@gmail.com
[db-3]



Re: [PHP] mysql_connect noob question

2013-04-19 Thread Matijn Woudt
On Fri, Apr 19, 2013 at 10:59 PM, Glob Design Info wrote:

> Already did that. I printed the form values in the PHP script after they
> are received and they print exactly as entered in the form. Even checked
> for extra spaces.
>
> Any functions I can pass the values to to remove the magic quotes?
>
> Thanks,


You would see the quotes if they were there in the output. There's no
reason why it should not work this way, though I doubt it's safe to do. Can
you show us the rest of the code, including the HTML form?
And exactly what error are you getting? (eg. from mysql_error())


>
>
> On 4/19/13 1:47 PM, Matijn Woudt wrote:
>
>> On Fri, Apr 19, 2013 at 10:43 PM, Glob Design Info > >wrote:
>>
>>  I know this has probably been answered already.
>>>
>>> When I pass a user name and password from a form to my PHP script and
>>> then
>>> pass those to mysql_connect it doesn't connect. When I paste those exact
>>> same values into mysql_connect as string literals it works.
>>>
>>> Can anyone tell me why this happens?
>>>
>>> I know the strings are identical to the literals I try in a test but they
>>> don't work when submitted via form.
>>>
>>> $form_user = $_POST[ 'user' ];
>>> $form_pass = $_POST[ 'password' ];
>>>
>>> # Connect to remote DB
>>>
>>> $LINK = mysql_connect( $host, $form_user, $form_pass );
>>>
>>> And yes, my $host param is correct.
>>>
>>> Thanks,
>>>
>>>
>>>  Try printing the $form_user and form_pass values, it might be that it's
>> just an error elsewhere, maybe field name is different in the html?
>> Otherwise, it might be you have some php init setting, like magic quotes
>> that does something with the input data.
>>
>> - Matijn
>>
>>
>


Re: [PHP] mysql_connect noob question

2013-04-19 Thread tamouse mailing lists
On Fri, Apr 19, 2013 at 3:43 PM, Glob Design Info  wrote:
> I know this has probably been answered already.
>
> When I pass a user name and password from a form to my PHP script and then
> pass those to mysql_connect it doesn't connect. When I paste those exact
> same values into mysql_connect as string literals it works.
>
> Can anyone tell me why this happens?
>
> I know the strings are identical to the literals I try in a test but they
> don't work when submitted via form.
>
> $form_user = $_POST[ 'user' ];
> $form_pass = $_POST[ 'password' ];
>
> # Connect to remote DB
>
> $LINK = mysql_connect( $host, $form_user, $form_pass );


Please show the error you are getting from the mysql_connect


>
> And yes, my $host param is correct.
>
> Thanks,
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Newbie Question - Parse XML with PHP...

2013-04-19 Thread tamouse mailing lists
On Fri, Apr 19, 2013 at 4:04 PM, dealTek  wrote:
>
> On Apr 19, 2013, at 1:33 PM, Sebastian Krebs  wrote:
>
>> A "webpage" is a file, that (usually) a browser downloads and parses. You'll 
>> do exactly the same :-) I don't know exactly, but you can try to pass the 
>> URL directly to simplexml_load_file(). If this doesn't work, download the 
>> content (for example with file_get_contents()) and pass it to 
>> simplexml_load_string(). There are obviously many other approaches, but you 
>> should now have an idea :-)
>>
>
> Thanks Sebastian for the help
>
> Actually what is happening in my case is:
>
> page1.php is sending out to credit card company - getting processed - then 
> coming back to the *same page1.php* with the XML data listed below...

Please expand what you mean by "sending out" and "coming back" - is
this a REST or SOAP API call? In that case, the response body is
likely to be the XML.

>
> - so I'm not going to some other page to get it - it is coming to me to the 
> same page I am on..
>
> so - after the XML result comes in - I need to assign the php to the XML 
> somehow...

How do you recognize the "XML result com(ing) in" ?



>
> I hope I am making myself clear
>
> Thanks in advance for the help
>
>
>> Or you use a specialized library like Guzzle.
>>
>> Am 19.04.2013 22:17 schrieb "dealTek" :
>> Hi all,
>>
>> newbie - just starting with trying to parse XML...
>>
>>
>> $mylist = simplexml_load_file('thelist.xml');
>>
>> then use a foreach to echo the data...
>>
>> > $mysongs = simplexml_load_file('songs.xml');
>>
>> foreach ($mysongs as $songinfo) {
>> $title=$songinfo->title;
>> $artist=$songinfo->artist;
>> $date=$songinfo['dateplayed'];
>> echo $title.' --- ';
>> echo $artist.' --- ';
>> echo $date.' --- ';
>> echo '  ';
>> }
>>
>> ?>
>>
>> that I get ...
>>
>> Question: how do you use $mylist when the xml is not as a file but is 
>> returned on a web page?
>>
>>
>> an example of the real xml I am trying to work with is like this demo below 
>> 
>>
>> Goal : when this response comes back - I would like to be able to get the 
>> data as php and then update the database
>>
>>
>> example
>> 
>> 
>>   1
>>   SUCCESS
>>   1865264174
>>   100
>>   123456
>>   N
>>   N
>>   sale
>>   12.00
>>   ::1
>>   ecommerce
>>   ccprocessora
>>   USD
>>   Small Order
>>   Red
>>   Medium
>>   1234
>>   2.00
>>   0.00
>>   
>> John
>> Smith
>> 1234 Main St.
>> Beverly Hills
>> CA
>> 90210
>> US
>> 555-555-
>> t...@example.com
>> Acme, Inc.
>> 40**0002
>> 0118
>>   
>>   
>> Mary
>> Smith
>> 1234 Main St.
>> Beverly Hills
>> CA
>> 90210
>> US
>> Unit #2
>>   
>>   
>> SKU-123456
>> test product description
>> abc
>> 1
>> 5.
>> 1.
>> 7.00
>> 2.00
>> 1.00
>> 2.00
>> 1.00
>> sales
>> 12345
>>   
>>   
>> SKU-123456
>> test 2 product description
>> abc
>> 2
>> 2.5000
>> 2.
>> 7.00
>> 2.00
>> 1.00
>> 2.00
>> 1.00
>> sales
>> 12345
>>   
>> 
>>
>>
>>
>>
>>
>>
>>
>>
>> --
>> Thanks,
>> Dave - DealTek
>> deal...@gmail.com
>> [db-3]
>>
>
>
> --
> Thanks,
> Dave - DealTek
> deal...@gmail.com
> [db-3]
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Newbie Question - Parse XML with PHP...

2013-04-19 Thread dealTek

On Apr 19, 2013, at 3:32 PM, tamouse mailing lists  
wrote:

>> 
>> page1.php is sending out to credit card company - getting processed - then 
>> coming back to the *same page1.php* with the XML data listed below...
> 
> Please expand what you mean by "sending out" and "coming back" - is
> this a REST or SOAP API call? In that case, the response body is
> likely to be the XML.
> 
>> 
>> - so I'm not going to some other page to get it - it is coming to me to the 
>> same page I am on..
>> 
>> so - after the XML result comes in - I need to assign the php to the XML 
>> somehow...
> 
> How do you recognize the "XML result com(ing) in" ?
> 

Hi tamouse,

with my untrained eye - it appears that this  is what is 'sending out'


 $data = sendXMLviaCurl($xmlRequest,$gatewayURL);


and this might be what is 'responding back' on the same page


$gwResponse = @new SimpleXMLElement((string)$data);


you can see these lines towards the bottom at - // Process Step Three...


---



the page code is long - so i cut out some extra lines - but this is
===


all page code - with edits...

https://secure.webxxx.com/api/test';

$APIKey = 'xxx';





// If there is no POST data or a token-id, print the initial shopping cart form 
to get ready for Step One.

if (empty($_POST['DO_STEP_1'])&& empty($_GET['token-id'])) {



print '  http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>';

print '



  



Collect non-sensitive Customer Info 

  

  

  Step One: Collect non-sensitive payment information.



   Customer Information

   Billing Details





  

  Company

 
 
 --- more



   Shipping Details

  
  
  --more
  

   

  Total Amount $12.00 

  

  





  





';

}else if (!empty($_POST['DO_STEP_1'])) {



// Initiate Step One: Now that we've collected the non-sensitive payment 
information, we can combine other order information and build the XML format.

$xmlRequest = new DOMDocument('1.0','UTF-8');



$xmlRequest->formatOutput = true;

$xmlSale = $xmlRequest->createElement('sale');



// Amount, authentication, and Redirect-URL are typically the bare mininum.

appendXmlNode($xmlSale,'api-key',$APIKey);

appendXmlNode($xmlSale,'redirect-url',$_SERVER['HTTP_REFERER']);

appendXmlNode($xmlSale, 'amount', '12.00');

appendXmlNode($xmlSale, 'ip-address', $_SERVER["REMOTE_ADDR"]);

//appendXmlNode($xmlSale, 'processor-id' , 'processora');

appendXmlNode($xmlSale, 'currency', 'USD');

//appendXmlNode($xmlSale, 'dup-seconds' , '2');



// Some additonal fields may have been previously decided by user

appendXmlNode($xmlSale, 'order-id', '1234');

appendXmlNode($xmlSale, 'order-description', 'Small Order');

appendXmlNode($xmlSale, 'merchant-defined-field-1' , 'Red');

appendXmlNode($xmlSale, 'merchant-defined-field-2', 'Medium');

appendXmlNode($xmlSale, 'tax-amount' , '2.00');

appendXmlNode($xmlSale, 'shipping-amount' , '0.00');



/*if(!empty($_POST['customer-vault-id'])) {

appendXmlNode($xmlSale, 'customer-vault-id' , 
$_POST['customer-vault-id']);

}else {

 $xmlAdd = $xmlRequest->createElement('add-customer');

 appendXmlNode($xmlAdd, 'customer-vault-id' ,411);

 $xmlSale->appendChild($xmlAdd);

}*/





// Set the Billing & Shipping from what was collected on initial shopping 
cart form

$xmlBillingAddress = $xmlRequest->createElement('billing');

appendXmlNode($xmlBillingAddress,'first-name', 
$_POST['billing-address-first-name']);

//-more


//billing-address-email

appendXmlNode($xmlBillingAddress,'country', 
$_POST['billing-address-country']);

appendXmlNode($xmlBillingAddress,'email', $_POST['billing-address-email']);

//more

$xmlSale->appendChild($xmlBillingAddress);





$xmlShippingAddress = $xmlRequest->createElement('shipping');

appendXmlNode($xmlShippingAddress,'first-name', 
$_POST['shipping-address-first-name']);

appendXmlNode($xmlShippingAddress,'last-name', 
$_POST['shipping-address-last-name']);

// more

appendXmlNode($xmlShippingAddress,'fax', $_POST['shipping-address-fax']);

$xmlSale->appendChild($xmlShippingAddress);





// Products already chosen by user

$xmlProduct = $xmlRequest->createElement('product');

appendXmlNode($xmlProduct,'product-code' , 'SKU-123456');

   
   
   
   // more

appendXmlNode($xmlProduct,'alternate-tax-id' , '12345');



$xmlSale->appendChild($xmlProduct);



$xmlProduct = $xmlRequest->createElement('product');

appendXmlNode($xmlProduct,'product-code' , 'SKU-123456');

appendXmlNode($xmlProduct,'description' , 'test 2 product description');



  

Re: [PHP] mysql_connect noob question

2013-04-19 Thread Glob Design Info

Nope, quotes are not visible in the output.

Both the HTML and the script it calls are shown below. They are in 2 
separate files. The variable names in both are "user" and "password". 
The data comes through to the PHP script fine - if I print them I see 
exactly what I typed in the form, but when I pass them to my DB host on 
another server via mysql_connect it give me an error.



HTML:


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

http://www.w3.org/1999/xhtml";>





Admin



.desw { font-family: Arial, Helvetica, sans-serif; }






   
  height="134" border="0" />


 
  Please log in.
   

   method="post">

User: 
Password: />


  

   
   

 
 






PHP:






User: " . $form_user . "";
echo "Pass: " . $form_pass . "";

# Connect to remote DB

$WSDB_LINK = mysql_connect( $host, $form_user, $form_pass );
if( !$WSDB_LINK )
{
error_log( "NeverStranded: cannot connect to the database." );
}
else
{
   ..
}

?>

On 4/19/13 2:13 PM, Matijn Woudt wrote:

On Fri, Apr 19, 2013 at 10:59 PM, Glob Design Info wrote:


Already did that. I printed the form values in the PHP script after they
are received and they print exactly as entered in the form. Even checked
for extra spaces.

Any functions I can pass the values to to remove the magic quotes?

Thanks,


You would see the quotes if they were there in the output. There's no
reason why it should not work this way, though I doubt it's safe to do. Can
you show us the rest of the code, including the HTML form?
And exactly what error are you getting? (eg. from mysql_error())




On 4/19/13 1:47 PM, Matijn Woudt wrote:


On Fri, Apr 19, 2013 at 10:43 PM, Glob Design Info 
wrote:

  I know this has probably been answered already.

When I pass a user name and password from a form to my PHP script and
then
pass those to mysql_connect it doesn't connect. When I paste those exact
same values into mysql_connect as string literals it works.

Can anyone tell me why this happens?

I know the strings are identical to the literals I try in a test but they
don't work when submitted via form.

$form_user = $_POST[ 'user' ];
$form_pass = $_POST[ 'password' ];

# Connect to remote DB

$LINK = mysql_connect( $host, $form_user, $form_pass );

And yes, my $host param is correct.

Thanks,


  Try printing the $form_user and form_pass values, it might be that it's

just an error elsewhere, maybe field name is different in the html?
Otherwise, it might be you have some php init setting, like magic quotes
that does something with the input data.

- Matijn





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] mysql_connect noob question

2013-04-19 Thread Glob Design Info

Sorry. The error displayed is:

*Warning*: mysql_connect() [function.mysql-connect 
]: Access denied for 
user ''@'ip70-162-142-180.ph.ph.cox.net' (using password: YES) in 
*/Library/WebServer/Documents/wservices/connect.php* on line *29*


(But with the real user name, not just '')

Thanks,

On 4/19/13 3:28 PM, tamouse mailing lists wrote:

On Fri, Apr 19, 2013 at 3:43 PM, Glob Design Info  wrote:

I know this has probably been answered already.

When I pass a user name and password from a form to my PHP script and then
pass those to mysql_connect it doesn't connect. When I paste those exact
same values into mysql_connect as string literals it works.

Can anyone tell me why this happens?

I know the strings are identical to the literals I try in a test but they
don't work when submitted via form.

$form_user = $_POST[ 'user' ];
$form_pass = $_POST[ 'password' ];

# Connect to remote DB

$LINK = mysql_connect( $host, $form_user, $form_pass );


Please show the error you are getting from the mysql_connect



And yes, my $host param is correct.

Thanks,

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php







Re: [PHP] mysql_connect noob question

2013-04-19 Thread David Robley
Glob Design Info wrote:

> Sorry. The error displayed is:
> 
> *Warning*: mysql_connect() [function.mysql-connect
> ]: Access denied for
> user ''@'ip70-162-142-180.ph.ph.cox.net' (using password: YES) in
> */Library/WebServer/Documents/wservices/connect.php* on line *29*
> 
> (But with the real user name, not just '')
> 
> Thanks,
> 
> On 4/19/13 3:28 PM, tamouse mailing lists wrote:
>> On Fri, Apr 19, 2013 at 3:43 PM, Glob Design Info 
>> wrote:
>>> I know this has probably been answered already.
>>>
>>> When I pass a user name and password from a form to my PHP script and
>>> then pass those to mysql_connect it doesn't connect. When I paste those
>>> exact same values into mysql_connect as string literals it works.
>>>
>>> Can anyone tell me why this happens?
>>>
>>> I know the strings are identical to the literals I try in a test but
>>> they don't work when submitted via form.
>>>
>>> $form_user = $_POST[ 'user' ];
>>> $form_pass = $_POST[ 'password' ];
>>>
>>> # Connect to remote DB
>>>
>>> $LINK = mysql_connect( $host, $form_user, $form_pass );
>>
>> Please show the error you are getting from the mysql_connect
>>
>>
>>> And yes, my $host param is correct.
>>>
>>> Thanks,
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>

First guess is that you don't have privileges for 
''@'ip70-162-142-180.ph.ph.cox.net', but you may have privileges for 
''.

And, what are you using for the $host value? If the script and mysql are on 
the same server, it shouldn't need to be anything other than 'localhost'.
-- 
Cheers
David Robley

A man's best friend is his dogma.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] mysql_connect noob question

2013-04-19 Thread Glob Design Info
They aren't on the same server. The DB is on xeround.com, the web server 
is localhost.


The host value is set and working. If I hard-code the user and password 
values in the mysql_connect() call and leave the host value as is, it 
connects fine. Only passing the user and password from the form cause it 
to fail.



On 4/19/13 5:47 PM, David Robley wrote:

Glob Design Info wrote:


Sorry. The error displayed is:

*Warning*: mysql_connect() [function.mysql-connect
]: Access denied for
user ''@'ip70-162-142-180.ph.ph.cox.net' (using password: YES) in
*/Library/WebServer/Documents/wservices/connect.php* on line *29*

(But with the real user name, not just '')

Thanks,

On 4/19/13 3:28 PM, tamouse mailing lists wrote:

On Fri, Apr 19, 2013 at 3:43 PM, Glob Design Info 
wrote:

I know this has probably been answered already.

When I pass a user name and password from a form to my PHP script and
then pass those to mysql_connect it doesn't connect. When I paste those
exact same values into mysql_connect as string literals it works.

Can anyone tell me why this happens?

I know the strings are identical to the literals I try in a test but
they don't work when submitted via form.

$form_user = $_POST[ 'user' ];
$form_pass = $_POST[ 'password' ];

# Connect to remote DB

$LINK = mysql_connect( $host, $form_user, $form_pass );


Please show the error you are getting from the mysql_connect



And yes, my $host param is correct.

Thanks,

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





First guess is that you don't have privileges for
''@'ip70-162-142-180.ph.ph.cox.net', but you may have privileges for
''.

And, what are you using for the $host value? If the script and mysql are on
the same server, it shouldn't need to be anything other than 'localhost'.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] mysql_connect noob question

2013-04-19 Thread Jim Giner

On 4/19/2013 9:33 PM, Glob Design Info wrote:

They aren't on the same server. The DB is on xeround.com, the web server
is localhost.

The host value is set and working. If I hard-code the user and password
values in the mysql_connect() call and leave the host value as is, it
connects fine. Only passing the user and password from the form cause it
to fail.


On 4/19/13 5:47 PM, David Robley wrote:

Glob Design Info wrote:


Sorry. The error displayed is:

*Warning*: mysql_connect() [function.mysql-connect
]: Access denied for
user ''@'ip70-162-142-180.ph.ph.cox.net' (using password: YES) in
*/Library/WebServer/Documents/wservices/connect.php* on line *29*

(But with the real user name, not just '')

Thanks,

On 4/19/13 3:28 PM, tamouse mailing lists wrote:

On Fri, Apr 19, 2013 at 3:43 PM, Glob Design Info 
wrote:

I know this has probably been answered already.

When I pass a user name and password from a form to my PHP script and
then pass those to mysql_connect it doesn't connect. When I paste
those
exact same values into mysql_connect as string literals it works.

Can anyone tell me why this happens?

I know the strings are identical to the literals I try in a test but
they don't work when submitted via form.

$form_user = $_POST[ 'user' ];
$form_pass = $_POST[ 'password' ];

# Connect to remote DB

$LINK = mysql_connect( $host, $form_user, $form_pass );


Please show the error you are getting from the mysql_connect



And yes, my $host param is correct.

Thanks,

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





First guess is that you don't have privileges for
''@'ip70-162-142-180.ph.ph.cox.net', but you may have privileges
for
''.

And, what are you using for the $host value? If the script and mysql
are on
the same server, it shouldn't need to be anything other than 'localhost'.

Do your user or password contain spaces, thereby requiring quotes in 
your call?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] mysql_connect noob question

2013-04-19 Thread Glob Design Info
No, no spaces.

I am wondering if I need to use htmlspecialchars()

On Apr 19, 2013, at 7:17 PM, Jim Giner  wrote:

> On 4/19/2013 9:33 PM, Glob Design Info wrote:
>> They aren't on the same server. The DB is on xeround.com, the web server
>> is localhost.
>> 
>> The host value is set and working. If I hard-code the user and password
>> values in the mysql_connect() call and leave the host value as is, it
>> connects fine. Only passing the user and password from the form cause it
>> to fail.
>> 
>> 
>> On 4/19/13 5:47 PM, David Robley wrote:
>>> Glob Design Info wrote:
>>> 
 Sorry. The error displayed is:
 
 *Warning*: mysql_connect() [function.mysql-connect
 ]: Access denied for
 user ''@'ip70-162-142-180.ph.ph.cox.net' (using password: YES) in
 */Library/WebServer/Documents/wservices/connect.php* on line *29*
 
 (But with the real user name, not just '')
 
 Thanks,
 
 On 4/19/13 3:28 PM, tamouse mailing lists wrote:
> On Fri, Apr 19, 2013 at 3:43 PM, Glob Design Info 
> wrote:
>> I know this has probably been answered already.
>> 
>> When I pass a user name and password from a form to my PHP script and
>> then pass those to mysql_connect it doesn't connect. When I paste
>> those
>> exact same values into mysql_connect as string literals it works.
>> 
>> Can anyone tell me why this happens?
>> 
>> I know the strings are identical to the literals I try in a test but
>> they don't work when submitted via form.
>> 
>> $form_user = $_POST[ 'user' ];
>> $form_pass = $_POST[ 'password' ];
>> 
>> # Connect to remote DB
>> 
>> $LINK = mysql_connect( $host, $form_user, $form_pass );
> 
> Please show the error you are getting from the mysql_connect
> 
> 
>> And yes, my $host param is correct.
>> 
>> Thanks,
>> 
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
> 
>>> 
>>> First guess is that you don't have privileges for
>>> ''@'ip70-162-142-180.ph.ph.cox.net', but you may have privileges
>>> for
>>> ''.
>>> 
>>> And, what are you using for the $host value? If the script and mysql
>>> are on
>>> the same server, it shouldn't need to be anything other than 'localhost'.
>>> 
> Do your user or password contain spaces, thereby requiring quotes in your 
> call?
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] mysql_connect noob question

2013-04-19 Thread Jim Giner

On 4/20/2013 12:23 AM, Glob Design Info wrote:

No, no spaces.

I am wondering if I need to use htmlspecialchars()

On Apr 19, 2013, at 7:17 PM, Jim Giner  wrote:


On 4/19/2013 9:33 PM, Glob Design Info wrote:

They aren't on the same server. The DB is on xeround.com, the web server
is localhost.

The host value is set and working. If I hard-code the user and password
values in the mysql_connect() call and leave the host value as is, it
connects fine. Only passing the user and password from the form cause it
to fail.


On 4/19/13 5:47 PM, David Robley wrote:

Glob Design Info wrote:


Sorry. The error displayed is:

*Warning*: mysql_connect() [function.mysql-connect
]: Access denied for
user ''@'ip70-162-142-180.ph.ph.cox.net' (using password: YES) in
*/Library/WebServer/Documents/wservices/connect.php* on line *29*

(But with the real user name, not just '')

Thanks,

On 4/19/13 3:28 PM, tamouse mailing lists wrote:

On Fri, Apr 19, 2013 at 3:43 PM, Glob Design Info 
wrote:

I know this has probably been answered already.

When I pass a user name and password from a form to my PHP script and
then pass those to mysql_connect it doesn't connect. When I paste
those
exact same values into mysql_connect as string literals it works.

Can anyone tell me why this happens?

I know the strings are identical to the literals I try in a test but
they don't work when submitted via form.

$form_user = $_POST[ 'user' ];
$form_pass = $_POST[ 'password' ];

# Connect to remote DB

$LINK = mysql_connect( $host, $form_user, $form_pass );


Please show the error you are getting from the mysql_connect



And yes, my $host param is correct.

Thanks,

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





First guess is that you don't have privileges for
''@'ip70-162-142-180.ph.ph.cox.net', but you may have privileges
for
''.

And, what are you using for the $host value? If the script and mysql
are on
the same server, it shouldn't need to be anything other than 'localhost'.


Do your user or password contain spaces, thereby requiring quotes in your call?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Why does the error message refer to "mysql-connect" and not "mysql_connect"?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] mysql_connect noob question

2013-04-19 Thread Glob Design Info
Dunno. The code definitely has the underscore.

On Apr 19, 2013, at 9:11 PM, Jim Giner  wrote:

> On 4/20/2013 12:23 AM, Glob Design Info wrote:
>> No, no spaces.
>> 
>> I am wondering if I need to use htmlspecialchars()
>> 
>> On Apr 19, 2013, at 7:17 PM, Jim Giner  wrote:
>> 
>>> On 4/19/2013 9:33 PM, Glob Design Info wrote:
 They aren't on the same server. The DB is on xeround.com, the web server
 is localhost.
 
 The host value is set and working. If I hard-code the user and password
 values in the mysql_connect() call and leave the host value as is, it
 connects fine. Only passing the user and password from the form cause it
 to fail.
 
 
 On 4/19/13 5:47 PM, David Robley wrote:
> Glob Design Info wrote:
> 
>> Sorry. The error displayed is:
>> 
>> *Warning*: mysql_connect() [function.mysql-connect
>> ]: Access denied for
>> user ''@'ip70-162-142-180.ph.ph.cox.net' (using password: YES) in
>> */Library/WebServer/Documents/wservices/connect.php* on line *29*
>> 
>> (But with the real user name, not just '')
>> 
>> Thanks,
>> 
>> On 4/19/13 3:28 PM, tamouse mailing lists wrote:
>>> On Fri, Apr 19, 2013 at 3:43 PM, Glob Design Info 
>>> wrote:
 I know this has probably been answered already.
 
 When I pass a user name and password from a form to my PHP script and
 then pass those to mysql_connect it doesn't connect. When I paste
 those
 exact same values into mysql_connect as string literals it works.
 
 Can anyone tell me why this happens?
 
 I know the strings are identical to the literals I try in a test but
 they don't work when submitted via form.
 
 $form_user = $_POST[ 'user' ];
 $form_pass = $_POST[ 'password' ];
 
 # Connect to remote DB
 
 $LINK = mysql_connect( $host, $form_user, $form_pass );
>>> 
>>> Please show the error you are getting from the mysql_connect
>>> 
>>> 
 And yes, my $host param is correct.
 
 Thanks,
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
>>> 
> 
> First guess is that you don't have privileges for
> ''@'ip70-162-142-180.ph.ph.cox.net', but you may have privileges
> for
> ''.
> 
> And, what are you using for the $host value? If the script and mysql
> are on
> the same server, it shouldn't need to be anything other than 'localhost'.
> 
>>> Do your user or password contain spaces, thereby requiring quotes in your 
>>> call?
>>> 
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>> 
> Why does the error message refer to "mysql-connect" and not "mysql_connect"?
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php