perezf Posted September 24, 2007 Share Posted September 24, 2007 Im sure im making a simple mistake can someone tell me why this code will not update my SQL, it shos the message that it completed but it never changes SQL Statement below: if($Submit == "Save"){ $titleedit = $_POST['titleedit']; $lengthedit = $_POST['lengthedit']; $priceedit = $_POST['priceedit']; $descedit = $_POST['descedit']; $theedit = $_POST['theedit']; $sql = "UPDATE excursions SET exc_title='$titleedit', exc_length='$lengthedit', exc_price='$priceedit', exc_desc='$descedit' WHERE exc_id='48'"; mysql_query("$sql") or die(mysql_error()); echo "Excursion Updated<br><br>"; } Quote Link to comment https://forums.phpfreaks.com/topic/70522-sql-not-updating-im-sure-its-a-simple-mistake/ Share on other sites More sharing options...
Psycho Posted September 24, 2007 Share Posted September 24, 2007 I would assume that exc_id is a numeric field, not a string. So, try changing this WHERE exc_id='48' To this: WHERE exc_id=48 Quote Link to comment https://forums.phpfreaks.com/topic/70522-sql-not-updating-im-sure-its-a-simple-mistake/#findComment-354242 Share on other sites More sharing options...
BlueSkyIS Posted September 24, 2007 Share Posted September 24, 2007 ^^ shouldn't make a difference. I always quote numbers. In fact, I always quote everything... Are we sure there is a record with that id? Are we sure we ever enter this if? if($Submit == "Save"){ Quote Link to comment https://forums.phpfreaks.com/topic/70522-sql-not-updating-im-sure-its-a-simple-mistake/#findComment-354243 Share on other sites More sharing options...
perezf Posted September 24, 2007 Author Share Posted September 24, 2007 Yes and it also does not give me an error message, it shows that it executed hmmmmmm i even tried removing the single quotes didnt work if($Submit == "Save"){ $titleedit = $_POST['titleedit']; $lengthedit = $_POST['lengthedit']; $priceedit = $_POST['priceedit']; $descedit = $_POST['descedit']; $theedit = $_POST['theedit']; $sql = "UPDATE excursions SET exc_title='$titleedit', exc_length='$lengthedit', exc_price='$priceedit', exc_desc='$descedit' WHERE exc_id=$theedit"; mysql_query("$sql") or die(mysql_error()); echo "Excursion Updated<br><br>"; } Quote Link to comment https://forums.phpfreaks.com/topic/70522-sql-not-updating-im-sure-its-a-simple-mistake/#findComment-354245 Share on other sites More sharing options...
sayedsohail Posted September 24, 2007 Share Posted September 24, 2007 apologize if i am wrong, can you just echo the post values i.e, echo "$titleedit - $lengthedit ..... the rest of post values and specially don't forget $theedit"; can you please tell me if it prints the post values. i will wait for your confirmation and lets solve this issues now? Do remember to comment the update statement for time being. /*$sql = "UPDATE excursions SET exc_title='$titleedit', exc_length='$lengthedit', exc_price='$priceedit', exc_desc='$descedit' WHERE exc_id=$theedit"; mysql_query("$sql") or die(mysql_error()); echo "Excursion Updated<br><br>";*/ Quote Link to comment https://forums.phpfreaks.com/topic/70522-sql-not-updating-im-sure-its-a-simple-mistake/#findComment-354274 Share on other sites More sharing options...
cooldude832 Posted September 24, 2007 Share Posted September 24, 2007 trying seeing if the issue is in the number, run a select where exc_id = $theedit and then see if you get a return of the number of rows greater than 0, also echoing out a query string can be helpful. Quote Link to comment https://forums.phpfreaks.com/topic/70522-sql-not-updating-im-sure-its-a-simple-mistake/#findComment-354277 Share on other sites More sharing options...
perezf Posted September 24, 2007 Author Share Posted September 24, 2007 when i echoed the post values all of the values displayed correctly? im not really understanding why its not working Quote Link to comment https://forums.phpfreaks.com/topic/70522-sql-not-updating-im-sure-its-a-simple-mistake/#findComment-354434 Share on other sites More sharing options...
Psycho Posted September 24, 2007 Share Posted September 24, 2007 As someone esle suggested, echo out the query and then change it to a SELECT statement using the where clause and run it in MySQL to see if any records are returned. Quote Link to comment https://forums.phpfreaks.com/topic/70522-sql-not-updating-im-sure-its-a-simple-mistake/#findComment-354437 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.