Page 1 of 1

no results

Posted: Sun Jan 25, 2004 3:56 pm
by mattmcb
I'm getting the following error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/seekide/public_html/storegroup/sg_forum/search.php on line 23

here is my html code:

Code: Select all

<input type="radio" value="1" name="venture_id" checked>Joint Venture<br>
              <input type="radio" value="2" name="venture_id">Link Exchange<br>
              <input type="radio" value="3" name="venture_id">Customer Exchange<br>
              <input type="radio" value="4" name="venture_id">Banner Exchange<br>
              <input type="radio" value="5" name="venture_id">Advertising Exchange</td>
            <td width="50%"><input type="radio" value="6" name="venture_id">Offer to Advertise<br>
              <input type="radio" value="7" name="venture_id">Offer to Accept Ads<br>
              <input type="radio" value="8" name="venture_id">Feature / Technology / Code Exchange<br>
              <input type="radio" value="9" name="venture_id">Service / Product Exchange<br>
              <input type="radio" value="10" name="venture_id">Resource Exchange
Here is the php code:

Code: Select all

$venture_id = $_POST&#1111;'venture_id'];
//$pm_url = append_sid("privmsg.$phpEx?mode=post&" . POST_USERS_URL . "=$poster_id");

/* Let's strip some slashes in case the user entered any escaped characters. */
$venture_id = stripslashes($venture_id);

// Search Query - Display Results
echo "<table width='100%' cellpadding='2' cellspacing='1' border='0' class='forumline'><tr><td class='catLeft' height='26'><img src='templates/phpib2/images/nav.gif'><span class='genmed'><font color='white'><b>Venture Results</b></font></a></span></td></tr>";
$result = mysql_query(
	"SELECT sgforum_users.username, sgforum_users.companyname, sgforum_users.storename, sgforum_users.storewebsite, sgforum_users.storecategory, sgforum_users.orders, sgforum_users.hits, sgforum_users.customers, venture_master.venture_type, venture.products, venture.venture_desc 
	FROM sgforum_users, venture_master, venture 
	WHERE sgforum_users.user_id = venture.user_id
	AND venture.venture_id = venture_master.venture_id	
	AND venture_master.venture_id = ".$venture_id."
	ORDER BY venture.venture_date", $linkid); 
while ($row = mysql_fetch_array($result))
&#123;    
   echo "<tr> 
   <span class='genmed'> 
   <td> 
   User Name: <a href='http://www.seekideas.com/storegroup/sg_forum/privmsg.php?mode=post&u=2'>".$row&#1111;'sgforum_users.username']."</a><br>
   Company Name: ".$row&#1111;'sgforum_users.companyname']."<br> 
   Store Name: ".$row&#1111;'sgforum_users.storename']."<br> 
   Store Website: <a href='".$row&#1111;'sgforum_users.storewebsite']."' target='_blank'>".$row&#1111;'sgforum_users.storewebsite']."</a><br> 
   Store Category: ".$row&#1111;'sgforum_users.storecategory']."<br> 
   Orders per Year: ".$row&#1111;'sgforum_users.orders']."<br> 
   Hits per Month: ".$row&#1111;'sgforum_users.hits']."<br> 
   Total Customers: ".$row&#1111;'sgforum_users.customers']."<br><br> 
   Venture Type: ".$row&#1111;'venture_master.venture_type']."<br> 
   Type of Products:<br> 
   ".$row&#1111;'venture.products']."<br> 
   Venture Details:<br> 
   ".$row&#1111;'venture.venture_desc']."<br> 
   <br> 
   Click User Name to send Private Message 
   </span> 
   <img src='images/line_break.gif' width='555' height='2' align='absmiddle'><br> 
   </td> 
   </tr>";
&#125;
echo "</table>";
The page is displaying correctly but without any results. Am I passing the venture_id correctly from the form? For example, will the value I specified by passed because that is critical to the query?

Posted: Sun Jan 25, 2004 4:05 pm
by markl999
Try adding a little debugging ( viewtopic.php?t=17096 ) and let us know what happens.

Posted: Sun Jan 25, 2004 4:17 pm
by mattmcb
I think the problem may be in the syntax of this code:

Code: Select all

while ($row = mysql_fetch_array($result)) 
&#123;    
   echo "<tr> 
   <span class='genmed'> 
   <td> 
   User Name: <a href='http://www.seekideas.com/storegroup/sg_forum/privmsg.php?mode=post&u=2'>".$row&#1111;'sgforum_users.username']."</a><br> 
   Company Name: ".$row&#1111;'sgforum_users.companyname']."<br> 
   Store Name: ".$row&#1111;'sgforum_users.storename']."<br> 
   Store Website: <a href='".$row&#1111;'sgforum_users.storewebsite']."' target='_blank'>".$row&#1111;'sgforum_users.storewebsite']."</a><br> 
   Store Category: ".$row&#1111;'sgforum_users.storecategory']."<br> 
   Orders per Year: ".$row&#1111;'sgforum_users.orders']."<br> 
   Hits per Month: ".$row&#1111;'sgforum_users.hits']."<br> 
   Total Customers: ".$row&#1111;'sgforum_users.customers']."<br><br> 
   Venture Type: ".$row&#1111;'venture_master.venture_type']."<br> 
   Type of Products:<br> 
   ".$row&#1111;'venture.products']."<br> 
   Venture Details:<br> 
   ".$row&#1111;'venture.venture_desc']."<br> 
   <br> 
   Click User Name to send Private Message 
   </span> 
   <img src='images/line_break.gif' width='555' height='2' align='absmiddle'><br> 
   </td> 
   </tr>"; 
&#125;
Am I calling variables correctly in this code?

Posted: Sun Jan 25, 2004 4:21 pm
by markl999
You don't need to reference table names in the result array, so where you have, for example, $row['venture.venture_desc'], just use $row['venture_desc']

The error_reporting(E_ALL); you put at the top of the script should have given you 'Undefined Index' type warnings :p

Posted: Sun Jan 25, 2004 4:25 pm
by mattmcb
let me ask you this... is this correct syntax for getting the date and timestamp into a variable:

Code: Select all

$venture_date = getdate();

I'm working on the above and thanks for the debugging article link, it's helping me out a lot!

Posted: Sun Jan 25, 2004 4:29 pm
by markl999
Well getdate() will return an array of 'date information' as defined at http://uk.php.net/getdate
Can't say i've really ever used getdate() myself, i tend to just use time() and use date() to format the timestamp into whatever format is required.