|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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:
|
|
#3
|
|||
|
|||
|
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. |
|
#4
|
|||
|
|||
|
Quote:
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. |
|
#5
|
|||
|
|||
|
Quote:
This cann't be right. Post your script again. I mean the new script that includes the error checking code. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Help my php script can't get access to MySQL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|