|
-
May 23rd, 2005, 10:25 AM
#1
Thread Starter
Addicted Member
What am I doing wrong? [RESOLVED]
Why am I getting the error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/content/b/i/k/mydirectory/html/ax0!calRe367/view.php on line 13
but it still shows me the data underneath it
VB Code:
<?php
include("cn.php");
include("commonview.php");
checklogin();
$sql = "SELECT * FROM calendar";
$calendar = mysql_query($sql) or die(mysql_error());
echo '<table>
<tr>';
while ($calendar = mysql_fetch_array($calendar)) {
if ($i == 2) {
echo '</tr><tr>';
$i = 0;
}
echo '<td><b>' . $calendar['dept'] . '</b><br>';
echo $calendar['mon'] . '<br>';
echo $calendar['tues'] . '<br>';
echo $calendar['wed'] . '<br>';
echo $calendar['thurs'] . '<br>';
echo $calendar['fri'] . '<br>';
echo $calendar['sat'] . '<br>';
echo $calendar['sun'] . '<br><br></td>';
$i++;
}
echo '</tr></table><br>';
?>
Last edited by espylacopa; May 24th, 2005 at 04:51 PM.
Things fall apart which the center cannot hold...
-
May 24th, 2005, 08:37 AM
#2
Fanatic Member
Re: What am I doing wrong?
I've had this before when the SQL statement was incorrect (i.e. DELEE instead of DELETE).
Possibly, is it because your database doesn't have a table called 'calendar', that's the only thing i can think of. That errors usually tends to mean incorrect sql statement.
sql_lall 
-
May 24th, 2005, 10:04 AM
#3
Fanatic Member
Re: What am I doing wrong?
well, correct my if i am wrong, but shouldnt
PHP Code:
while ($calendar = mysql_fetch_array($calendar)) {
be:
PHP Code:
while ($calendar == mysql_fetch_array($calendar)) {
???
-
May 24th, 2005, 03:41 PM
#4
Re: What am I doing wrong?
$calendar first stores a reference to the result of the query. The statement $calendar = mysql_fetch_array($calendar) overwrites this reference. Hence, the next time it loops, it fails because $calendar no longer contains a reference to the result of the query, it contains an array.
To solve this change the name of the variable. I.e:
PHP Code:
$result= mysql_query($sql) or die(mysql_error());
/* other code */
while ($calendar= mysql_fetch_array($result)) {
-
May 24th, 2005, 04:51 PM
#5
Thread Starter
Addicted Member
Re: What am I doing wrong?
thanks visual ad. I am used to asp, but the server doesnt support it. It worked great.
Things fall apart which the center cannot hold...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|