|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
I have installed Red Hat Linux 7.1. By default it have Apache, PHP and MySQL. All are installed from rpm files. But i can't select mysql database.
$cnx = mysql_connect("localhost","root","rootpaswd") or die("Unable to connect to database"); This executes fine, i can connect to MySQL. I tryed wrong password and it won't connect. $db = mysql_select_db("test",$cnx) or die("Unable to select DB"); This fails with following error <br> <b>Warning</b>: Supplied argument is not a valid MySQL-Link resource in <b>/var/www/html/test.php</b> on line <b>4</b><br> Unable to Select the source code for test.php is __________________________________________ <?php $cnx = mysql_connect("localhost","root","rotpaswd") or die ("unable to connect"); $db = mysql_select_db("test","$cnx") or die("Unable to Select"); echo "ok"; ?> __________________________________________ Following packages are installed on my system. [root@localhost /root]# rpm -qa | grep mysql mysql-server-3.23.36-1 mysql-devel-3.23.36-1 mysqlclient9-3.23.22-4 mysql-3.23.36-1 php-mysql-4.0.4pl1-9 [root@localhost /root]# rpm -qa | grep php php-ldap-4.0.4pl1-9 php-imap-4.0.4pl1-9 php-manual-4.0.4pl1-9 php-pgsql-4.0.4pl1-9 php-4.0.4pl1-9 php-mysql-4.0.4pl1-9 php-devel-4.0.4pl1-9 mysql.so is available in following locations. /usr/lib/php4/ /usr/lib/perl5/ My phpinfo() is available at http://www.space4host.com/phpinfo.html Is it problem with PHP or MySQL. Please help. |
|
#2
|
||||
|
||||
|
Instead of:
PHP Code:
use: PHP Code:
Quote:
not Apache. hope helps,ciao. |
|
#3
|
|||
|
|||
|
The PHP4 difference
Hi vu3prx,
I had the same problem after updating from PHP3 to PHP4. The reason is this: PHP3 returns a number after mysql_connect(), PHP4 returns a string in the form "Ressource ID#1", which is a killer, while at the same time expecting you to provide a number in all other commands. The solution: 1. Be careful when using persistent connections - this needs to be urlencoded when handed over via the URL 2. Instead of $db = mysql_select_db("test",$cnx) use $db = mysql_select_db("test") when using only one connection (same with all other commands). If you need to use more than one connection, extract the numberfrom the string. |
|
#4
|
|||
|
|||
|
Solved the pblm
Hi,
Thanks for all for help. I solved the pblm. Still i don't know what the problem. Anyway thanks for all for help Regds, Boby |
![]() |
| Viewing: Dev Shed Forums > System Administration > Apache Development > MySQL and PHP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|