Shaned145 Posted June 19, 2007 Share Posted June 19, 2007 Ok so Im trying to make a register function for my website. Im getting frustrated with it, Ive asked my friends to help me, but theyre either busy, or they dont want to help. LOL! (Such nice friends eh?) Heres my coding: <html> <body> <form action="registera.php" method="get"> Screen Name: <input type="text" name="sn" /> Password: <input type="text" name="pw" /> <input type="submit" /> </form> //open connection $con = mysql_connect("localhost","****","****"); if (!$con) { die('Could Not Connect: ' . mysql_error()); } else { echo "Connected!"; } //select database mysql_select_db("productions", $con); //write to table $idhigh = mysql_query("SELECT id FROM users ORDER BY desc"); $user = $_GET["sn"]; $pass = $_GET["pw"]; mysql_query("INSERT INTO users ( id, sn, pw) VALUES ( $idhigh+1, $user, $pass"); //close connection mysql_close($con); ?> </body> </html> I want it to get the username and password from the input boxes and I want it to add 1 more number to the highest id number in the table. Can anyone please help me? Quote Link to comment https://forums.phpfreaks.com/topic/56155-writing-to-my-table/ Share on other sites More sharing options...
Shaned145 Posted June 19, 2007 Author Share Posted June 19, 2007 *bump* Quote Link to comment https://forums.phpfreaks.com/topic/56155-writing-to-my-table/#findComment-277435 Share on other sites More sharing options...
KrisNz Posted June 19, 2007 Share Posted June 19, 2007 the function mysql_query() doesn't directly return the resulting data from your query. In any case you don't need to query the database to find the next id. You should set the id column in your table to auto_increment, that means whenever you insert a new record, the next available id will be automatically used for that record without you having to provide any data for that column. You should also read a few tutorials to help you along. http://www.phpfreaks.com/tutorials/142/0.php Quote Link to comment https://forums.phpfreaks.com/topic/56155-writing-to-my-table/#findComment-277439 Share on other sites More sharing options...
Shaned145 Posted June 19, 2007 Author Share Posted June 19, 2007 id is set to auto_increment. what do you mean by "mysql_query() doesn't directly return the resulting data from your query"? anywho, thanks for the link I'll be sure to look at it. Quote Link to comment https://forums.phpfreaks.com/topic/56155-writing-to-my-table/#findComment-277441 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.