omgh4x0rz
2007-04-21 18:59:24
Ok, I'm just starting to learn php and I just hooked it up to a mysql database. How do I get it to show the data on the page? I tried using SHOW TABLES, but nothing happens. Help please
Heres my code (sorry if the standards suck balls) I'm 99% sure it is connecting to the database right because I have it say "database accessed" if the select_db returns true.
Heres my code (sorry if the standards suck balls) I'm 99% sure it is connecting to the database right because I have it say "database accessed" if the select_db returns true.
<?php
$con = mysql_connect("host","database","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
else
{
echo 'connected successfully...';
if (mysql_select_db("database", $con))
{
echo 'Database accessed!';
$sql= "CREATE TABLE persons
(
personID int NOT NULL AUTO_INCREMENT,
PRIMARY KEY(personID),
Firstname varchar(15),
Lastname varchar(15),
Age int
)";
mysql_query($sql, $con);
mysql_query("INSERT INTO persons(Firstname, Lastname, Age)
VALUES('Im not', 'Telling My Name', 16)");
mysql_query("SHOW TABLES");
}
else
{
echo "You suck at mysql: ".mysql_error();
}
}
mysql_close($con);
?>