Page 1 of 1

mysql insert and form

Posted: Sat Jan 07, 2012 8:08 pm
by jayson.ph
Hi all,

i need advice for a simple Add code below that not work both mysql and form, please help

Code: Select all

<form action="welcome.php" method="post">
	Username: <input type="username" name="uname" />
		Password: <input type="password" name="pwd" />
<input type="submit" value="Submit" />
</form> 

<?php
$conn = mysql_connect("localhost","","");
	if(!$conn)
	{
	die("Server not found".mysql_error());
	}
		mysql_select_db("mydatabase", $conn);
			$sql = INSERT INTO  tbl_login("uname", "pwd") VALUES ("uname", "pwd");
			
	if(!mysql_query($sql, $conn));
	{
	die("error:".mysql_error());
	}
		echo "Thanks";
		mysql_close($conn)
?>

Re: mysql insert and form

Posted: Sat Jan 07, 2012 10:00 pm
by Gopesh
Hi,can u pls post the error you got...

Re: mysql insert and form

Posted: Sat Jan 07, 2012 10:59 pm
by jayson.ph
here is the error output..

Image

Re: mysql insert and form

Posted: Sat Jan 07, 2012 11:04 pm
by jayson.ph
the said line 15 error is this --> $sql = INSERT INTO tbl_login("uname", "pwd") VALUES ("uname", "pwd");

Re: mysql insert and form

Posted: Sat Jan 07, 2012 11:58 pm
by twinedev
You don't have the SQL statement that you are trying to $SQL wrapped in any type of quotes.

Re: mysql insert and form

Posted: Sun Jan 08, 2012 12:19 am
by jayson.ph
What is that?

Re: mysql insert and form

Posted: Sun Jan 08, 2012 12:44 am
by jayson.ph
Hi all, thanks and i appreciate to does who reply and view my post. and now i solve the problem. see below the code-

Code: Select all

$conn = mysql_connect("localhost","","");
	if(!$conn)
	{
	die("Server not found".mysql_error());
	}
		mysql_select_db("mydatabase", $conn);
			mysql_query("INSERT INTO tbl_login(username, password) VALUES ('uname', 'pwd')");