dansk Posted January 12, 2007 Share Posted January 12, 2007 i got this query in php$result=mysql_query("SELECT * FROM Announ.jan WHERE Key =' " .date('d'). " ' ")or die(mysql_error());and i get this errorYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Key =' 12 '' at line 1 Link to comment https://forums.phpfreaks.com/topic/33872-query-error-in-php/ Share on other sites More sharing options...
ted_chou12 Posted January 12, 2007 Share Posted January 12, 2007 by this: date('d') do you mean date['d']? Link to comment https://forums.phpfreaks.com/topic/33872-query-error-in-php/#findComment-158959 Share on other sites More sharing options...
redbullmarky Posted January 12, 2007 Share Posted January 12, 2007 ted, in this case, it seems the original use of date (ie, the function) is correct.i believe "Key" is a reserved word. You should try and avoid using SQL reserved words, but if you want to carry on in this case, enclose the 'Key' with backticks (` - normally the key directly to the left of the number 1).Also, remove the spaces between the single and double quote:[code]<?php$result=mysql_query("SELECT * FROM Announ.jan WHERE `Key` = '" .date('d'). "'") or die(mysql_error());?>[/code]that should helpcheers Link to comment https://forums.phpfreaks.com/topic/33872-query-error-in-php/#findComment-158963 Share on other sites More sharing options...
dansk Posted January 12, 2007 Author Share Posted January 12, 2007 no, I am actually using the date funtion in phpdate("d") would return 12 becuase today's date is jan 12thanks Link to comment https://forums.phpfreaks.com/topic/33872-query-error-in-php/#findComment-158964 Share on other sites More sharing options...
dansk Posted January 12, 2007 Author Share Posted January 12, 2007 wow, thanks redbullmarkyi never thought of thatthanks everyone Link to comment https://forums.phpfreaks.com/topic/33872-query-error-in-php/#findComment-158965 Share on other sites More sharing options...
ted_chou12 Posted January 12, 2007 Share Posted January 12, 2007 i c. Link to comment https://forums.phpfreaks.com/topic/33872-query-error-in-php/#findComment-158966 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.