nikhar021 Posted April 23, 2008 Share Posted April 23, 2008 if(!empty($_POST['first1'])) { $update1 = "UPDATE student1 SET first = '{$_POST[first1]}' WHERE id='{$_POST[id2]}' AND branch='{$_POST[branch2]}' "; $result1 = mysql_query($update1) or die(mysql_error()); echo "First name updated" ; $count++; } Quote Link to comment https://forums.phpfreaks.com/topic/102546-is-something-wrong-with-this-code/ Share on other sites More sharing options...
DarkWater Posted April 23, 2008 Share Posted April 23, 2008 There may be something wrong with your caps lock key too. if(!empty($_POST['first1'])) { $update1 = "UPDATE student1 SET first = '{$_POST['first1']}' WHERE id='{$_POST['id2']}' AND branch='{$_POST['branch2]'}' "; $result1 = mysql_query($update1) or die(mysql_error()); echo "First name updated" ; $count++; } Quote Link to comment https://forums.phpfreaks.com/topic/102546-is-something-wrong-with-this-code/#findComment-525025 Share on other sites More sharing options...
947740 Posted April 23, 2008 Share Posted April 23, 2008 I believe you already made this post elsewhere... http://www.phpfreaks.com/forums/index.php/topic,193973.0.html Quote Link to comment https://forums.phpfreaks.com/topic/102546-is-something-wrong-with-this-code/#findComment-525029 Share on other sites More sharing options...
nikhar021 Posted April 23, 2008 Author Share Posted April 23, 2008 ya but this is the error im gettng in my browser 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 'CS'' at line 1 pls help Quote Link to comment https://forums.phpfreaks.com/topic/102546-is-something-wrong-with-this-code/#findComment-525044 Share on other sites More sharing options...
DarkWater Posted April 23, 2008 Share Posted April 23, 2008 ya but this is the error im gettng in my browser 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 'CS'' at line 1 pls help Which values are being posted to the MySQL query from $_POST? Show the output of print_r($_POST); after you send info to the page. Quote Link to comment https://forums.phpfreaks.com/topic/102546-is-something-wrong-with-this-code/#findComment-525047 Share on other sites More sharing options...
947740 Posted April 23, 2008 Share Posted April 23, 2008 One thing I noticed in the error was 'CS". A single-quote, then a double-quote. There may be a problem with quotes somewhere in your values. Quote Link to comment https://forums.phpfreaks.com/topic/102546-is-something-wrong-with-this-code/#findComment-525054 Share on other sites More sharing options...
DarkWater Posted April 23, 2008 Share Posted April 23, 2008 One thing I noticed in the error was 'CS". A single-quote, then a double-quote. There may be a problem with quotes somewhere in your values. Yeah, that's why I want to see his values. Quote Link to comment https://forums.phpfreaks.com/topic/102546-is-something-wrong-with-this-code/#findComment-525055 Share on other sites More sharing options...
nikhar021 Posted April 23, 2008 Author Share Posted April 23, 2008 ok this is wat i get Array ( [id2] => [branch2] => CS [first1] => [last1] => [branch3] => CS [semester1] => 1 [fname1] => [mname1] => [add11] => [add21] => [city1] => Anuppur [state1] => [pin1] => [no1] => [email1] => [tenth1] => [twelth1] => [r11] => [r21] => [r31] => [r41] => [r51] => [r61] => [r71] => [r81] => [submit] => update ) 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 'CS'' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/102546-is-something-wrong-with-this-code/#findComment-525063 Share on other sites More sharing options...
DarkWater Posted April 23, 2008 Share Posted April 23, 2008 $update1 = "UPDATE student1 SET first = '{$_POST['first1']}' WHERE id='{$_POST['id2']}' AND branch='{$_POST['branch2']}' "; Had a quote in the wrong place. Woops. =) That should work. Quote Link to comment https://forums.phpfreaks.com/topic/102546-is-something-wrong-with-this-code/#findComment-525067 Share on other sites More sharing options...
947740 Posted April 23, 2008 Share Posted April 23, 2008 Sorry about that DarkWater, I did not know that is why you asked... Quote Link to comment https://forums.phpfreaks.com/topic/102546-is-something-wrong-with-this-code/#findComment-525069 Share on other sites More sharing options...
DarkWater Posted April 23, 2008 Share Posted April 23, 2008 Oh, no problem. =P And it was because one quote was in the wrong place. The new query I posted should work. Quote Link to comment https://forums.phpfreaks.com/topic/102546-is-something-wrong-with-this-code/#findComment-525071 Share on other sites More sharing options...
nikhar021 Posted April 23, 2008 Author Share Posted April 23, 2008 no i didnt find any wrong quote my statement is the same as posted by you..... Quote Link to comment https://forums.phpfreaks.com/topic/102546-is-something-wrong-with-this-code/#findComment-525075 Share on other sites More sharing options...
nikhar021 Posted April 23, 2008 Author Share Posted April 23, 2008 smbdy pls help me out its getting ??? mind boggling Quote Link to comment https://forums.phpfreaks.com/topic/102546-is-something-wrong-with-this-code/#findComment-525096 Share on other sites More sharing options...
DarkWater Posted April 23, 2008 Share Posted April 23, 2008 no i didnt find any wrong quote my statement is the same as posted by you..... Copy and paste mine in. It'll work. I fixed a quote, and maybe you just aren't seeing it. o-o Quote Link to comment https://forums.phpfreaks.com/topic/102546-is-something-wrong-with-this-code/#findComment-525100 Share on other sites More sharing options...
nikhar021 Posted April 23, 2008 Author Share Posted April 23, 2008 i did that but its giving the same error........should i paste the whole 250 line code Quote Link to comment https://forums.phpfreaks.com/topic/102546-is-something-wrong-with-this-code/#findComment-525108 Share on other sites More sharing options...
wildteen88 Posted April 23, 2008 Share Posted April 23, 2008 Because your are using raw _POST data in your query you are most probably typed a quote in your form which is causing the error. You should not place raw _POST data directly into a query as is very unsecure. I'd change your code to: <?php if(!empty($_POST['first1'])) { $first1 = mysql_real_escape_string($_POST['first1']); $id2 = mysql_real_escape_string($_POST['id2']); $branch2 = mysql_real_escape_string($_POST['branch2']); $update1 = "UPDATE student1 SET first = '$first1' WHERE id='$id2' AND branch='$branch2'"; $result1 = mysql_query($update1) or die(mysql_error()); echo "First name updated" ; $count++; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/102546-is-something-wrong-with-this-code/#findComment-525289 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.