Apache Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationApache Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old October 4th, 2001, 04:07 AM
vu3prx vu3prx is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: /home
Posts: 10 vu3prx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Talking MySQL and PHP

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.

Reply With Quote
  #2  
Old October 4th, 2001, 04:41 AM
pippo's Avatar
pippo pippo is offline
A PAtCHy sErver
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Italy
Posts: 410 pippo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Instead of:
PHP Code:
 $db mysql_select_db("test","$cnx") or die("Unable to Select"); 


use:
PHP Code:
 $db mysql_select_db("test",$cnx) or die("Unable to Select"); 


Quote:
Is it problem with PHP or MySQL

not Apache.

hope helps,ciao.

Reply With Quote
  #3  
Old October 4th, 2001, 05:12 AM
code grunt code grunt is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2001
Location: Frankfurt, Germany
Posts: 11 code grunt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #4  
Old October 6th, 2001, 05:47 AM
vu3prx vu3prx is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: /home
Posts: 10 vu3prx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > MySQL and PHP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway