Re: Fatal error: Call to undefined function: mysqli_connect() in
| From: | Gary | Date: | Sat, 14 Mar 2009 23:36:54 +0000 |
| Subject: | Re: Fatal error: Call to undefined function: mysqli_connect() in | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-290063@lists.php.net to get a copy of this message | ||
Thank you to everybody, turns out that in the godaddy control panel, you
have the option of php4 or php5, and they have 4 as the default. A call to
gd and I was able to switch and it now works.
Thanks again for all your help!
Gary
""Gary"" <gwpaul@ptd.net> wrote in message
news:D1.A0.60648.83BEBB94@pb1.pair.com...
>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@email.com";
> $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!';
> ?>
>