I am recieving a fatal error trying to connect to my server/mysql. This is
my first attempt at connecting to a remote server, have been successful with
localhost (apache). I had the variation of not putting the hostname & others
into a variable, but that did not work either.
I have also genericised the username and password for this post. Host name
is correct.
Can anyone enlighted me as to what I am not doing correctly?
Fatal error: Call to undefined function: mysqli_connect() in
<?php
// Receiving variables
@$pfw_ip= $_SERVER['REMOTE_ADDR'];
@$first_name = addslashes($_POST['first_name']);
@$last_name = addslashes($_POST['last_name']);
@$company = addslashes($_POST['company']);
@$phone = addslashes($_POST['phone']);
@$email = addslashes($_POST['email']);
@$url = addslashes($_POST['url']);
@$comments = addslashes($_POST['comments']);
// Validation
if (strlen($phone) <8)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please
enter a valid phone</font></p>");
}
if (strlen($phone) >15)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please
enter a valid phone</font></p>");
}
if (! ereg('[a-za-z0-9_-...@[a-za-z0-9_-]+\.[a-za-z0-9_-]+', $email))
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please
enter a valid email</font></p>");
}
// checks if bot
if ($_POST['address'] != '' ){
die("Changed field");
}
//Connect To Database
$hostname='h50mysql43.secureserver.net';
$username='myusername';
$password='mypassword';
$dbname='mydbname';
$usertable='tablename';
$dbc = mysqli_connect('$hostname','$username','$password')
or die('Error connecting to MySQL server');
mysql_select_db('$usertable');
$query = "INSERT INTO contact(first_name, last_name, company, phone, email,
url, comments) ".
"VALUES
('$first_name','$last_name','$company','$phone','$email','$url','$comments')
";
$result = mysqli_query($dbc, $query)
or die('Error querying database.');
mysqli_close($dbc);
//Sending Email to form owner
$pfw_header = "From: $email\n"
. "Reply-To: $email\n";
$pfw_subject = "Subject Message";
$pfw_email_to = "[email protected]";
$pfw_message = "Visitor's IP: $pfw_ip\n"
. "name: $first_name . ' '.$last_name\n"
. "company: $company\n"
. "phone: $phone\n"
. "email: $email\n"
. "url: $url\n"
. "comments: $comments\n"
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>Thank
you for your submission, we will respond shortly!</font></p>");
echo "Thank you $first_name for your request<br />";
echo "We have the following information from you.<br />";?>
<br />
<?php
echo "First Name $first_name<br />";
echo "Last Name: $last_name<br />";
echo "Company Name: $company<br />";
echo "Phone Number: $phone<br />";
echo "Web Address: $url<br />";
echo "Email Address: $email.<br />";?>
<br />
<?php
echo "Your Comment: $comments<br />";
?>
<br ? />
<?php
echo 'Please review your information and feel free to correct any that may
be incorrect.<br />';?>
<br ? />
<?php
echo 'We will contact your shortly!';
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php