|
PHP and MySQL Help
Hello Everybody:
I am learning PHP & MySQL by reading "Head First PHP & MySQL" by Lynn Beighley and Michael Morrison. I have a problem with Chapter 2.
I can not automatically connect to/or insert information into the MySQL Database that I created (I am able to manually go into the database via. PHPMyAdmin and insert new info.)
My Hosting is with GoDaddy (maybe this is the whole problem). I have sent numerous requests for help through their support system, but they have not helped. My Website uses Linux, shared hosting, the Hosting Configuration is 2.0, PHP version is 5.x, and the database is MySQL 5.0.
Whenever I fill out the form and click Report Abduction, I receive the following error message:
Fatal error: Call to undefined function: mysqli_connect() in /home/content/I/m/i/UserIDKeptPrivate/html/report2.php on line 38
Please note that I changed the real UserID to UserIDKeptPrivate for security reasons.
The php coding that I used is as follows:
<html>
<head>
<title>Aliens Abducted me - Report an Abduction</title>
</head>
<body>
<h2>Aliens Abucted me - Report an Abduction</h2>
<?php
$first_name = $_POST['firstname'];
$last_name = $_POST['lastname'];
$when_it_happened = $_POST['whenithappened'];
$how_long = $_POST['howlong'];
$how_many = $_POST['howmany'];
$alien_description = $_POST['aliendescription'];
$what_they_did = $_POST['whattheydid'];
$fang_spotted = $_POST['fangspotted'];
$email = $_POST['email'];
$other = $_POST['other'];
$SQL = mysqli_connect('h50mysql79.secureserver.net', 'codinjackwel84', 'KeptPrivate', 'codinjackwel84')
or die('Error connecting to MySQL server.');
$query = "INSERT INTO aliencraft(first_name, last_name, when_it_happened, how_long, " .
"how_many, alien_description, what_they_did, fang_spotted, other, email) " .
"VALUES ('$first_name', '$last_name', '$when_it_happened', '$how_long', '$how_many', " .
"'$alien_description', '$what_they_did', '$fang_spotted', '$other', '$email')";
$result = mysqli_query($dbc,$query)
or die('Error querying database.');
echo 'Thanks for submitting the form.<br />';
echo 'You were abducted' . $when_it_happened;
echo ' and were gone for ' . $how_long . '<br />';
echo ' Number of aliens: ' . $how_many . '<br />';
echo 'Describe them: ' . $alien_description . '<br />';
echo ' The aliens did this: ' . $what_they_did . '<br />';
echo 'Was Fang there? ' . $fang_spotted . '<br />';
echo ' Other comments: ' . $other . '<br />';
echo 'Your email address is ' . $email;
?>
</body>
</html>
I would appreciate it if somebody could provide the correct coding.
Maybe I should switch Hosting Companies? If so, which one(s)?
Thank you.
|