User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 426,891 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,347 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser: Programming Forums
Views: 725 | Replies: 7
Reply
Join Date: Feb 2008
Posts: 4
Reputation: prashish_raj is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
prashish_raj prashish_raj is offline Offline
Newbie Poster

Help plz help me..mysql_fetch_array() problem

  #1  
Feb 15th, 2008
i have been getting this problem n this is getting into my nerves..
it works fine on the web.. but i need to present it on the intranet tomorrow "sunday"
it gives this damn error. of mysql_fetch_array..
can u plz help me

CODE:
<div id="right_nav">

<div id="cga_events">
<div id="navtop" align="center">
<div id="navtop_left">
</div><div id="navtop_right">
</div>
<div id="navtop_text">CGA Events</div>
</div>
<div id="pageNav">
<div id="sectionLinks">';

include("connect1.php");
$table = events;
$query = "SELECT id, topic, event, date
FROM events ORDER BY 'id' DESC LIMIT 5";

$result=mysql_query($query);
//LINE 140 while (list($id, $topic, $event, $date) =mysql_fetch_array($result))
{
echo" <font color=\"#006600\">&nbsp;On ".substr($date,0,10)."</font>
<a href=\"$self?page=showevents&id=$id &topic=$topic \" class=\"elibtopic\">$topic</a>
";
}


echo'</div>
</div>';

warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\phpdev5\www\intranet cga\sept 25th 2007\myclub\index.php on line 140
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: plz help me..mysql_fetch_array() problem

  #2  
Feb 16th, 2008
$query = "SELECT id, topic, event, date
FROM events ORDER BY 'id' DESC LIMIT 5";

Should be
  1. $query = "SELECT id, topic, event, date
  2. FROM events ORDER BY id DESC LIMIT 5";

Cheers,
Naveen
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Feb 2008
Posts: 4
Reputation: prashish_raj is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
prashish_raj prashish_raj is offline Offline
Newbie Poster

Re: plz help me..mysql_fetch_array() problem

  #3  
Feb 16th, 2008
it still shows the ame error..
?????
Reply With Quote  
Join Date: Feb 2008
Posts: 4
Reputation: prashish_raj is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
prashish_raj prashish_raj is offline Offline
Newbie Poster

Re: plz help me..mysql_fetch_array() problem

  #4  
Feb 16th, 2008
im really getting annoyed by this bug...
can anyone help
Reply With Quote  
Join Date: Feb 2008
Posts: 4
Reputation: prashish_raj is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
prashish_raj prashish_raj is offline Offline
Newbie Poster

Re: plz help me..mysql_fetch_array() problem

  #5  
Feb 16th, 2008
when i placed the mysql_error() then it showed

Parse error: parse error, unexpected T_WHILE, expecting ',' or ';' in c:\phpdev5\www\intranet cga\sept 25th 2007\myclub\index.php on line 140
Reply With Quote  
Join Date: Dec 2004
Location: UAE
Posts: 406
Reputation: Sulley's Boo will become famous soon enough Sulley's Boo will become famous soon enough 
Rep Power: 5
Solved Threads: 9
Sulley's Boo's Avatar
Sulley's Boo Sulley's Boo is offline Offline
Posting Pro in Training

Question Re: plz help me..mysql_fetch_array() problem

  #6  
Feb 16th, 2008
include("connect1.php");
$table = events;
$query = "SELECT id, topic, event, dateFROM events ORDER BY id DESC LIMIT 5";

$result=mysql_query($query);
//LINE 140 while (list($id, $topic, $event, $date) =mysql_fetch_array($result))
{
echo" <font color=\"#006600\">&nbsp;On ".substr($date,0,10)."</font>
<a href=\"$self?page=showevents&id=$id &topic=$topic \" class=\"elibtopic\">$topic</a>
";
}

Why do you need the stuff in red?
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: plz help me..mysql_fetch_array() problem

  #7  
Feb 17th, 2008
when i placed the mysql_error() then it showed
No. mysql_error() shows mysql related error. Can you post your full code ? May be you have a misplaced } .
And instead of
while (list($id, $topic, $event, $date) =mysql_fetch_array($result))
try this
  1. while($row=mysql_fetch_array($result)){ $id=$row['id'];
  2. $topic=$row['topic'];
  3. $event=$row['event'];
  4. $date=$row['date'];
  5. ...
I am not sure if this ll work. If it doesn't, then please post your code.
Last edited by nav33n : Feb 17th, 2008 at 12:46 pm.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: plz help me..mysql_fetch_array() problem

  #8  
Feb 17th, 2008
Originally Posted by Sulley's Boo View Post
Why do you need the stuff in red?


In php, if we want to echo something, its done like this. echo "Welcome...";
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MySQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MySQL Forum

All times are GMT -4. The time now is 10:46 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC