What caused this "Call to undefined function mysql_connect()" error in PHP?
I have been working on an app for a couple weeks now, using GoDaddy, Windows Server (I know it sucks) everything seemed ok, I have been a PHP programmer for about a year now and have never come across something like this, I have been connecting to a mysql db all day and all of a sudden I'm getting this error:
Call to undefined function mysql_connect() on Line 6
Could some type of a syntax error be 开发者_如何学编程causing this?
I was coding a curl that pulled an XML Feed because I couldn't use file_get_contents due to allow_url_fopen = off which seems to be impossible to change on godaddy with a windows server, and all of a sudden I got this error.
What could be causing this?
Here's the Code in question:
session_start();
$hostname = "test.com"; $user = "root"; $pw = "passwd";
$connection = mysql_connect($hostname,$user,$pw) or die("couldnt connect to db"); $db = mysql_select_db ('mydb',$connection) or die("couldnt find db");
I created a PHP5.ini to try to fix the allow_url_fopen and just found this question which could be related: Updating PHP.ini on a GoDaddy Hosted site
I have deleted the PHP5.ini file from the server, but the error still hasn't gone away, maybe it needs some time?
Maybe the MySQL extension is not installed for your PHP installtion. Create a php file and enter this:
<?php
phpinfo();
?>
See if you find a section called MySQL.
Perhaps they put a PHP installation up without MySQL installed. Sometimes hosts make that mistake.
Try and find an entry for MySQL in phpinfo();
.
Also, see what function_exists('mysql_connect')
says.
This was the problem god window sucks
Updating PHP.ini on a GoDaddy Hosted site
Administrative tools / services / MySQL : Start ! Thats it.
精彩评论