Code: Select all
<?php
//include database details
include('include/db-inc.php');
//include the header of the page
include('include/header.php');
//database connections
$mysql_con = "@mysql_connect('$host','$user','$password')";
$select_db = "@mysql_select_db('$database')";
//check if connection was successfull
if(!$mysql_con){
exit('<p>Error: Unable to connect to the host.</p>');
};
//check if database exists
if(!$select_db) {
exit('<p>Error: Unable to connect to the database.</p>');
};
//all is good, lets proceed to create the jokes table
$sql = 'CREATE TABLE joke(
id INT NOT NULL AUTO-INCREMENT PRIMARY KEY,
joketext TEXT,
jokedate DATE NOT NULL
)';
//check if adding table was sucessfull
if (@mysql_query($sql)) {
echo 'Joke table sucessfully created';
}
else {
exit('<p>error creating table: ' .
mysql_error() . '</p>');
}
//include the footer of the page
include('include/footer.php');
?>here is the error that i get when doing it on my pc:
i dont know what ODBC is, the user im trying to connect with is called jack, all the paswords `etc are correct.error creating table: Access denied for user 'ODBC'@'localhost' (using password: NO)
here is the error on my web server:
error creating table: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
this is whats in "db-inc.php":
Code: Select all
<?php
//mysql database details
$host = "********";
$database = "*******";
$user = "******";
$password = "*****";
?>can anybody see what ive done wrong? thanks for any help, im really stuck.