adamjones Posted October 21, 2008 Share Posted October 21, 2008 Ok. So this is a form I did for user to update their details; <?php $host="localhost"; $username="wowdream_domaine"; $password="pass"; $db_name="wowdream_domaine"; $tbl_name="members"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name WHERE username='$myusername'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); ?> <form name="form1" method="post" action="updateaccount_ac.php"> <fieldset> <label>Your Name:</label> <input class="small" name="name" type="text" id="name" value="<? echo $rows['name']; ?>"><br class="hid" /> <br class="hid" /> <label>Your Password:</label> <input class="small" name="pass" type="password" id="pass" value="<? echo $rows['password']; ?>"><br class="hid" /> <br class="hid" /> <label>Your E-Mail:</label> <input class="small" name="email" type="text" id="email" value="<? echo $rows['email']; ?>"><br class="hid" /> <br class="hid" /> <label>Contact Number:</label> <input class="small" name="number" type="text" id="number" value="<? echo $rows['number']; ?>"><br class="hid" /> <br class="hid" /> <br /><br /><br /><br /><a href="#" class="button submit" title="Submit"><span>Submit</span></a> <span class="clear"></span> </fieldset> </form> <? mysql_close(); ?> And this is 'updateaccount_ac.php'; <? session_start(); if(!session_is_registered(myusername)){ header("location:index.php"); } ?> <?php $host="localhost"; $username="wowdream_domaine"; $password="pass"; $db_name="wowdream_domaine"; $tbl_name="members"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="UPDATE $tbl_name SET name='$name', password='$pass', email='$email', number='$number' WHERE username='$myusername'"; $result=mysql_query($sql); if($result){ echo "GOOD"; } else { echo "ERROR"; } ?> Thing is, It just echo's ''GOOD", and doesn't actually update the database. I have a similar one, that just updates the users password. That one work- I just can't see why this one wont! Link to comment https://forums.phpfreaks.com/topic/129463-my-code-isnt-updating-my-database/ Share on other sites More sharing options...
genericnumber1 Posted October 21, 2008 Share Posted October 21, 2008 mysql_query(...) or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/129463-my-code-isnt-updating-my-database/#findComment-671161 Share on other sites More sharing options...
adamjones Posted October 21, 2008 Author Share Posted October 21, 2008 It's not giving me an error. Just coming up as blank. Link to comment https://forums.phpfreaks.com/topic/129463-my-code-isnt-updating-my-database/#findComment-671173 Share on other sites More sharing options...
genericnumber1 Posted October 21, 2008 Share Posted October 21, 2008 After you added the or die(mysql_error()) you aren't getting "GOOD" anymore? Also, why are you using register_globals? Try enabling E_ALL and E_NOTICE for errors if you are just seeing a blank white page, that typically can mean an error is being suppressed. Link to comment https://forums.phpfreaks.com/topic/129463-my-code-isnt-updating-my-database/#findComment-671177 Share on other sites More sharing options...
adamjones Posted October 21, 2008 Author Share Posted October 21, 2008 After adding the error bit, it's not echoing "GOOD" anymore, just brings up the page blank. Link to comment https://forums.phpfreaks.com/topic/129463-my-code-isnt-updating-my-database/#findComment-671180 Share on other sites More sharing options...
adamjones Posted October 21, 2008 Author Share Posted October 21, 2008 Sorry- how do I enable E_ALL? Link to comment https://forums.phpfreaks.com/topic/129463-my-code-isnt-updating-my-database/#findComment-671181 Share on other sites More sharing options...
genericnumber1 Posted October 21, 2008 Share Posted October 21, 2008 Stick this at the top of your script that's coming up blank: error_reporting(E_ALL | E_STRICT); Oh, and I meant E_STRICT before, not E_NOTICE, sorry about that. Link to comment https://forums.phpfreaks.com/topic/129463-my-code-isnt-updating-my-database/#findComment-671183 Share on other sites More sharing options...
adamjones Posted October 21, 2008 Author Share Posted October 21, 2008 Ok Thanks. This is the error; Notice: Use of undefined constant myusername - assumed 'myusername' in /home/wowdream/public_html/domaine/admin/beta/updateaccount_ac.php on line 4 Notice: Undefined variable: pass in /home/wowdream/public_html/domaine/admin/beta/updateaccount_ac.php on line 18 ...but the variables are registered, aren't they? :s Link to comment https://forums.phpfreaks.com/topic/129463-my-code-isnt-updating-my-database/#findComment-671192 Share on other sites More sharing options...
genericnumber1 Posted October 21, 2008 Share Posted October 21, 2008 Just as it says, pass isn't being set for some reason. The myusername error's just because you didn't put quotes around it when you used it, it wouldn't stop the script from working (though you should put die() after the header redirect because the script keeps running after you redirect unless you tell it to stop.) Link to comment https://forums.phpfreaks.com/topic/129463-my-code-isnt-updating-my-database/#findComment-671197 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.