Absorbator Posted April 23, 2008 Share Posted April 23, 2008 Hello to everybody I have very stupid problem. First at all I'd like to apology about my bad english. There is the problem: I can read MySql databases with php script, but I cannot write in them. I'm asking you is there a possibility the server has wrong settings (because I checked them and there was this "Read-Only-OFF") or my code is wrong (I have compare it with another codes: nothing illegal...). Quote Link to comment Share on other sites More sharing options...
JSHINER Posted April 23, 2008 Share Posted April 23, 2008 Hello and Welcome! Can we see your code? And, what errors do you get when you try to write to your database? Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted April 23, 2008 Share Posted April 23, 2008 It's possible you could have the wrong privileges - though you would get an error message to this effect if that was the case (assuming you are debugging). So yes, we'll need to see your code. Quote Link to comment Share on other sites More sharing options...
Absorbator Posted April 23, 2008 Author Share Posted April 23, 2008 This is the code, modified by me to be easier to read it <?php $reg_form="<table border=0 bgcolor=0099ff cellpadding=0 cellspacing=2 width=300 height=140> <tr><td bgcolor=fff0f0 align=center><form action='example.php' method=post>Username:<input type=text size=16 maxlength=32 name=profile align=right> <br>Password:<input type=password size=16 maxlength=32 name=pass> <br>Confirm Password:<input type=password size=16 maxlength=32 name=configpass> <br>E-mail:<input type=text size=16 maxlength=32 name=email> <br><input type=submit value='registrate' name=submit></form></td></tr> </table>"; $message = "<font color=blue>Enter your name, password and e-mail</font>"; if($_POST['submit']) { if(!$_POST['user'] | !$_POST['pass'] | !$_POST['configpass'] | !$_POST['email']) { $message = "<font color=red>You did not complete all of the fields!</font>"; } else { $chars_number_pass = strlen($_POST['pass']); $chars_number_user = strlen($_POST['user']); if($_POST['pass'] != $_POST['configpass']) { $message = "<font color=red>You must enter you password twice(once in password field and once in Confirm Password field)</font>"; } else { if($chars_number_pass < 6 || $chars_number_user < 3) { $message = "<font color=red>Your password or username (or both) is too short!</font>"; } else { if (!$_POST['email']) { echo "<font color=red>You did not type an e-mail address!</font>"; } else { $mailcheck = "@"; if(!ereg($mailcheck, $_POST['email'])) { $message = "<font color=red>An invalid e-mail address</font>"; } else { if(!get_magic_quotes_gpc()) { $user=addslashes($_POST['user']); $pass=addslashes($_POST['pass']); $mail=addslashes($_POST['email']); } else { $user=$_POST['user']; $pass=$_POST['pass']; $mail=$_POST['email']; } $check_user = mysql_query("SELECT username FROM accounts WHERE username IN($user)"); if($check_user == $_POST['user']) { $message = "<font color=red>The username $_POST['user'] is allready in use!</font>"; } else { $reg=mysql_query("INSERT INTO accounts ('username', 'pass') VALUES ('$user', '$pass')"); if (!$reg) { $message="<font color=red>Failed to record into databases!</font>"; } else { $message = "<font color=#487644>Your registration is now valid</font>"; $reg_form=""; setcookie (user, $user, time()+3600, "/", "", 1 ); setcookie (pass, $pass, time()+3600, "/", "", 1 ); }} } } }}}} echo "<p align=center>"; echo $message; echo $reg_form; echo "</p>"; } ?> I think that the problem is in the code, because i have used PHPBB forum code which worked without problems Quote Link to comment Share on other sites More sharing options...
Absorbator Posted April 23, 2008 Author Share Posted April 23, 2008 By the way, when I was modifying the code I made a mistake, you should remove one of the brackets on line 77, not the last one. Sorry about that.. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted April 24, 2008 Share Posted April 24, 2008 Whenever you're having problems with a query, you should add an or die statement and echo the query. That is, this: $check_user = mysql_query("SELECT username FROM accounts WHERE username IN($user)"); Becomes: $sql = "SELECT username FROM accounts WHERE username IN($user)"; $check_user = mysql_query($sql) or die(mysql_error()); echo '<br />Query was:'.$sql; Now, when you do that, i suspect you'll find that $user is undefined, since your form has this: Username:<input type=text size=16 maxlength=32 name=profile align=right> Im guessing that should be: Username:<input type=text size=16 maxlength=32 name=user align=right> Quote Link to comment 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.