Page 1 of 1

output problem from mysql

Posted: Tue Jan 27, 2004 8:40 pm
by tanjafei
hi,

i can't get it the php to output the mysql data. it the database connection works - because it writes the page title, but the reast is missing...

it also gives me the errror, but i think there is something else missing in the php code:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/network/public_html/try/qtvr_stanley_englishbay.php on line 10

this is how it looks right now:
http://www.networkvancouver.com/try/qtv ... ishbay.php

here is the code:

Code: Select all

<?php
<?
@$db=mysql_connect("localhost","****","*****");
//   Set the database we are going to use
mysql_select_db("****");
//   set the select statement
$query="select name, gps1, gps2, text, entry, web from qtvr where name='English Bay'";
//   execute the query on the database and put it in the variable $result
$result=mysql_query($query);    
//   find out how many rows will be returned
$output=mysql_fetch_array($result);

$page_title = "English Bay";
require ("header.php");
require ("footer.html");
?>
<table width="36%" height="422" border="0" align="center">
  <tr>
    <td align="center">
    <object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="256"height="208" align="middle">
      <param name="SRC" value="qtvr/englishBay2.mov">
      <param name="AUTOPLAY" value="false">
      <param name="CONTROLLER" value="true">
      <embed src="qtvr/englishBay2.mov" width="256" height="208" align="middle" autoplay="false" controller="true" pluginspage="http://www.apple.com/quicktime/download/"> </embed>
    </object>     
    
     <p class="qtvrHeading"><? echo($output['name']); ?><br>
      <font color="999999" size="1">GPS: <span class="headline"><? echo($output['gps1']); ?><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<? echo($output['gps2']); ?></font></span></font></p>
      <p class="newsText"><? echo($output['text']); ?><br>
    <br>
          <br>
          <br><span class="newsText">Website: <a href="<? echo($output['web']); ?>" target="_blank" class="style"><font color="#99CC33"><? echo($output2['name']); ?></font></a></span>
          </p></td>
  </tr>
</table>
?>

Re: output problem from mysql

Posted: Tue Jan 27, 2004 9:12 pm
by m3rajk
tanjafei wrote:it also gives me the errror, but i think there is something else missing in the php code:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/network/public_html/try/qtvr_stanley_englishbay.php on line 10
this is the thing you need to be concerned with. it's why it's not working.

Code: Select all

<?php
<? #<--------------------------- this line not needed
@$db=mysql_connect("localhost","****","*****"); //   Set the database we are going to use
mysql_select_db("****");  //   set the select statement
$query="select name, gps1, gps2, text, entry, web from qtvr where name='English Bay'";  //   execute the query on the database and put it in the variable $result
$result=mysql_query($query);     //   find out how many rows will be returned
$output=mysql_fetch_array($result);  #<----- this is your problem
the problem is that you're getting an error, not what you want from the result. the best way to debug this is to change that last link to:

Code: Select all

if(!(mysql_errno($db))){ $output=mysql_fetch_array($result); }else{ echo "<p>WE HAVE AN ERROR!!!<br />$query<br />caused: ".mysql_error($db).'</p>'; }
becsue that line will go as you expect if it works or give you why it's not working so you can fix the sql issue.

-josh

btw: ntil you have it working, it's good practice to make it so that if ti works right, it does what you want, and if it goes wrong it just gives you an error at each point there can be a db issue. this will let you find and debug the sql errors much faster.