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... Quote 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? Quote 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. Quote 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... Quote 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..."); Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/65840-connect-to-mysql-problem/#findComment-329675 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.