Hey, Idk why this isn't working. I've done it before successfully. $mysql_host = "localhost"; $mysql_user = "*********"; $mysql_pass = "******"; $mysql_base = "************"; mysql_connect($mysql_host, $mysql_user, $mysql_pass) or die( "Unable to connect to SQL server"); mysql_select_db( "$mysql_base") or die( "Unable to select database"); mysql_query("INSERT INTO purchases (id,item_name,item_number,payment_status,payment_amount,payment_currency,txn_id,receiver_email,payer_email,date,registrations) VALUES('','$item_name','$item_number','$payment_status','$payment_amount','$payment_currency','$txn_id','$receiver_email','$payer_email','$date222','0') ") or die(mysql_error());
$link_id = mysql_connect($mysql_host, $mysql_user, $mysql_pass) or die( "Unable to connect to SQL server"); mysql_select_db($mysql_base, $link_id) or die( "Unable to select database"); mysql_query("abcde", $link_id); Code (markup):
Tell your error message and Whether SQL error message is necessary? (die( "Unable to select database") as it sometimes confuses newbies
$mysql_host = "localhost"; $mysql_user = "*********"; $mysql_pass = "******"; $mysql_base = "************"; mysql_connect($mysql_host, $mysql_user, $mysql_pass) or die( "Unable to connect to SQL server"); mysql_select_db( "$mysql_base") or die( "Unable to select database"); mysql_query("INSERT INTO purchases (id,item_name,item_number,payment_status,payment_amount,payment_currency,txn_id,receiver_email,payer_email,date,registrations) VALUES('','$item_name','$item_number','$payment_status','$payment_amount','$payment_currency','$txn_id','$receiver_email','$payer_email','$date222','0') ") or die(mysql_error()); Code (markup): There is nothing wrong with this code. My guess is that you have a typo in the dbname/user/pass.
sometimes hostname is not localhost like for godaddy hosting its not localhost so please check hostname which is 99% "localhost" Secondly Where are these variables coming from? $item_name','$item_number','$payment_status','$payment_amount','$payment_currency' Are you using register global off Regards Alex
Register globals does not have any influence on this problem. Even if it was turned off and the variables are coming straight from get or post I think it would not produce an error message but insert an empty row.
Nothing wrong with the variable, no error message, and the host is localhost. I know the rest of the script is working because I have told the script to email and add to database, but right now its only emailing me.
if id is auto increment the use NULL inside of '' VALUES(NULL,'$item_name','$item_number','$payment_status','$payment_amount','$payment_currency','$txn_id','$receiver_email','$payer_email','$date222','0')
I even deleted date,registrations,payment_status,payment_currency and all from script and database, but still doesn't work.