Jump to content

Call to undefined function mysql_connect()


Guest droz

Recommended Posts

Guest droz
i've been searching the internet for a while.  Tried everything this forum and all other sites say and nothing works.
I just recently installed :

MySql 5.0
Apache 2.2
PHP 5.1.4

on a windows xp computer.

Php and Apache work fine together, and MySql works fine on it's own.
I looked under control panel - administrative tools - services......and MySql is running.

i've done the following changes to my php.ini file :

Change  : ;extension=php_mysql.dll
to : extension=php_mysql.dll
//////
extension_dir = "C:\PHP\ext" (where all my .dll files are located)
/////
extension=php_mysqli.dll
/////
and some other things other forums said to try but none worked


I've tried copying the libmysql.dll and libmysqli.dll files into C:\PHP\ext, C:\windows, C:\system, C:\system32, and that didn't work

When i use <?php phpinfo() ?> i read a big section should be on there about mysql, but there isn't.  The only thing refering to mySql is :

Apache Enviornment

variable      Value

Path          C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI 
                Technologies\ATI Control Panel;C:\Program Files\Common Files\Adaptec 
                Shared\System;[b]C:\Program Files\MySQL\MySQL Server 5.0\bin[/b]


Also the same thing, as shown above, is under "PHP Variables" and "Enviornment" sections.


And i made sure it's pointing to the right php.ini file

this is the output of C:\PHP>php -m (which from what i've seen from others, ??? looks normal)
[PHP Modules]
bcmath
calendar
com_dotnet
ctype
date
dom
ftp
hash
iconv
libxml
mbstring
msql
mysql
mysqli
odbc
pcre
Reflection
session
SimpleXML
SPL
standard
tokenizer
wddx
xml
xmlreader
xmlwriter
zlib

[Zend Modules]

I read in one forum to copy a config.php.dist file over an existing config.php file, but i couldn't find a config.php on my computer.

Also i read that a mysql.so file needs to be loaded into the php.ini file
but when i put extension=mysql.so into my php.ini file the following happens

C:\PHP>php -m
PHP Warning: PHP Startup: Unable to load dynamic library 'c:\PHP\ext\mysql.so'
-The specified module could not be found.
in Unknown on line 0
//followed by what was in the last output

So i searched my computer for a mysql.so file....I didn't find it.

And this is what my .php file looks like that i'm trying to run:

<?php
$dbServer='localhost';

$dbUser='username';
$dbPass='password';


$dbName='test';

    $link = mysql_connect("$dbServer", "$dbUser", "$dbPass") or die("Could not connect");
    print "Connected successfully<br>";
    mysql_select_db("$dbName") or die("Could not select database");
    print "Database selected successfully<br>";

mysql_close($link);

?>


The username and password are correct
I've also tried using another database instead of "test"


Also i have tried using the PEAR DB class to connect to Mysql using the following code:

<?php
require_once('pear\DB.php');

$username = 'username';
$password = 'password';
$hostspec = 'localhost';
$database = 'bank';

$phptype = 'mysql';

$dsn = "$phptype://$username:$password@$hostspec/$database";


$conn = DB::connect($dsn);
if (DB::isError($conn)) {
die ("Cannot connect:" . $conn->getMessage () . "\n");
}

?>

And "Cannot connect:DB Error: not found" shows up on the screen when i use that script.


I think thats all i have tried, if anyone can help me it would be appreciated!
Link to comment
Share on other sites

Also DONT move the extensions out of the ext directory. Also when you make changes to the php.ini make sure you restart the server. Also I notice you are using Apache2.2, unless I am mistaken, currently PHP doesn't offically support this version of Apache. You might want to downgrade to Apache 2.0.x

Also about the mysql.so file I believe that is for OS other than Windows. PHP Extensions for Windowws are dll files. .so files are for other OS I beleive.
Link to comment
Share on other sites

OKay have you moved a file called libmysql.dll form the root of the PHP folder to the windows folder.

Make sure you move any files and modify any files you restart the server for the new settings to be loaded into memory, otherwise the new settings wont come available until the server is restarted. Also add the PHP folder to the Windows Path variable and add the following line:
#PHPIniDir
PHPIniDir "C:/PHP"

To Apache httpd.conf file too. POlace the php.ini in the PHP folder when you add the PHP folder to Windows PATH variable.

When you create the chnage the PATH variable you must restart your computer.
Link to comment
Share on other sites

Basically when you add the PHP folder to the PATH it allows PHP to look for files automatically as it can access itself. It is best to add the PHP folder to the PATH as then all PHP related files are located in one place which is the PHP folder. However instead of creating a PHP folder can threoretically move all the files and folders from the PHP folder to the Windows folder or the System32 Folder.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.