K
Kevin S
Guest
<?php
$con = mysql_connect("localhost","Username","Password");
echo "con = ";
echo $con;
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
else
{
$db = mysql_select_db("MyDb", $con);
echo "<P>";
echo "db = ";
echo $db;
$mysql_query = ("INSERT INTO `MyDb`.`Users` (Email, UserName, Password, DateJoined) VALUES (g, g, g, 2010-08-31)");
echo "<P>";
echo "mysql = ";
echo $mysql_query;
}
mysql_close($con);
echo "connection closed";
?>
The output is:
con = Resource id #1
db =
mysql = INSERT INTO `MyDb`.`Users` (Email, UserName, Password, DateJoined) VALUES (g, g, g, 2010-08-31)connection closed
If I run the insert sql statment from my php admin an etry is added to the table correctly.
Thanks, I've tried that and it doesn't work. When I use my php admin theres an option to create php code that gives
$sql = "INSERT INTO MyDb`.`Users` (`Email`, `UserName`, `Password`, `DateJoined`) VALUES (\'sd\', \'sd\', \'sd\', \'2010-09-22\');";
putting that into my php script doesn't work though.
Ok that didn't work either. I know the sql works if I run it through my php admin. How can I check my connection to the db?
$con = mysql_connect("localhost","Username","Password");
echo "con = ";
echo $con;
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
else
{
$db = mysql_select_db("MyDb", $con);
echo "<P>";
echo "db = ";
echo $db;
$mysql_query = ("INSERT INTO `MyDb`.`Users` (Email, UserName, Password, DateJoined) VALUES (g, g, g, 2010-08-31)");
echo "<P>";
echo "mysql = ";
echo $mysql_query;
}
mysql_close($con);
echo "connection closed";
?>
The output is:
con = Resource id #1
db =
mysql = INSERT INTO `MyDb`.`Users` (Email, UserName, Password, DateJoined) VALUES (g, g, g, 2010-08-31)connection closed
If I run the insert sql statment from my php admin an etry is added to the table correctly.
Thanks, I've tried that and it doesn't work. When I use my php admin theres an option to create php code that gives
$sql = "INSERT INTO MyDb`.`Users` (`Email`, `UserName`, `Password`, `DateJoined`) VALUES (\'sd\', \'sd\', \'sd\', \'2010-09-22\');";
putting that into my php script doesn't work though.
Ok that didn't work either. I know the sql works if I run it through my php admin. How can I check my connection to the db?