yddib Posted September 9, 2008 Share Posted September 9, 2008 <?php //start the session session_start(); $id = $_SESSION['id']; mysql_connect("", "", "") or die(mysql_error()); //connects to the server mysql_select_db(""); //selects the database echo "Connection Open<br>"; $result = mysql_query("UPDATE gradinfo SET f_name='$f_name', l_name='$l_name', gender='$gender', birthd='$birthd', birthm='$birthm', birthy='$birthy', email='$email', pass='$pass', address1='$address1', county='$county', country='$country', telephone='$telephone', relationship='$relationship', location='$location', about_me='$about' WHERE u_id='$id'") or die (mysql_error()); if (!$result) { exit('<p>Error performing query: ' . mysql_error() . '</p>'); } echo "Record Updated<br>"; ?> Hi i'm have a bit of a problem updating my form. I am grabbing varaibles from another form at the top of this form but i can't get it to update the database. I was wondering if anyone could see if there is a problem? Thanks Link to comment https://forums.phpfreaks.com/topic/123422-update-form/ Share on other sites More sharing options...
Minase Posted September 9, 2008 Share Posted September 9, 2008 it give any error? did you check if the variables have the correct content? Link to comment https://forums.phpfreaks.com/topic/123422-update-form/#findComment-637418 Share on other sites More sharing options...
yddib Posted September 9, 2008 Author Share Posted September 9, 2008 This is the error: 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 'm 23 years old. I'm finishing my Masters which is very difficult but it has been' at line 1 Link to comment https://forums.phpfreaks.com/topic/123422-update-form/#findComment-637426 Share on other sites More sharing options...
Minase Posted September 9, 2008 Share Posted September 9, 2008 maybe your inputs have " ' " in them? Link to comment https://forums.phpfreaks.com/topic/123422-update-form/#findComment-637427 Share on other sites More sharing options...
revraz Posted September 9, 2008 Share Posted September 9, 2008 Yep, your $about has a single quote at I'm Use addslashes and stripslashes. Link to comment https://forums.phpfreaks.com/topic/123422-update-form/#findComment-637430 Share on other sites More sharing options...
yddib Posted September 9, 2008 Author Share Posted September 9, 2008 That worked perfect thanks. It was the " ' " in I'm! How do I stop people putting " ' " in or how do they go in successfully? ??? Link to comment https://forums.phpfreaks.com/topic/123422-update-form/#findComment-637431 Share on other sites More sharing options...
Minase Posted September 9, 2008 Share Posted September 9, 2008 or you can use str_replace("'"," ",$string) Link to comment https://forums.phpfreaks.com/topic/123422-update-form/#findComment-637436 Share on other sites More sharing options...
JasonLewis Posted September 9, 2008 Share Posted September 9, 2008 mysql_real_escape_string() should be used on any user inserted data into MySQL. Google "MySQL Injection" for more. Link to comment https://forums.phpfreaks.com/topic/123422-update-form/#findComment-637438 Share on other sites More sharing options...
revraz Posted September 9, 2008 Share Posted September 9, 2008 I just told you above this post. That worked perfect thanks. It was the " ' " in I'm! How do I stop people putting " ' " in or how do they go in successfully? ??? Link to comment https://forums.phpfreaks.com/topic/123422-update-form/#findComment-637443 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.