PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
jayson.ph
Forum Contributor
Posts: 165 Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:
Post
by jayson.ph » Sat Jan 07, 2012 8:08 pm
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)
?>
Gopesh
Forum Contributor
Posts: 143 Joined: Fri Dec 24, 2010 12:48 am
Location: India
Post
by Gopesh » Sat Jan 07, 2012 10:00 pm
Hi,can u pls post the error you got...
jayson.ph
Forum Contributor
Posts: 165 Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:
Post
by jayson.ph » Sat Jan 07, 2012 10:59 pm
here is the error output..
jayson.ph
Forum Contributor
Posts: 165 Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:
Post
by jayson.ph » Sat Jan 07, 2012 11:04 pm
the said line 15 error is this --> $sql = INSERT INTO tbl_login("uname", "pwd") VALUES ("uname", "pwd");
twinedev
Forum Regular
Posts: 984 Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio
Post
by twinedev » Sat Jan 07, 2012 11:58 pm
You don't have the SQL statement that you are trying to $SQL wrapped in any type of quotes.
jayson.ph
Forum Contributor
Posts: 165 Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:
Post
by jayson.ph » Sun Jan 08, 2012 12:19 am
What is that?
jayson.ph
Forum Contributor
Posts: 165 Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:
Post
by jayson.ph » Sun Jan 08, 2012 12:44 am
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')");