php-mysql

I have installed “php/mysql” for http server “Apache” with “yast”.

“Apache” interfaces with the php interpreter without problem. “mysql” in stand alone mode is also fine.


linux-7bll:/var/log # mysql -h 'localhost' -u 'root'
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 22
Server version: 5.1.53-log SUSE MySQL RPM

No prompt for password, this is fine and as expected! By default no passwords, also not for “root”!

But I cannot get the connection from “php” to “mysql” to work!

PHP: mysql_connect - Manual

gives as example:


<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

but


<html>
 <head>
  <title>PHP-Test</title>
 </head>
 <body>
 <?php
    $link = mysql_connect('localhost', 'root', '');
    if (!$link) {die('Could not connect: ' . mysql_error());}
 ?>
 </body>
</html>

results in “HTTP 500 Internal Server Error”!

Removing the optional(?) third argument ‘’ changes nothing! Any proposal how to proceed?

stamcose wrote:
> results in “HTTP 500 Internal Server Error”!
>
> Removing the optional(?) third argument ‘’ changes nothing! Any
> proposal how to proceed?

check /var/log/apache2/errorlog to see what the server error is.

I have now set a mysql password for “root” with

mysql> set password = password(‘mittpass’)

to be able to provide a real password as third argument and to have exactly the form of the manual above

Just the same, I still get “HTTP 500 Internal Server Error”.


[Thu Dec 08 16:06:25 2011] [error] [client 192.168.0.176] PHP Fatal error:  Call to undefined function mysql_connect() in /srv/www/htdocs/show.php on line 7

Undefined function???

stamcose wrote:

>
> I have installed “php/mysql” for http server “Apache”
with “yast”.
>
> “Apache” interfaces with the php interpreter without
problem. “mysql”
> in stand alone mode is also fine.
>
>
> Code:
> --------------------
>
> linux-7bll:/var/log # mysql -h ‘localhost’ -u
‘root’
> Welcome to the MySQL monitor. Commands end with ;
or \g.
> Your MySQL connection id is 22
> Server version: 5.1.53-log SUSE MySQL RPM
>
> --------------------
>
>
> No prompt for password, this is fine and as expected!
By default no
> passwords, also not for “root”!
>
> But I cannot get the connection from “php” to “mysql”
to work!
>
> ‘PHP: mysql_connect - Manual’
> (http://php.net/manual/en/function.mysql-connect.php)
>
> gives as example:
>
> Code:
> --------------------
>
> <?php
> $link = mysql_connect(‘localhost’, ‘mysql_user’,
‘mysql_password’);
> if (!$link) {
> die('Could not connect: ’ . mysql_error());
> }
> echo ‘Connected successfully’;
> mysql_close($link);
> ?>
>
> --------------------
>
>
> but
>
>
> Code:
> --------------------
>
> <html>
> <head>
> <title>PHP-Test</title>
> </head>
> <body>
> <?php
> $link = mysql_connect(‘localhost’, ‘root’, ‘’);
> if (!$link) {die('Could not connect: ’ .
mysql_error());}
> ?>
> </body>
> </html>
>
> --------------------
>
> results in “HTTP 500 Internal Server Error”!
>
> Removing the optional(?) third argument ‘’ changes
nothing! Any
> proposal how to proceed?
>
>
$link = mysql_connect(‘localhost’, ‘root’, ‘’);
Is there a space needed between the quotes for
password?

Russ

I found (by google):

PHP: Database issues - Manual

This seems to be a SUSE mess!

This won’t actually affect that many people. Unix users, at least the ones who know what they are doing, tend to always build PHP against their system’s libmysqlclient library simply by adding the --with-mysql=/usr option when building PHP. Windows users may enable the extension php_mysql.dll inside php.ini. For more details, see the MySQL Reference for installation instructions. Also, be sure libmysql.dll is available to the systems PATH. For more details on how, read the FAQ on setting up the Windows systems PATH. Because libmysql.dll (and many other PHP related files) exist in the PHP folder, you’ll want to add the PHP folder to your systems PATH.

“the ones who know what they are doing”?

Does this mean that the build by yast is useless?

“adding the --with-mysql=/usr option when building PHP”

Why is this “–with-mysql=/usr option” not used by Yast? If this is really is not done properly by Yast there should be at least be a detailed description of what the user must do! Any serious web-server needs php/mysql as this has turned into a web standard!

Am 08.12.2011 15:46, schrieb stamcose:
>
> Undefined function???
>
Please post the output from


rpm -qa '*php5*'


PC: oS 11.4 (dual boot 12.1) 64 bit | Intel Core i7-2600@3.40GHz | KDE
4.6.0 | GeForce GT 420 | 16GB Ram
Eee PC 1201n: oS 11.4 64 bit | Intel Atom 330@1.60GHz | KDE 4.7.3 |
nVidia ION | 3GB Ram


linux-7bll:/var/log/apache2 # rpm -qa '*php5*'
php5-tokenizer-5.3.5-5.16.1.i586
php5-ctype-5.3.5-5.16.1.i586
php5-xmlreader-5.3.5-5.16.1.i586
php5-pdo-5.3.5-5.16.1.i586
php5-hash-5.3.5-5.16.1.i586
php5-iconv-5.3.5-5.16.1.i586
php5-5.3.5-5.16.1.i586
php5-dom-5.3.5-5.16.1.i586
php5-json-5.3.5-5.16.1.i586
php5-xmlwriter-5.3.5-5.16.1.i586
php5-sqlite-5.3.5-5.16.1.i586
apache2-mod_php5-5.3.5-5.16.1.i586

Am 08.12.2011 19:58, schrieb stamcose:
>
> Code:
> --------------------
>
> linux-7bll:/var/log/apache2 # rpm -qa ‘php5
> php5-tokenizer-5.3.5-5.16.1.i586
> php5-ctype-5.3.5-5.16.1.i586
> php5-xmlreader-5.3.5-5.16.1.i586
> php5-pdo-5.3.5-5.16.1.i586
> php5-hash-5.3.5-5.16.1.i586
> php5-iconv-5.3.5-5.16.1.i586
> php5-5.3.5-5.16.1.i586
> php5-dom-5.3.5-5.16.1.i586
> php5-json-5.3.5-5.16.1.i586
> php5-xmlwriter-5.3.5-5.16.1.i586
> php5-sqlite-5.3.5-5.16.1.i586
> apache2-mod_php5-5.3.5-5.16.1.i586
>
> --------------------
>
You do not have the php mysql bindings installed, install them


sudo zypper install php5-mysql


PC: oS 11.4 (dual boot 12.1) 64 bit | Intel Core i7-2600@3.40GHz | KDE
4.6.0 | GeForce GT 420 | 16GB Ram
Eee PC 1201n: oS 11.4 64 bit | Intel Atom 330@1.60GHz | KDE 4.7.3 |
nVidia ION | 3GB Ram

In fact,

sudo zypper install php5-mysql

solved the problem! Thank you!

But how come that this package was left out by Yast? As far as I understand this means that the tables of dependencies set up for Yast not are complete! I guess that it cannot be the fault of the Yast user!?!

Am 08.12.2011 22:26, schrieb stamcose:
>
> In fact,
>
> sudo zypper install php5-mysql
>
> solved the problem! Thank you!
>
> But how come that this package was left out by Yast? As far as I
> understand this means that the tables of dependencies set up for Yast
> not are complete! I guess that it cannot be the fault of the Yast
> user!?!
>
>
You did not describe what you did exactly. Why do you think there is a
broken dependency? What did you install?
Yast has no table of dependencies, the rpm packages have each a table of
dependencies. Yast is just a tool, do not mix that in your understanding.


PC: oS 11.4 (dual boot 12.1) 64 bit | Intel Core i7-2600@3.40GHz | KDE
4.6.0 | GeForce GT 420 | 16GB Ram
Eee PC 1201n: oS 11.4 64 bit | Intel Atom 330@1.60GHz | KDE 4.7.3 |
nVidia ION | 3GB Ram

There is no dependency of php or mysql on php5-mysql. There is no assumption that just because you have installed PHP and MySQL you want to use the two together. You could be say using PHP with SQLite, and MySQL with Perl.

Am 08.12.2011 23:36, schrieb ken yap
> There is no dependency of php or mysql on php5-mysql. There is no
> assumption that just because you have installed PHP and MySQL you
> want to use the two together. You could be say using PHP with SQLite,
> and MySQL with Perl.
>
+1 of course

but what I really want to know from the OP is if the
pattern lamp_server was installed since that from a logical point of
view should have this dependency by its mere definition what a lamp
stack is for


PC: oS 11.4 (dual boot 12.1) 64 bit | Intel Core i7-2600@3.40GHz | KDE
4.6.0 | GeForce GT 420 | 16GB Ram
Eee PC 1201n: oS 11.4 64 bit | Intel Atom 330@1.60GHz | KDE 4.7.3 |
nVidia ION | 3GB Ram

OK, makes sense!

But just some general remarks(questions!) about commercial large scale WEB hosting!

I have got the impression that at least the large web hosting companies do not allow general CGI with programs from the different users (Perl or other programs) running on the server. At most they allow PHP with data storage permitted only over the MYSQL utility. This then enforces a large use of precisely the PHP-MYSQL combination.

Is this impression correct?

Perl can also be used in webapps without CGI, there is a mod_perl. And of course there are other webapp languages like Python and Ruby. You should have just done it the easy way: install the LAMP pattern.