본문 바로가기

카테고리 없음

Call To Undefined Function Sql Connect Php Windows 7



Active4 months ago

I have ran aptitude install php5-mysql (and restarted MySQL/Apache 2), but I am still getting this error:

Fatal error: Call to undefined function mysql_connect() in /home/validate.php on line 21

phpinfo() says the /etc/php5/apache2/conf.d/pdo_mysql.ini file has been parsed.

Peter Mortensen
14.4k19 gold badges88 silver badges117 bronze badges

(mssql) Windows 7: 64-bit => PHP ติดต่อกับ MSSQL ไม่ได้ค่ะ Call to undefined function mssql_connect เริ่มหัวข้อใหม่ Guest. Fatal error: Call to undefined function mysql_connect() in /home/validate.php on line 21. Phpinfo() says the /etc/php5/apache2/conf.d/pdo_mysql.ini file has been parsed. Error: Call to undefined function mysql_connect() At the time, I used wamp to install them. Recently, my PC was changed out for new PC with Windows 7, 64bit machine.

user1765369user1765369
5072 gold badges6 silver badges13 bronze badges

13 Answers

Well, this is your chance! It looks like PDO is ready; use that instead.

Trim function sql

Try checking to see if the PHP MySQL extension module is being loaded:

If it's not there, add the following to the php.ini file:

Peter Mortensen
14.4k19 gold badges88 silver badges117 bronze badges
wanovakwanovak

I see that you tagged this with Ubuntu. Most likely the MySQL driver (and possibly MySQL) is not installed. Assuming you have SSH or terminal access and sudo permissions, log into the server and run this:

If the MySQL packages or the php5-mysql package are already installed, this will update them.

UPDATE

Since this answer still gets the occasional click I am going to update it to include PHP 7. PHP 7 requires a different package for MySQL so you will want to use a different argument for the apt-get command.

Examples: 'LaserJet Pro P1102 paper jam', 'EliteBook 840 G3 bios update' Need help finding your product name or product number? Hp agency series hstnn-c12c drivers. Warranty removed from product: This product was designated to be returned to HP.

And importantly, mysql_connect() has been deprecated since PHP v5.5.0. Refer the official documentation here: PHP: mysql_connect()

jameshfisher

Convert Function Sql

13.5k17 gold badges74 silver badges127 bronze badges
SarcastronSarcastron

If someone came here with the problem of docker php official images, type below command inside the docker container.

For more information, please refer to the link above How to install more PHP extensions section(But it's a bit difficult for me..).

Or this doc may help you.

kujiykujiy

In case, you are using PHP7 already, the formerly deprecated functions mysql_* were removed entirely, so you should update your code using the PDO-functions or mysqli_* functions instead.

These programming models are commonly used in Monte Carlo analysis or risk calculation in finance. Applications using these scale-out models are ideal for the Cloud because they can typically scale linearly. Hpc server 2008 crackle. Support for LINQ to HPC beta In the coming days, we will release a second beta for building data intensive applications (previously codenamed Dryad). Add more resources and get your work done faster!

If that's not possible, as a workaround, I created a small PHP include file, that recreates the old mysql_* functions with mysqli_*()-functions: fix_mysql.inc.php

rubo77rubo77
8,98115 gold badges79 silver badges165 bronze badges

I was also stuck with the same problem of undefined MySQL_connect().I tried to make changes in PHP.ini file but it was giving me the same error.Then I came to this solution where I changed my code from depreciated php functions to new functions.

I hope this will help you .This solution is correctly working for me .

EDIT:

If you upgrade form old php you need to apt-get install php7.0-mysql

Elia Weiss
2,9244 gold badges34 silver badges63 bronze badges
apurva sharmaapurva sharma

Try:

Run the page and search for mysql. If not found, run the following in the shell and restart the Apache server:

Also make sure you have all the following lines uncommented somewhere in your apache2.conf (or in your conf.d/php.ini) file, from

to

Peter Mortensen
14.4k19 gold badges88 silver badges117 bronze badges
fortunefortune
2,9901 gold badge15 silver badges30 bronze badges
Bhargav Rao
32.6k21 gold badges96 silver badges115 bronze badges
Dominic Amal Joe FDominic Amal Joe F

My guess is your PHP installation wasn't compiled with MySQL support.

Check your configure command (php -i | grep mysql). You should see something like '--with-mysql=shared,/usr'.

You can check for complete instructions at http://php.net/manual/en/mysql.installation.php. Although, I would rather go with the solution proposed by @wanovak.

Still, I think you need MySQL support in order to use PDO.

Peter Mortensen
14.4k19 gold badges88 silver badges117 bronze badges
MucMuc
9572 gold badges10 silver badges26 bronze badges

The question is tagged with ubuntu, but the solution of un-commenting the extension=mysqli.dll is specific to windows. I am confused here?!, anyways, first thing run <? php phpinfo ?> and search for mysql* under Configuration heading. If you don't see such a thing implies you have not installed or enabled php-mysql. So first install php-mysql

sudo apt get install php-mysql

This command will install php-mysql depending on the php you have already installed, so no worries about the version!!.

Then comes the unix specific solution, in the php.ini file un-comment the line

verify that msql.so is present in /usr/lib/php/<timestamp_folder>,ELSE

Then finally restart the apache and mysql services, and you should now see the mysql section under Configrations heading in phpinfo page

Dota2Dota2

I was getting this error because the project I was working on was developed on php 5.6 and after install, the project was unable to run on php7.1.

The best way to do this is to write a own serialize method which creates a JSON object with attributes, based on your getters. Normally you define a getter per attribute. So it should work for most cases (so you don't have to define a serialize. Nodejs with php. Tool to unserialize data taken from PHP. It can parse 'serialize()' output, or even serialized sessions data.

Just for anyone that uses Vagrant with ubuntu/nginx, in the nginx directory(/etc/nginx/), there is a directory named 'sites-available' which contains a file named like the url configured for the vagrant maschine. In my case was homestead.app. Within this file there is a line that says something like

There you can change the php version to the desired for that particular site.

Create Function Sql

Googled this but wasnt really able to find a simple answer that said where to look and what to change.

Hope that this helps anyone.Thanks.

freifedefreifede

If you are getting the error as

Fatal error: Call to undefined function mysql_connect()

Kindly login to the cPanel >> Click on Select Php version >> select the extension MYSQL

Aminah Nuraini
8,1394 gold badges55 silver badges71 bronze badges
Abhishek VaingadeAbhishek Vaingade

(Windows mysql config)

Step 1 : Go To Apache Control Panel > Apache > Config > PHP.ini

Step 2 : Search in Notepad (Ctrl+F) For: ;extension_dir = ' (could be commented with a ;). Replace this line with: extension_dir = 'C:phpext' (please do not you need to remove the ; on the beginning of the sentence).

Step 3 : Search For: extension=php_mysql.dll and remove the ; in the beginning.

Step 4 : Save and Restart You Apache HTTP Server. (On Windows this usually done via a UI)

That's it :)

If you get errors about missing php_mysql.dll you'll probably need to download this file from either the php.net site or the pecl.php.net. (Please be causius about where you get it from)

More info on PHP: Installation of extensions on Windows - Manual

Spidfire
2,8245 gold badges23 silver badges33 bronze badges
Piash SarkerPiash Sarker

There must be some syntax error. Copy/paste this code and see if it works:

I had the same error message. It turns out I was using the msql_connect() function instead of mysql_connect().

Peter Mortensen
14.4k19 gold badges88 silver badges117 bronze badges
lara_croftlara_croft

protected by MachavityOct 12 '17 at 18:39

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged phpmysqlubuntumysql-connectundefined-function or ask your own question.