internetguy
Technical User
I am having trouble inserting data into a database. The connection is good because there is no error reported in the mysql_connect(). Here is my code, let me know if there is anthing wrong.
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$url = $_POST['url'];
$db = mysql_connect('localhost','root');
if (!$db)
{
echo 'Failure to connect to database, please try later.';
}
mysql_select_db('users');
$query = "INSERT INTO info VALUES ('".$name."', '".$url."', '".$email."')";
$result = mysql_query($query);
if ($result)
echo 'your information has been submited';
?>
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$url = $_POST['url'];
$db = mysql_connect('localhost','root');
if (!$db)
{
echo 'Failure to connect to database, please try later.';
}
mysql_select_db('users');
$query = "INSERT INTO info VALUES ('".$name."', '".$url."', '".$email."')";
$result = mysql_query($query);
if ($result)
echo 'your information has been submited';
?>