Jump to content

Recommended Posts

does anyone know why this insert statement isnt inserting anything into the data base?

$date = date("m-d-y");
$datequery = "INSERT INTO users timelogged VALUES $date WHERE username = '$uname'";
$rundate = mysql_query($datequery);

 

echo $datequery; returns

INSERT INTO users timelogged VALUES 08-30-07 WHERE username = 'abarter'

 

so that sounds right to me..i dunno i might be crazy

 

does the timelogged field in the DB have to be something specific? I have it set as VARCHAR right now

Link to comment
https://forums.phpfreaks.com/topic/67333-solved-query-not-inserting-to-db/
Share on other sites

Don't think it's the varchar problem unless it's not long enough to hold the value submitted.

 

But what's wrong is the VALUES $date part. You have to tell the database to input date into what table field.

 

Something like this:

<?php

$date = date("m-d-y");
$datequery = "INSERT INTO users timelogged VALUES date='$date' WHERE username = '$uname'";
$rundate = mysql_query($datequery) or die(mysql_error());

?>

Also try to put in die methods

the insert statment goes like this though...

 

INSERT INTO table_name (column1, column2) VALUES ('value1','value2') so the date= part on your statement would be wrong.

 

I did add the or die part and got this error:

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'timelogged VALUES 08-30-07 WHERE username = 'abarter'' at line 1

 

timelogged is my column name and then im just saying put it in the row where username = the person that is logged in

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.