My Script Dosent Want To And Will Not Connect Lol
Posted: Sat Feb 10, 2007 10:04 am
Hello, ive just recently created a script, im reading from a book and learning and im trying to put to use what i have just learnt so that i will have a better understanding of whats going on, i have looked at the book now and then just to confirm im doing it all right, but it just wont work, it wont connect to the database to create a table, ive tried it on wamp server on my pc and also my web server, here is my code (dont mind my comments, im just trying to get into the habbit of making them lol):
here is the error that i get when doing it on my pc:
here is the error on my web server:
this is whats in "db-inc.php":
passwords blocked out.
can anybody see what ive done wrong? thanks for any help, im really stuck.
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.