Jump to content

INSERT INTO statement


i8grand

Recommended Posts

I have the following piece of code that I am using to try and insert a new row of data into a table in my SQL database.  Both $customerID and $puzzle are obtained from SESSION variables, and $startGrid is got through the query below.  The statement should work but can't work out why it is not!

 

		$dbQuery = 	"SELECT startGrid FROM puzzle WHERE id=$puzzle";
	$result = mysql_query($dbQuery,$db);
	$dbRow = mysql_fetch_array($result);

		$startGrid = $dbRow[0];	

	$dbQueryNew = 	"INSERT INTO puzzlestatus VALUES (NULL, $customerID, $puzzle, $startGrid, Current_Timestamp, NULL)";
	$resultNew 	=	mysql_query($dbQueryNew, $db);	

 

Any help at all would be greatly appreciated, thanks

 

Dylan.

Link to comment
https://forums.phpfreaks.com/topic/202836-insert-into-statement/
Share on other sites

The database is set up fine because I can alter already created records.  And how exactly do you mean echo the query, I just echoed each attribute that I want to put into the record:

 

echo "$customerID"."$puzzle"."$startGrid"."$date";

 

is there a way to echo the whole query:

 

$dbQueryNew = 	"INSERT INTO puzzlestatus VALUES (NULL, $customerID, $puzzle, $startGrid, $date, NULL)";
$resultNew 	=	mysql_query($dbQueryNew, $db);

 

 

thanks for all your help, its great.

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.