PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 7th, 2004, 07:17 AM
BJICe BJICe is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 3 BJICe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Help my php script can't get access to MySQL

My php script can't get access to MySQL tables
here is my php script:
<?
$db = mysql_connect("localhost","fred","abc123");
mysql_select_db("bjice",$db);
$query = "SELECT * FROM first";
$result = mysql_query("SELECT * FROM first");
echo $result;
while($record=mysql_fetch_assoc($result)){
while(list ($filedname,$fieldvalue) = each ($record)){
echo $fieldname.": ".$dieldvalue."<BR>";
}
echo "<BR>";
}
?>
and the result of it in browser is nothing
is there something that I've to do

Reply With Quote
  #2  
Old November 8th, 2004, 01:42 AM
Viper_SB's Avatar
Viper_SB Viper_SB is offline
Moderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Canada
Posts: 331 Viper_SB User rank is Private First Class (20 - 50 Reputation Level)Viper_SB User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 4 h 53 m 7 sec
Reputation Power: 6
read the PHP manual on mysql

ALWAYS use error handling no matter how small the script.
try this way it'll tell you if there is an error with your query.
PHP Code:
 $result mysql_query("SELECT * FROM first") or die('Invalid query: '.mysql_error()); 

Reply With Quote
  #3  
Old November 8th, 2004, 09:26 AM
BJICe BJICe is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 3 BJICe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thank you

Here is what $result return

Invalid query: Access denied for user: 'root@localhost' (Using password: NO)
what I have to know to fix that.

Reply With Quote
  #4  
Old November 8th, 2004, 11:22 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
Quote:
Originally Posted by BJICe
Here is what $result return

Invalid query: Access denied for user: 'root@localhost' (Using password: NO)
what I have to know to fix that.

I'm not sure how you were denied access using root@localhost when your connection string shows:

$db = mysql_connect("localhost","fred","abc123");

Are you sure your script isn't trying to connect to Mysql from somewhere else (maybe above this or a file that includes this one)?

Also, are you sure fred is a user with password abc123 and does he have localhost access granted?
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #5  
Old November 9th, 2004, 07:06 PM
daidalus13 daidalus13 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 16 daidalus13 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 12 m 51 sec
Reputation Power: 0
Quote:
Originally Posted by BJICe
Here is what $result return

Invalid query: Access denied for user: 'root@localhost' (Using password: NO)
what I have to know to fix that.

This cann't be right. Post your script again. I mean the new script that includes the error checking code.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Help my php script can't get access to MySQL


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 2 hosted by Hostway
Stay green...Green IT