Executing SQL statements using PHP
Posted: 20. January 2007 18:52
im trying to insert a table into one of my databases using the following code...
<?php
$db= mysql_connect("localhost", "root", "");
mysql_select_db("people2", $db);
$sql = "CREATE TABLE mytable (col1 INT, col2 VARCHAR(10))";
mysql_query($sql, $conn);
mysql_close($db);
?>
but when i run the script i get this error message:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\Program Files\xampp\htdocs\xampp\Mystuff\new\sqltest.php on line 8
Anyone know the problem here? I'm using the code from a PHP book i have
thanks
<?php
$db= mysql_connect("localhost", "root", "");
mysql_select_db("people2", $db);
$sql = "CREATE TABLE mytable (col1 INT, col2 VARCHAR(10))";
mysql_query($sql, $conn);
mysql_close($db);
?>
but when i run the script i get this error message:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\Program Files\xampp\htdocs\xampp\Mystuff\new\sqltest.php on line 8
Anyone know the problem here? I'm using the code from a PHP book i have
thanks