Jump to content

[SOLVED] weird sql error! can anyone see where im going wrong?!


rmmo

Recommended Posts

ok so this code is supposed to insert data into my orders table... but first i need to find my cust_id from the customer table as it is a feild in the orders table... why isnt the sql select query working??? it just goes to my error trigger?!  can anyone see where i have gone wrong?

 

  $conn = mysql_connect($host, $dbuser, $dbpass) or trigger_error("SQL", E_USER_ERROR);
  $db = mysql_select_db($dbname, $conn) or trigger_error("SQL", E_USER_ERROR);
$name = $_SESSION['name'];
$password = $_SESSION['password'];

echo $name;
echo $password;
$checkcustid= ("select customer_id from customer where customer_name = $name and customer_password = $password"); 

//	$insertorder = mysql_query("insert into custorder values('',''");
//	echo $name, "your order has been processed below is your recipt. please printscreen this page to use as proof of purchase.";
//foreach ($_POST as $value => $key)
//		{
//   echo $value, '<br/>';
		   
// insert into table here
//}
	    $results = mysql_query($checkcustid, $conn) or trigger_error("SQL", E_USER_ERROR);
                    echo $results;		 

?>

 

 
$checkcustid= ("select customer_id from customer where customer_name = $name and customer_password = $password"); 


should have had the $name as '$name' and $password as '$password'.

 

so now there is no slq error but my $results variable isnt showing what i had hoped! i was hoping for a "customer_id" from my customer table but it is infact showing "Resource id #3" and i have NO IDEA where thats coming from! could it be that this is returning an array? i have no idea how to get my actual table data... i only need the one feild so that i can assign it to another variable for an insert statement!

 

PLEASE can someone explain why this is happening?!

 

thanks a million! in advanced

RMMO

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.