erik345 Posted January 9, 2011 Share Posted January 9, 2011 <?php $con = mysql_connect("127.0.0.1","root","") or die(mysql_error()); mysql_select_db("schemalaggare", $con); $date = (isset($_POST["date"])) ? $_POST["date"] : "Inget datum"; $amne = (isset($_POST["amne"])) ? $_POST["amne"] : "Inget ämne valt"; $beskrivning = (isset($_POST["beskriv"])) ? $_POST["beskriv"] : "Ingen beskrivning"; $betyg = (isset($_POST["betyg"])) ? $_POST["betyg"] : "Inget betyg"; $sort = (isset($_POST["sort"])) ? $_POST["sort"] : "Inget arbete"; /* Något fel */ if ( (mysql_query("SELECT datum FROM struktur WHERE datum=\"" $_POST["date"] '"')) == NULL) { mysql_query("INSERT INTO struktur(datum, sort, amne, beskrivning, betyg) VALUES ('$date', '$sort', '$amne', '$beskrivning', '$betyg')");} else { mysql_query("UPDATE struktur(datum, sort, amne, beskrivning, betyg) VALUES ('$date, '$sort', '$amne', '$beskrivning', '$betyg')"); } echo 'Inlägg sparat!' ?> Can someone please tell my why i get this error? Parse error: syntax error, unexpected T_VARIABLE in C:\Program Files (x86)\EasyPHP-5.3.3.1\www\Schema projekt\send.php on line 14 the if statement is on line 14. if ( (mysql_query("SELECT datum FROM struktur WHERE datum=\"" $_POST["date"] '"')) == NULL) what's wrong with it? I really can't see it. Thanks for helping out a beginner. EDIT: Sorry if im posting in the wrong forum. Quote Link to comment https://forums.phpfreaks.com/topic/223875-need-help-with-if-statement/ Share on other sites More sharing options...
smerny Posted January 9, 2011 Share Posted January 9, 2011 try this if ( (mysql_query("SELECT datum FROM struktur WHERE datum='". $_POST["date"] ."'")) == NULL) Quote Link to comment https://forums.phpfreaks.com/topic/223875-need-help-with-if-statement/#findComment-1157050 Share on other sites More sharing options...
suresh_kamrushi Posted January 11, 2011 Share Posted January 11, 2011 mysql_query() returns a resource on success, or FALSE on error. Hence you can try update your code like this: if ( (mysql_query("SELECT datum FROM struktur WHERE datum='". $_POST["date"] ."'")) === FALSE) Quote Link to comment https://forums.phpfreaks.com/topic/223875-need-help-with-if-statement/#findComment-1157798 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.