|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate 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
|
|||
|
|||
|
So simple but just won't work
I just can't work out why this code:
<html> <body> <?PHP $data_b = mysql_pconnect("dbs.server","root",""); mysql_select_db("databasename"); $query = "SELECT office_id, contact,site,street_add,Postal_add,city,state,pcod e,phone,fax,email,website FROM office_table WHERE site = "; $query .= $HTTP_GET_VARS['of0']; $result = mysql_query($query); $row = mysql_fetch_array($result); ?> <? PHP echo $row['contact'] ?> </body> </html> Is giving me this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /web/htdocs/notbad/docs/Eplus_Beta/NSW/stationery2.php on line 4 If you can help it will make me very happy. |
|
#2
|
|||||
|
|||||
|
RE: So simple but just won't work
That error message is telling you that your query is wrong, either improperly formated, fields dont exist, etc.
The problem with your query is that there are no quotes around what site is suppose to be equal to. I find it helpful prior to putting my queries in code, I like to run them in my mysql client first. This way I see the result set and can verify that it returns what I wanted. You can test it by doing this: mysql -u username -p dbname One wat to fix your syntax problem is to use a query like this: php Code:
Hopoe that helps. |
|
#3
|
|||
|
|||
|
RE: So simple but just won't work
it seems that "$row = mysql_fetch_array($result); " has to be used as an argument like "if ($row = mysql_fetch_array($result)) { etc."
It's the only way I can assign the values to the array. I don't know why but it works. |
|
#4
|
|||
|
|||
|
RE: So simple but just won't work
hmmm...
Very strange! I use code like this and it works fine: $query = "select sount(*) from table"; $result = mysql_query($query); $row = mysql_fetch_array($result); Wierd. |
|
#5
|
|||
|
|||
|
RE: So simple but just won't work
Let me rewrite that:
$query = "select count(*) as total from members"; $result = mysql_query($query); $row = mysql_fetch_array($result); echo "There are ".$row['total']." registered members"; Thats better. |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > So simple but just won't work |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|
|