The error : syntax error, unexpected T_STRING
But I checked all string objects and they worked separately..

mysql_query("INSERT INTO downloadlogs(id, name, ip, time) VALUES('" . $Gid. "', '" . $nFile . "', '" . $IP . "', '" . date("l jS \of F Y h:i:s A") . "')")or die(mysql_error());

I checked this with TextPad and I saw that the syntax was right.. so I don't know what is the problem...
Thank you in advanced.

Recommended Answers

Look at the lines before this one.

Jump to Post

Hi,
Syntax is correct still Check before the sql statement line if ok you can try as:
store the sql statement in a variable ,execute the query then retrieve the value ,

Jump to Post

All 7 Replies

Look at the lines before this one.

This is what is before the code above.

$finalFile = '/home/a6771073/public_html/dTemp/' . $nFile;
	copy('/home/a6771073/public_html/upload/' . $oFile, $finalFile);

I don't know how.. but it worked 2 minutes ago..

Hi,
Syntax is correct still Check before the sql statement line if ok you can try as:
store the sql statement in a variable ,execute the query then retrieve the value ,

Most of the times, such an error also reports on which line in your script the error is occurring. Does it not?

The error : syntax error, unexpected T_STRING
But I checked all string objects and they worked separately..

mysql_query("INSERT INTO downloadlogs(id, name, ip, time) VALUES('" . $Gid. "', '" . $nFile . "', '" . $IP . "', '" . date("l jS \of F Y h:i:s A") . "')")or die(mysql_error());

date("l jS \of F Y h:i:s A") = Maybe the quotation marks are causing the issue?
either change them into single quote ' or put the format in an string and put the string there instead.

I used to have this issue and removing the Date("") from the query most often solved it.
A tip mate; Learn to use Unix Timestamps and save those in the DB instead of a Date-string.

date("l jS \of F Y h:i:s A") = Maybe the quotation marks are causing the issue?
either change them into single quote ' or put the format in an string and put the string there instead.

I used to have this issue and removing the Date("") from the query most often solved it.
A tip mate; Learn to use Unix Timestamps and save those in the DB instead of a Date-string.

i don't think so... i don't think the date function has to do with the error, the date() statement is concatenated correctly outside the string, so if you use and editor like notepad++ you will see the the concatenated strings is not broken

i think the error came from other part of code

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.