Jump to content

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

  $date = date('Y-m-d H:i:s');
  echo $date;

 

That gives the format you require.

 

As for the query, current_timestamp is a MySQL function. So simply echoing CURRENT_TIMESTAMP, will just echo exactly what it says. However, I see no reason for it to not work in the query.

 

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.