Hello
i am trying to set up a database on my home computer (to categorise books). I have it installed and, using mySQL in command line I can add lines etc.
When trying to add data through a form, I get the following error:
Fatal error: Call to undefined function: mysql_connect() in /home/hamish/public_html/db_books/sendtodb.php on line 21
Here are lines 8 to 23:
Code:
//get variables from index.php form in previous page
$author = $_REQUEST['author'];
$title = $_REQUEST['title'];
$year = $_REQUEST['year'];
$genre = $_REQUEST['genre'];
//set variables
$host = "localhost";
$user = "hc_books_user";
$password = "password";
$dbname = "hc_books";
$tablename = "books";
$Link = mysql_connect ($host, $user, $password); //line 21
$Query = "INSERT into $tablename values ('0', '$author', '$title', '$year', '$genre')";
As far as I can see, the $Link variable has all the data to work.
I wondered if I somehow needed to link the webpage to the database (or is that covered by localhost?) Or do I need to install a mySQL module for my Apache?
Form is at http://hamishnet.homelinux.com/~hamish/db_books/ .
the mySQL server is definately running and, AFAIK, I have correctly added the user with password.
If it that the $Link is looking for a database in the folder in which the PHP script is run from?
All help will be very much appreciated.
Thanks
Hamish
|