Jump to content

Recommended Posts

I have a bit of an interesting problem concerning the configuration of php and mysql. I cannot configure them to work together. Whenever try to connect to a mysql database, I get the following error: Fatal error: Call to undefined function mysql connect( ) .

I am currently using the latest version of mysql and php and am using a Windows 7 box as the server.

 

Due to certain restrictions, I cannot use a preconfigured web server or package (no xampp, apache or easyphp). Therefore, I am pretty much restricted to using the built-in development server that comes with php. So far, I have done the editing to the php.ini file, removed the semicolon from php_mysql.dll to remove the ; and changed extension_dir = "C:\PHP\ext" to reflect my extension folder.

 

I guess the two questions I have are:

 

A) can the php 5.4 included development server even connect to a mysql database

B) if so, can anyone provide me with some possible fixes to this configuration problem?

 

 

Any help given is appreciated.

 

 

Link to comment
https://forums.phpfreaks.com/topic/276161-php-mysql-configuration-with-a-twist/
Share on other sites

Keep in mind that MySQL is deprecated as of PHP 5.5.0 (that means its no longer supported and will be removed in th future). Instead, the MySQLi or PDO_MySQL extension should be used.

 

If you still have the shot the use a future proof SQL class, take it now.

Edited by DaveyK

@ gristoi: thank you for the correction, however, that was me typing out the error message I recieved, not copying it. Spelling error. My bad.

 

@DaveyK: What is mysqli? Is it any different from mysql? How do I configure php to use it?

Edited by questsword

You have to do anything to configure it, if your version of PHP is up to date its built in. The difference is that MySQL is deprecated as per PHP 5.5.0. That means php has dropped support for mysql and move on to mysqli or PDO_mysql(). The queries are the same (more or less), the PHP around it is a little different. However, as I said, PHP will not support mysql in the future and IF you can make a choice between what to use, Id suggest to go with the future proof option.

 

Personally, the project Ive been working on was too far into mysql before I found out I shouldnt be using it. So I still use mysql, but I will convert too.

Here is the issue I seem to be having: I cannot seem to enablemy extensions so that php can access the sql libraries. I am running this code to show my extensions:

<?php // extensions_list.php

$list = get_loaded_extensions();
$list2 = array_map('strtolower',$list);
sort($list2);
echo '<pre>'.print_r($list2,true).'</pre>';

?>

 

and this is what I get:

Array(    [0] => bcmath    [1] => calendar    [2] => cli_server    [3] => core    [4] => ctype    [5] => date    [6] => dom    [7] => ereg    [8] => filter    [9] => ftp    [10] => hash    [11] => iconv    [12] => json    [13] => libxml    [14] => mcrypt    [15] => mhash    [16] => mysqlnd    [17] => odbc    [18] => pcre    [19] => pdo    [20] => phar    [21] => reflection    [22] => session    [23] => simplexml    [24] => spl    [25] => standard    [26] => tokenizer    [27] => wddx    [28] => xml    [29] => xmlreader    [30] => xmlwriter    [31] => zip    [32] => zlib)

 

In the php.ini file, I have removed the semicolons for both the mysql and mysqli extensions to enable them, just like many guides online have said to do, but I can't seem to get the php libraries to load. Do you have any suggestions you could give me?

I dont know what you plan on doing, but I think (but do not know for sure) you can just use mysqli() without having to install anything.

 

for starters:

 

var_dump(function_exists ('mysqli_connect')); // dont use this function for real, its just a check if you  have th mysqli library

If this returns true, you can start using:

$sqli = new mysqli (LOCATION, USER, PASSWORD); // same credentials as used in mysql_connect()

That snippet of code came back false.

 

 

 

I dont know what you plan on doing, but I think (but do not know for sure) you can just use mysqli() without having to install anything.

 

for starters:

 

var_dump(function_exists ('mysqli_connect')); // dont use this function for real, its just a check if you  have th mysqli library

If this returns true, you can start using:

$sqli = new mysqli (LOCATION, USER, PASSWORD); // same credentials as used in mysql_connect()

What I think I need to ask is how to configure php extensions to work properly. None of my extensions are loading. PHP is not loading them when the development server is starting. I think my first step is to figure out why they are not loading and fix that first.

 

BTW, thank you for your help so far. I appreciate it.

 

I dont know, honestly. Well, its your own choice. Maybe you want to install mysqli then? I dont know how that works

you need to determine which php.ini file is being loaded.

 

create a php script with a phpinfo statement in it and browse to the php script. the Loaded Configuration File line is the php.ini that is being loaded. i'm pretty sure the command line version - development server of php will load the php.ini in the same folder where the php.exe file is at. if that that doesn't work, it should load the php.ini file it finds along the windows path statement, which should have the path to the php.exe file anyway.

Thanks for your help.

Unfortunately, my loaded configuration file  in phpinfo() says none even though I have the php.ini file in the same folder as php.exe. However, the configuration file path points toward c:\windows. I have thrown a copy of the .ini file in there as well, but nothing happened. Still getting none for the loaded configuration file.

 

 

you need to determine which php.ini file is being loaded.

 

create a php script with a phpinfo statement in it and browse to the php script. the Loaded Configuration File line is the php.ini that is being loaded. i'm pretty sure the command line version - development server of php will load the php.ini in the same folder where the php.exe file is at. if that that doesn't work, it should load the php.ini file it finds along the windows path statement, which should have the path to the php.exe file anyway.

is the filename of your php.ini just php.ini or is it php.ini.txt

 

windows hides the extensions of known file types by default (hackers love this and you should turn the setting off) and if you used a windows editor to modify the file, it may have a .txt entension.

I finally figured it out. My php.ini file was really named php.ini-development, which meant it was not being found by the development server. I was really nice of the php developers to intentionally screw up the php configuration file. Oh well.

 

You all have been very helpful with your suggestions. Thank you.

You must to configure if your version of PHP is by far the difference is that embedded MySQL is obsolete, since PHP 5.5.0 for. This means that PHP has removed support for MySQL and MySQLi or transient PDO_MYSQL (). Problems of the same (more or less), PHP around a little bit different. However, as I said, PHP does not support MySQL in the future, and if you can make a choice between what to use, I recommend you go with a promising option.

 

Personally, I worked on the project was too far in MySQL before I learned that you should not use. So I'm using MySQL, but I also converted.

You have to do anything to configure it, if your version of PHP is up to date its built in. The difference is that MySQL is deprecated as per PHP 5.5.0. That means php has dropped support for mysql and move on to mysqli or PDO_mysql(). The queries are the same (more or less), the PHP around it is a little different. However, as I said, PHP will not support mysql in the future and IF you can make a choice between what to use, Id suggest to go with the future proof option.

 

Personally, the project Ive been working on was too far into mysql before I found out I shouldnt be using it. So I still use mysql, but I will convert too.

 

 

You must to configure if your version of PHP is by far the difference is that embedded MySQL is obsolete, since PHP 5.5.0 for. This means that PHP has removed support for MySQL and MySQLi or transient PDO_MYSQL (). Problems of the same (more or less), PHP around a little bit different. However, as I said, PHP does not support MySQL in the future, and if you can make a choice between what to use, I recommend you go with a promising option.

 

 

 

Personally, I worked on the project was too far in MySQL before I learned that you should not use. So I'm using MySQL, but I also converted.

 

Wait what?!

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.