Jump to content


Photo

php & mysql: configuration with a twist

configuration php mysql fatal error

  • Please log in to reply
18 replies to this topic

#1 questsword

questsword

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 25 March 2013 - 11:58 PM

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.

 

 



#2 gristoi

gristoi

    Advanced Member

  • Members
  • PipPipPip
  • 805 posts

Posted 26 March 2013 - 07:34 AM

try using the correct funciton name : mysql_connect( ), not mysql connect( )


Edited by gristoi, 26 March 2013 - 07:35 AM.

To err is human... to really foul up requires the root password

#3 DaveyK

DaveyK

    Advanced Member

  • Members
  • PipPipPip
  • 288 posts
  • LocationThe Netherlands

Posted 26 March 2013 - 07:37 AM

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, 26 March 2013 - 07:38 AM.


#4 questsword

questsword

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 26 March 2013 - 08:37 AM

@ 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, 26 March 2013 - 08:37 AM.


#5 DaveyK

DaveyK

    Advanced Member

  • Members
  • PipPipPip
  • 288 posts
  • LocationThe Netherlands

Posted 26 March 2013 - 08:50 AM

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.



#6 questsword

questsword

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 26 March 2013 - 08:58 AM

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?



#7 DaveyK

DaveyK

    Advanced Member

  • Members
  • PipPipPip
  • 288 posts
  • LocationThe Netherlands

Posted 26 March 2013 - 09:12 AM

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()


#8 questsword

questsword

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 26 March 2013 - 09:27 AM

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()


#9 questsword

questsword

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 26 March 2013 - 09:37 AM

Also, should I be editing both php.ini files that come with the php installation? I have both a development and production php.ini file.



#10 DaveyK

DaveyK

    Advanced Member

  • Members
  • PipPipPip
  • 288 posts
  • LocationThe Netherlands

Posted 26 March 2013 - 10:07 AM

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



#11 questsword

questsword

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 26 March 2013 - 10:19 AM

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



#12 mac_gyver

mac_gyver

    Advanced Member

  • Administrators
  • 2,233 posts

Posted 26 March 2013 - 10:29 AM

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.


multi-purpose programming fool and resident naysayer [We try not be negative in replies, but telling someone what they're doing wrong, while staying politically correct, isn't always going to happen.]

#13 questsword

questsword

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 26 March 2013 - 10:40 AM

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.



#14 mac_gyver

mac_gyver

    Advanced Member

  • Administrators
  • 2,233 posts

Posted 26 March 2013 - 10:55 AM

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.


multi-purpose programming fool and resident naysayer [We try not be negative in replies, but telling someone what they're doing wrong, while staying politically correct, isn't always going to happen.]

#15 questsword

questsword

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 26 March 2013 - 11:16 AM

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.



#16 jackhard

jackhard

    Member

  • Members
  • PipPip
  • 12 posts

Posted 27 March 2013 - 10:56 PM

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.



#17 DaveyK

DaveyK

    Advanced Member

  • Members
  • PipPipPip
  • 288 posts
  • LocationThe Netherlands

Posted 28 March 2013 - 04:07 AM

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?!



#18 annaharris

annaharris

    Advanced Member

  • Members
  • PipPipPip
  • 56 posts

Posted 01 April 2013 - 07:47 AM

If you are using the latest version of PHP then avoid using the “mysql_connect()” function as this function is no longer supported by PHP. You can try this function "PDO_mysql()".



#19 mac_gyver

mac_gyver

    Advanced Member

  • Administrators
  • 2,233 posts

Posted 01 April 2013 - 08:10 AM

two or three people have already mentioned that :thumb-up:


multi-purpose programming fool and resident naysayer [We try not be negative in replies, but telling someone what they're doing wrong, while staying politically correct, isn't always going to happen.]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com