duffman014 Posted July 26, 2009 Share Posted July 26, 2009 hey there ok lets start off here... Im still very new to this so please be patient with me... im trying to create a login registration... my problems are as follows... on my registration form i think i have the html correct it all looks right perhaps im not outputting the data corectly im not sure... second... on my php side... it wont input the data into my database... im pretty sure i have that correct to or maybe i've missed something all togeather... here my code please let me know what im doing wrong... gonna drive me crazy... thanks, <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form name="regform" method="post" action="addtomembers.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>Member Registration </strong></td> </tr> <tr> <td width="78">Username:</td> <td width="294"><input name="myusername" type="text" id="myusername"></td> </tr> <tr> <td>Password:</td> <td width="294"><input name="mypassword" type="text" id="mypassword"></td> </tr> <tr> <td>Email:</td> <td width="294"><input name="email" type="text" id="email"></td> </tr> <tr> <td>First Name:</td> <td width="294"><input name="firstname" type="text" id="firstname"></td> </tr> <tr> <td>Last Name:</td> <td width="294"><input name="lastname" type="text" id="lastname"></td> </tr> <tr> <td> </td> <td> </td> <td width="294"><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </td> </form> </tr> </table> ===-------------------------------------------------------------------------- here my php side of things[/img] <?php $host="randomt.db.2342342342342344688039.hostedresource.com"; // Host name $username="bludgeonaccount"; // Mysql username $password="randompassword"; // Mysql password $db_name="bludgeonaccount"; // Database name $tbl_name="members"; // Table name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Get values from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $firstname=$_POST['firstname']; $lastname=$_POST['lastname']; $email=$_POST['email']; // Insert data into mysql $sql="INSERT INTO $tbl_name(myusername, mypassword, firstname, lastname, email,)VALUES('$myusername','$mypassword','$firstname', '$lastname', '$email')"; $result=mysql_query($sql); // if successfully insert data into database, displays message "Successful". if($result){ echo "Successful"; echo "<BR>"; echo "<a href='insert.php'>Back to main page</a>"; } else { echo "ERROR"; } // close connection mysql_close(); ?> Link to comment https://forums.phpfreaks.com/topic/167552-php-mysql-help/ Share on other sites More sharing options...
ldougherty Posted July 26, 2009 Share Posted July 26, 2009 On your insert query you have a comma after email which shouldn't be there. $sql="INSERT INTO $tbl_name(myusername, mypassword, firstname, lastname, email) VALUES ('$myusername','$mypassword','$firstname', '$lastname', '$email')"; Everything else looks fine to me, if you still have a problem let us know the error. Link to comment https://forums.phpfreaks.com/topic/167552-php-mysql-help/#findComment-883510 Share on other sites More sharing options...
duffman014 Posted July 26, 2009 Author Share Posted July 26, 2009 On your insert query you have a comma after email which shouldn't be there. $sql="INSERT INTO $tbl_name(myusername, mypassword, firstname, lastname, email) VALUES ('$myusername','$mypassword','$firstname', '$lastname', '$email')"; Everything else looks fine to me, if you still have a problem let us know the error. http://www.cndalliance.com/login/reg.php here the site i'm trying it on ... it keeps kicking out to the error page instead of sucess???? still not sure why and thx for spotting that coma lol... Link to comment https://forums.phpfreaks.com/topic/167552-php-mysql-help/#findComment-883517 Share on other sites More sharing options...
ldougherty Posted July 26, 2009 Share Posted July 26, 2009 Try changing your query as such.. change this.. $result=mysql_query($sql); to $result=mysql_query($sql) or die("MySQL ERROR: ".mysql_error()); This should tell you the mySQL error you are encountering. You should also try and output the variables prior to inserting them into the database to see if they have the values you expect. Link to comment https://forums.phpfreaks.com/topic/167552-php-mysql-help/#findComment-883528 Share on other sites More sharing options...
duffman014 Posted July 27, 2009 Author Share Posted July 27, 2009 Ok i fixed some of the errors know i cant get it to out put ... here my output code... i just took out the last else statment and put this for an output page... actuall errors are coming up know... Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\Hosting\4688039\html\Login\addtomembers.php on line 26 while($rows=mysql_fetch_array($result)){ ?> <table width="400" border="1" cellspacing="0" cellpadding="3"> <tr> <td width="10%"><? echo $rows['id']; ?></td> <td width="30%"><? echo $rows['myusername']; ?></td> <td width="30%"><? echo $rows['mypassword']; ?></td> <td width="30%"><? echo $rows['firstname']; ?></td> <td width="30%"><? echo $rows['lastname']; ?></td> <td width="30%"><? echo $rows['email']; ?></td> </tr> </table> <? Link to comment https://forums.phpfreaks.com/topic/167552-php-mysql-help/#findComment-883542 Share on other sites More sharing options...
duffman014 Posted July 27, 2009 Author Share Posted July 27, 2009 ok i know what i did wrong.. COMPLETELY FORGOT TO ASK THE SERVER FOR THE INFORMATION BACK OOPS... thx for all your help Link to comment https://forums.phpfreaks.com/topic/167552-php-mysql-help/#findComment-883562 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.