Re: Problem with connecting to MySQL from PHP script



J D wrote:
Hi!

I have one problem and I'm hoping that someone can help me. I'm writing PHP script and wish to connect to MySQL database from PHP script but I can't, always get error message like this:

Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\htdocs\CMS3\install\connect.php on line 10

My script looks like this:

<?php
 $database="cmsdbase";
 $mysql_user = "root";
 $mysql_password = "loz001";
 $mysql_host = "localhost";
 $mysql_table_prefix = "";



$success = mysql_pconnect($mysql_host, $mysql_user, $mysql_password);
if (!$success)
die ("<b>Cannot connect to database, check if username, password and host are correct.</b>");
$success = mysql_select_db($database);
if (!$success) {
print "<b>Cannot choose database, check if database name is correct.";
die();
}
?>


I tried to use mysql_connect() but result is the same error message. Btw, I'm using MySQL Server 4.1 and PHP 5.0.4.

Can anyone help me? Thanks!


Hello,

This sounds like a problem with the password...
Try this query and try reconnecting

SET PASSWORD FOR 'user'@'host' = OLD_PASSWORD('password');

this will solve the problem in 99% of the cases

Arno
.



Relevant Pages

  • Re: [PHP] Attaching File to be Emailed
    ... which will then be sent via php script. ... Can anyone provide sample code or point me in the right direction. ... "Serving out a file to Firefox ... ... If you wanted to store the data in a MySQL database it would be the same ...
    (php.general)
  • Re: recall id after adding a query to MySQL database
    ... > When I add a entry to my mysql database from a PHP form, ... which is generated by MySQL. ... > lines of PHP script and unnecessary queries. ...
    (comp.lang.php)
  • Re: check on reading webpage
    ... readflag in the MySql database let us say, every week, and send a mail ... trigger the event by somebody loading a PHP script via the 'net. ... could make a page which only you can load, ... in after a given time each week and launch the mailing process. ...
    (comp.lang.php)
  • Re: MySQL Logging
    ... > is being done by a PHP script that runs a query on a Mysql database and I ... > need to see what is the biggest item searched for ... Easiest is IMHO to make the PHP script to log the search queries. ...
    (alt.linux)
  • recall id after adding a query to MySQL database
    ... must be a clever solution. ... I did not find it untill now. ... When I add a entry to my mysql database from a PHP form, ... lines of PHP script and unnecessary queries. ...
    (comp.lang.php)