Jump to content

Hello!!! i got this mysql_fetch_object(): supplied argument is not a valid MySQL


Makis77

Recommended Posts

Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/myspace/public_html/plugins/layouts/cats.php on line 49

Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/myspace/public_html/plugins/layouts/cats.php on line 64

 

here is the code, in bold letters its the lines 49 and 64


<table width="100%" border="0" cellspacing="0" cellpadding="3">

<tr>

<td><form action="" method="get">

<select name="menu1" onChange="MM_jumpMenu('parent',this,0)">

<option value="">Select Layout Type</option>

<?

$fetch = mysql_query("SELECT * FROM layout_cats");

while( $row = mysql_fetch_object($fetch) ){

?>

<option value="<? echo ("$url"); ?>index.php?app=layouts&action=cats&id=<?=$row->id?>"><?=$row->name?></option>

<?

}

?>

  </select>

</form></td>

  </tr>

</table>   

<?

$fetch = mysql_query("SELECT * FROM layout_cats WHERE id=$id ORDER BY id DESC");

$cat = mysql_fetch_object($fetch);

$seo_title = $sitename." - ".$cat->name." Layouts";

?>             

<h1><?=$cat->name?> Layouts</h1>

<?

$fetch2 = mysql_query("SELECT * FROM layouts WHERE cat_id=$id AND published='1' ORDER BY id DESC");

while( $row = mysql_fetch_object($fetch2) ){

?> 


 

 

if i put instead of: $id directly the category i need, lets say '1' then it works fine. Only this is a drop down menu from which the user select the category he want to see the result, so if i put '1' then he will always see the category with id=1

 

any help we ll be appreciated!

 

thanx a lot in advance!

 

 

Link to comment
Share on other sites

Your query is failing. Change this:

$fetch = mysql_query("SELECT * FROM layout_cats WHERE id=$id ORDER BY id DESC");

 

to:

$fetch = @mysql_query("SELECT * FROM layout_cats WHERE id=$id ORDER BY id DESC") or die(mysql_error());

to see what the error is.

Link to comment
Share on other sites

thanx,

i got the following:

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY id DESC' at line 1

 

mysql ver: 4.1.22-standard

php ver:    4.4.3

 

i tried to remove the order by but still i get the same error

Link to comment
Share on other sites

<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td><form action="" method="get">
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
<option value="">Select Layout Type</option>
<?
$fetch = mysql_query("SELECT * FROM layout_cats");
while( $row = mysql_fetch_object($fetch) ){
?>
<option value="<? echo ("$url"); ?>index.php?app=layouts&action=cats&id=<?=$row->id?>"><?=$row->name?></option>
<?
}
?>
  </select>
</form></td>
  </tr>
</table>    
<?
if (isset($id))
   echo "ID is: " . $id  . "<br>";
else
   echo "ID is empty!<br>";
$fetch = mysql_query("SELECT * FROM layout_cats WHERE id=$id ORDER BY id DESC");

$cat = mysql_fetch_object($fetch);
$seo_title = $sitename." - ".$cat->name." Layouts";
?>              
<h1><?=$cat->name?> Layouts</h1>
<?
$fetch2 = mysql_query("SELECT * FROM layouts WHERE cat_id=$id AND published='1' ORDER BY id DESC");
while( $row = mysql_fetch_object($fetch2) ){
?>  

That should either show the value for id or say it is empty.

Link to comment
Share on other sites

i get the following:

 

ID is empty!

 

...

 

maybe that means that the code is not correctly configured since i have the tables with the id's installed,

maybe the drop down menu doesnt work correctly???

 

visit:

 

http://www.myspacerequest.com

 

and select from top menu the 'Layouts' option.

Then select from the box the layout category u want to see and u will get the message.

 

Keep in mind that the sql table from cats has id's inside...

Link to comment
Share on other sites

so now i change

 

$fetch = mysql_query("SELECT * FROM layout_cats WHERE id=$id ORDER BY id DESC");

 

to

 

$fetch = mysql_query("SELECT * FROM layout_cats WHERE id=$_GET['id'] ORDER BY id DESC");

 

and

 

$fetch2 = mysql_query("SELECT * FROM layouts WHERE cat_id=$id AND published='1' ORDER BY id DESC");

 

to

 

$fetch2 = mysql_query("SELECT * FROM layouts WHERE cat_id=$_GET['id'] AND published='1' ORDER BY id DESC");

 

urli is like:

 

http://www.myspacerequest.com/index.php?app=layouts&action=cats&id=1

Link to comment
Share on other sites

its get alright,

i just did that and i got the following:

 

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/mysite/public_html/plugins/layouts/cats.php on line 44

 

where lne 44 has:

 

$fetch = mysql_query("SELECT * FROM layout_cats WHERE id=$_POST['id'] ORDER BY id DESC");

 

it seems he cant understand this change.

 

 

ps: Thanx a lot :)

Link to comment
Share on other sites

hahhahahaha

 

well i m not geek, yet :P

 

i replaced with

$sql = "SELECT * FROM layout_cats WHERE id=".$_POST['id']." ORDER BY id DESC";
$fetch = mysql_query($sql) OR die(mysql_error().' Query: '.$sql);

 

and now i get:

 

ID is empty!

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY id DESC' at line 1 Query: SELECT * FROM layout_cats WHERE id= ORDER BY id DESC

Link to comment
Share on other sites

jesirose, as i wrote before i m a completely newbie.

I only have some swl and oracle serious backround.

 

i replaced _POST with _GET

and i got results but stil i get some malfunction

see this:

 

http://www.myspacerequest.com/index.php?app=layouts&action=cats&id=20

Link to comment
Share on other sites

Try:

 




<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td><form action="" method="get">
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
<option value="">Select Layout Type</option>
<?php
$fetch = mysql_query("SELECT * FROM layout_cats");
while( $row = mysql_fetch_array($fetch) ){
?>
<option value="<? echo ("$url"); ?>index.php?app=layouts&action=cats&id=<?=$row->id?>"><?=$row->name?></option>
<?php
}
?>
  </select>
</form></td>
  </tr>
</table>    
<?php
$fetch = mysql_query("SELECT * FROM layout_cats WHERE id=$id ORDER BY id DESC");

$cat = mysql_fetch_array($fetch);
$seo_title = $sitename." - ".$cat->name." Layouts";
?>              
<h1><?=$cat->name?> Layouts</h1>
<?php
$fetch2 = mysql_query("SELECT * FROM layouts WHERE cat_id=$id AND published='1' ORDER BY id DESC");
while( $row = mysql_fetch_array($fetch2) ){
?>  








Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.