Jump to content

Connect to MySQL from PHP does not work


qeldroma
 Share

Recommended Posts

Fatal error: Call to undefined function: mysql_connect() in /var/www/html/templates/sql.php on line 4

 

...was the answer as i tried this command.

I installed LM9.1 + Apache2 + PHP4 + PHP-MySQL-Module

 

PHP is interpreted, only the mysql-commands not.

Does anybody...?

Link to comment
Share on other sites

Seeing how I just spent the last week reading up on MySQL issues :wink: let me make an attempt at this:

 

I would first doublecheck your $dbname, $dbpass or $dbuname are correct in your config file and check that you can first connect to your MySQL database. Webmin or phpmyadmin are two programs I have been using to check my databases.

Link to comment
Share on other sites

Yes, MySqlCC works too. This is the program that helped me fix my MySQL problem. For me, it found a problem in several of the tables and by clicking the quick fix button on each, I was able to salvage my database.

 

What is this line 4 of sql.php ? Do other php scripts run ?

 

And also lets double check which modules you have installed for php and apache.

Link to comment
Share on other sites

I would start at the begining, can you connect to your database from a console? If you can then it is an Apache problem, or failing that it would be a database error.

Once you know whats wrong you can try and fix it better.

Link to comment
Share on other sites

Well, shell-connect is no problem, the connect via other tools either.

 

In that line is only the connect-command, with hardcoded Database variables, as it was as it worked before...

 

I think, that php does not recognize the mysql-module, but how to proove?

 

The module ist htere, inbound in the /etc/php-directory, so no obvious hint for the failure...

Link to comment
Share on other sites

Gotta double check our syntax here:

mysql_connect("localhost","user","pass");

(semi-colons look very much like colons sometimes)

 

and for a laugh, I was searching around for an answer here and came across this: http://www.phphelp.com/ then click on their forums link in top left box.

(Its a php help board that needs help with their php.)

Link to comment
Share on other sites

The syntax is correct!

Remember, i told that it worked before LM9.1....

 

It seems that the php-mysql-module isn't inbound, but how to do?

I read in "php.ini" that it just has to be situated in the /etc/php directory, like the rpm did it. But that's not working. In "phpinfo()" i can see some undefined things concerning mysql, so i believe, that this step isn't in order...

Link to comment
Share on other sites

Guest tezca

your correct in the phpinfo function, if it dosn't look like its enabled, its not

 

looks to me like you need a couple more rpms from the cd, the ones concerning php & mysql, not the packages themselves, but their "rpm modules" I dont remember the exact names, but trust me that is what the problem is, if you have a gui on that machine bring up the package manager and search for all items that have php and mysql once you see it you'll know what it is.

 

Fatal error: Call to undefined function: mysql_connect()

 

thats why it dosn't recognize this function.

Link to comment
Share on other sites

Guest xaff

You need to compile PHP with mysql to be able to use mysql. (./configure --with-mysql)

 

"Call to undefined function" = It's not installed.

 

Syntax for mysql_connect();

mysql_connect("ip", "user", "password");

 

Though I would recommend putting an @ on it. (Conceals errors)

 

@mysql_connect("ip", "user", "password");

Link to comment
Share on other sites

Hey , update apache 2 from any FTP and I think this solve your problem, but I have problem with

mysql_create_db, I dont know what is happening.

 

I you update , try phpinfo and mysql apears to be ok ...

 

 

 

 

Bruno

Link to comment
Share on other sites

Guest tezca

you dont need to do all that you just need the "phpmysql.rpm" or something with a name close to that once you install that rpm restart apache and itll detect the new modules and php will work with mysql

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
 Share

×
×
  • Create New...