devang23 Posted December 7, 2009 Share Posted December 7, 2009 i have 2 scripts and one of them is to send info into mysql and the other one is to display it. the problem with this script is that the page just refreshes, and i believe it doesnt store the information that im trying to store. <html><head><title>Adding a User </title></head> <body> <?php if( (!$firstname) or (!$lastname) or (!$username) or (!$password) ) { $form ="Please enter all new user details"; $form.="<form action=\"$PHP_SELF\""; $form.=" method=\"post\">First Name: "; $form.="<input type=\"text\" name=\firstname\""; $form.=" value=\"$firstname\"><br>Last Name: "; $form.="<input type=\"text\" name=\"lastname\""; $form.=" value=\"$lastname\"><br>UserName: "; $form.="<input type=\"text\" name=\"username\""; $form.=" value=\"$username\"><br>PassWord: "; $form.="<input type=\"text\" name=\"password\""; $form.=" value=\"$password\"><br>"; $form.="<input type=\"submit\" value=\"Submit\">"; $form.="</form>"; echo($form); } else { $conn = mysql_connect("mysql4.000webhost.com","a3213677_dolphin","******")or die("Try Again Punk"); $db = mysql_select_db("a3213677_snorre",$conn)or die("NOOPE"); $sql = "insert into User Table (first_name,last_name,username,password) values (\"$firstname\",\"$lastname\",\"$username\",password(\"$password\") )"; $result = mysql_query($sql,$conn); if($result) { echo("New User $username ADDED DUH"); } } ?> </body></html> and the 2nd one i get this error message "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 ''User Table' Where 1' at line 1" <html><head><title>I'm a GENUIS</title></head> <body> <?php $conn=mysql_connect("mysql4.000webhost.com","a3213677_dolphin","********") or die(mysql_error()); $rs = mysql_select_db("a3213677_snorre", $conn) or die("NOOOPE"); $sql="select * from 'User Table' Where 1"; $rs=mysql_query($sql,$conn) or die(mysql_error());; $list = "<table border=\"1\" cellpadding=\"2\">"; $list.="<tr><th><First Name</th>"; $list.="<th>Last Name</th>"; $list.="<th>UserName</th>"; $list.="<th>PassWord</th></tr>"; while($row= mysql_fetch_array($rs) ) { $list .= "<tr>"; $list .= "<td>".$row["first_name"]."</td>"; $list .= "<td>".$row["last_name"]."</td>"; $list .= "<td>".$row["username"]."</td>"; $list .= "<td>".$row["password"]."</td>"; $list .= "</tr>"; } $list .= "<\table"; echo($list); ?> </body><html> Quote Link to comment https://forums.phpfreaks.com/topic/184246-php-mysql-errors/ Share on other sites More sharing options...
Russia Posted December 7, 2009 Share Posted December 7, 2009 Try this for the second code, it might work. Also, whats the problem with the first code? <html><head><title>I'm a GENUIS</title></head> <body> <?php $conn=mysql_connect("mysql4.000webhost.com","a3213677_dolphin","********") or die(mysql_error()); $rs = mysql_select_db("a3213677_snorre", $conn) or die("NOOOPE"); $sql="select * from `User Table` Where 1"; $rs=mysql_query($sql,$conn) or die(mysql_error());; $list = "<table border=\"1\" cellpadding=\"2\">"; $list.="<tr><th><First Name</th>"; $list.="<th>Last Name</th>"; $list.="<th>UserName</th>"; $list.="<th>PassWord</th></tr>"; while($row= mysql_fetch_array($rs) ) { $list .= "<tr>"; $list .= "<td>".$row["first_name"]."</td>"; $list .= "<td>".$row["last_name"]."</td>"; $list .= "<td>".$row["username"]."</td>"; $list .= "<td>".$row["password"]."</td>"; $list .= "</tr>"; } $list .= "<\table"; echo($list); ?> </body><html> Quote Link to comment https://forums.phpfreaks.com/topic/184246-php-mysql-errors/#findComment-973042 Share on other sites More sharing options...
devang23 Posted December 8, 2009 Author Share Posted December 8, 2009 the page just refreshes itself...it doesnt reply that the data was submitted, and thanks for the last code and it work, its just that the info didnt show up, and im guessing its cause of the first code? Quote Link to comment https://forums.phpfreaks.com/topic/184246-php-mysql-errors/#findComment-973741 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.