Re: MySQL Errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Mikea.

You have to know that i am new to php, too. And i am also struggling to
understand the code. Well, i would suggest you take something
less complex to start up. But if you still want that code for the
beginning.. make sure the database xy (that part is missing in the
code) has a table ad_details and a table ad_cat_join. both also
have to contain some rows inside. otherwise $sql_countresult will be
false and you will get the errors, too.

Robert

Mikea wrote:
This is an applic that I got off the internet that I am trying to install.
An example of the code follows.

if ($action=="memberlist") {
 /* get the total number data and find out what the grand total is */
 $sql =  "select id, title, price from ad_details where member_id=" .
$_SESSION['login_id'];
 $sql .=" order by  $orderby $order LIMIT $limitvalue, $user_view_limit  ";
 $sqlcount = "select count(*) from ad_details where member_id=" .
$_SESSION['login_id'];
 } else {
 $sql =  "select a.id, a.title, a.price from ad_details a, ad_cat_join j
where j.cat_id=$current_cat_id ";
 $sql .="and a.id=j.ad_id order by $orderby $order LIMIT $limitvalue,
$user_view_limit";
 $sqlcount = "select count(*) from ad_details a, ad_cat_join j where
j.cat_id=$current_cat_id ";
 $sqlcount .=" and a.id=j.ad_id";
 }
 $sql_countresult = mysql_query($sqlcount);
 list($totalrows) = mysql_fetch_row($sql_countresult);


$res = mysql_query($sql); $num_ads = mysql_num_rows($res);

I did not code this and I'm struggling to understand the applic and PHP!  So
I'm up to my armpits in alligators! LOL

Thanks.

Mike



"Robert Schipper" <froschi82@xxxxxx> wrote in message
news:20041021124845.98628.qmail@xxxxxxxxxxxxxxx

hello mikea,

looks like there is something missing in your sourcecode, which you
should have provided. do you give any arguments to
mysql_fetch_array() ? Do you check if it is not false?

your code should look like this:

$sql = "SELECT * FROM example";
$result = mysql_query($sql,$db);

if ($result) {
 $myrow=mysql_fetch_array($result);
} else {
 echo "ERROR: SQL-query returned false!";
}

Robert

Mikea wrote:


I am getting the following errors when I execute a php script.

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL

result

resource
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL

result

resource
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
resource

What do I need to make this work? I am new to PHP. I read something

about

mysql.class.php somewhere. Do I need that somewhere? Do I put an

include

in the main script?  Where does mysql.class.php go directory-wise?

I am sure I am not giving enough information and may not be explaining

it

good enough.  My apologies.  Again, I am new at this.

I appreciate any help.  Thank you in advance.

Mike

-- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux