suigion Posted August 20, 2007 Share Posted August 20, 2007 Hi All, I am new in PHP. I try to insert data into MySQL Table, table name is "member".But, nothing happen. The table still contains 0 row. Here is the code: <?php $user = $_POST["username"]; $email = $_POST["email"]; $password = $_POST["password"]; $db = mysql_connect("localhost","root","suigion"); mysql_select_db("blogzone",$db); $sql = "INSERT INTO member(Username, Email, Password) VALUES ('$user','$email','$password')"; mysql_query($sql,$db); mysql_close($db); ?> Can anyody tell me what's wrong with the code??? Thanks in advance... Link to comment https://forums.phpfreaks.com/topic/65840-connect-to-mysql-problem/ Share on other sites More sharing options...
trq Posted August 20, 2007 Share Posted August 20, 2007 Change this.... mysql_query($sql,$db); to... if (mysql_query($sql,$db)) { echo "success"; } else { echo "Query failed...<br />" . mysql_error() . "<br />$sql<br />"; } What do you get? Link to comment https://forums.phpfreaks.com/topic/65840-connect-to-mysql-problem/#findComment-329021 Share on other sites More sharing options...
trq Posted August 20, 2007 Share Posted August 20, 2007 Actually, change your query while your at it. $sql = "INSERT INTO member (Username, Email, `Password`) VALUES ('$user','$email','$password')"; Password is a reserved word. Link to comment https://forums.phpfreaks.com/topic/65840-connect-to-mysql-problem/#findComment-329024 Share on other sites More sharing options...
suigion Posted August 21, 2007 Author Share Posted August 21, 2007 Hi, I have try your suggestions, but the browser display nothing. It just blank... Do I need to install additional things?? I have install MySQL and PHP 5... Thanks... Link to comment https://forums.phpfreaks.com/topic/65840-connect-to-mysql-problem/#findComment-329576 Share on other sites More sharing options...
pranav_kavi Posted August 21, 2007 Share Posted August 21, 2007 initally try tis, mysql_connect("localhost","root","suigion") or die("Unable to connect to database..."); mysql_select_db("blogzone") or die("Unable to select database..."); Link to comment https://forums.phpfreaks.com/topic/65840-connect-to-mysql-problem/#findComment-329583 Share on other sites More sharing options...
suigion Posted August 21, 2007 Author Share Posted August 21, 2007 thanks for your idea, but the problem is not solved yet. I think I have to configue the PHP so that it can support MySQL operation. Did anybody know how to change the php.ini file ??? Thnks Link to comment https://forums.phpfreaks.com/topic/65840-connect-to-mysql-problem/#findComment-329675 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.