|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Help with MySQL connect
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 |
|
#2
|
|||
|
|||
|
The variables "fieldname" and "fieldvalue" are spelled differently when you try to echo them.
|
|
#3
|
||||
|
||||
|
You might want to use foreach ($record as $fieldname => $fieldvalue) instead of that inner while loop... it makes the code look more elite =)
Also, i'm being picky, but you set the $query variable and still hardcoded the sql in the function... perhaps this was just you testing your error though =) |
|
#4
|
||||
|
||||
|
Also, this thread would be better placed in the PHP section.
|
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > Help with MySQL connect |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|