Jump to content


Photo

MySQL Errors HELP PLEASE!


  • Please log in to reply
11 replies to this topic

#1 Synitex

Synitex
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 12 July 2006 - 09:15 PM

Hey, im writing a gallery/comments etc script, and i keep getting this error :
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/prodream/public_html/prom/gallery.php on line 33


Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/prodream/public_html/prom/gallery.php on line 41


Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/prodream/public_html/prom/gallery.php on line 49


Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/prodream/public_html/prom/gallery.php on line 57


Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/prodream/public_html/prom/gallery.php on line 65


Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/prodream/public_html/prom/gallery.php on line 73


Heres the code:
<?php
session_start();
$conn = mysql_connect("localhost","####","####");
$db = mysql_select_db("####");
?>
<html>
<head>
<title>Habbo Alterations - Habbo's No.1 Gallery.</title>
<STYLE TYPE="text/css">
A:link {text-decoration:none; color:#334016;}
A:visited {text-decoration:none; color:#334016;}
A:hover {text-decoration:none; color:#A3B975;}
</style>
</head>
<body bgcolor=#A3B975>
<table cellspacing=0 cellpadding=0 align=center width=100%>
<tr><td><?php include("nav.php"); ?></TD></tr>
</table>
<font color=3D4E17 face=verdana size=1>
<?php
if(!isset($page)){
$page = 1;
}
$maxresults = 36;
$rowresults = 6;
$from = (($page * $maxresults) - $maxresults);
$sql = MYSQL_QUERY("SELECT id, image, comment, title, name FROM images WHERE active='1' ORDER BY date DESC LIMIT $from, $rowresults");

print("<br><table cellpadding=1 bgcolor=819556 style='border-width: 1px; border-style: ridge; border-color: #3D4E17' width=100% align=center>");

print("<tr>");
print("<td colspan=5><center><font color=3D4E17 face=verdana size=1><strong>Click on an image to comment on it.</TD></TR><TR>");
while($rows=mysql_fetch_array($sql)){
print("<TD width=20% align=center><center><font color=3D4E17 face=verdana size=1><a href=viewpic.php?id=$rows[id]><img border=0width='100' height='100'  src=gallerythumbs/$rows[image]></a><br><strong>$rows[name]</strong><br><u><a href=viewpic.php?id=$rows[id]>$rows[title]</A></u><br>$rows[comment]</TD>");
}
print("</tr>");

print("<tr>");
$from = $from + 5;
$sql2 = MYSQL_QUERY("SELECT id, image, comment, title, name FROM images WHERE active='1' ORDER BY date DESC LIMIT $from, $rowresults");
while($rows2=mysql_fetch_array($sql2)){
print("<TD width=20% align=center><center><font color=3D4E17 face=verdana size=1><a href=viewpic.php?id=$rows2[id]><img border=0width='100' height='100'  src=gallerythumbs/$rows2[image]></a><br><strong>$rows2[name]</strong><br><u><a href=viewpic.php?id=$rows2[id]>$rows2[title]</a></u><br>$rows2[comment]</TD>");
}
print("</tr>");

print("<tr>");
$from = $from +5;
$sql3 = MYSQL_QUERY("SELECT id, image, comment, title, name FROM images WHERE active='1' ORDER BY date DESC LIMIT $from, $rowresults");
while($rows3=mysql_fetch_array($sql3)){
print("<TD width=20% align=center><center><font color=3D4E17 face=verdana size=1><a href=viewpic.php?id=$rows3[id]><img border=0width='100' height='100'  src=gallerythumbs/$rows3[image]></a><br><strong>$rows3[name]</strong><br><u><a href=viewpic.php?id=$rows3[id]>$rows3[title]</a></u><br>$rows3[comment]</TD>");
}
print("</tr>");

print("<tr>");
$from = $from + 5;
$sql4 = MYSQL_QUERY("SELECT id, image, comment, title, name FROM images WHERE active='1' ORDER BY date DESC LIMIT $from, $rowresults");
while($rows4=mysql_fetch_array($sql4)){
print("<TD width=20% align=center><center><font color=3D4E17 face=verdana size=1><a href=viewpic.php?id=$rows4[id]><img border=0width='100' height='100'  src=gallerythumbs/$rows4[image]></A><br><strong>$rows4[name]</strong><br><u><a href=viewpic.php?id=$rows4[id]>$rows4[title]</a></u><br>$rows4[comment]</TD>");
}
print("</tr>");

print("<tr>");
$from = $from + 5;
$sql2 = MYSQL_QUERY("SELECT id, image, comment, title, name FROM images WHERE active='1' ORDER BY date DESC LIMIT $from, $rowresults");
while($rows2=mysql_fetch_array($sql2)){
print("<TD width=20% align=center><center><font color=3D4E17 face=verdana size=1><a href=viewpic.php?id=$rows2[id]><img border=0width='100' height='100'  src=gallerythumbs/$rows2[image]></a><br><strong>$rows2[name]</strong><br><u><a href=viewpic.php?id=$rows2[id]>$rows2[title]</a></u><br>$rows2[comment]</TD>");
}
print("</tr>");

print("<tr>");
$from = $from + 5;
$sql2 = MYSQL_QUERY("SELECT id, image, comment, title, name FROM images WHERE active='1' ORDER BY date DESC LIMIT $from, $rowresults");
while($rows2=mysql_fetch_array($sql2)){
print("<TD width=20% align=center><center><font color=3D4E17 face=verdana size=1><a href=viewpic.php?id=$rows2[id]><img border=0width='100' height='100'  src=gallerythumbs/$rows2[image]></a><br><strong>$rows2[name]</strong><br><u><a href=viewpic.php?id=$rows2[id]>$rows2[title]</a></u><br>$rows2[comment]</TD>");
}
print("</tr>");

print("<TR><TD colspan=5 align=center><font color=3D4E17 face=verdana size=1><strong>Select a page<BR>");

$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM images WHERE active='1'"),0);

$total_pages = ceil($total_results / $maxresults);
if($page > 1){
    $prev = ($page - 1);
    print("<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><< Previous</a>&nbsp;");
}

for($i = 1; $i <= $total_pages; $i++){
    if(($page) == $i){
        echo "$i&nbsp;";
        } else {
            print("<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a>&nbsp;");
    }
}

// Build Next Link
if($page < $total_pages){
    $next = ($page + 1);
    print("<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next >></a>");
}
print("</TD></TR>");
?>
</table>
</body>
</html> 

Can someone help me?

Thanks!

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 12 July 2006 - 09:21 PM

An error like that means that your previous mysql_query did not work correctly.

Change your mysql_query() calls to be similar to this:
<?php
$q = "SELECT id, image, comment, title, name FROM images WHERE active='1' ORDER BY date DESC LIMIT $from, $rowresults";
$sql = MYSQL_QUERY($q) or die("Problem with the query: $q<br>" . mysql_error());
?>

Also, please edit your post to change the [quote] tag to a [code] tag and the [/quote] tag to a [/code] tag.

Ken

#3 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 12 July 2006 - 09:22 PM

What the hell dude, you shouldn't put your username and password down like that, XXXX or #### them out, no matter what you do now, chances are someone is going to get into your db, unless you made up a random username and password for that, that is something you will probably regret.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#4 Synitex

Synitex
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 12 July 2006 - 09:48 PM

Okay.. done what you said.. i now get this www.prodreaming.co.uk/prom/gallery.php

I dont know what to do.

Help please.

#5 GingerRobot

GingerRobot
  • Staff Alumni
  • Advanced Member
  • 4,086 posts
  • LocationUK

Posted 12 July 2006 - 09:55 PM

Are you sure you've selected the right table? It says the table "images" doesn't exist.

#6 Synitex

Synitex
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 12 July 2006 - 10:11 PM

Ahh Im kinda retarded at this lol.. Could you do it for me?  im still learning PHP :(

#7 GingerRobot

GingerRobot
  • Staff Alumni
  • Advanced Member
  • 4,086 posts
  • LocationUK

Posted 12 July 2006 - 10:15 PM

Its not something i can do for you.

Did you create the database with the table in? If so how did you create it, did you use phpMyAdmin?

#8 Synitex

Synitex
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 12 July 2006 - 10:57 PM

Actually, the script was sent to me, so i have no idea what the tables are.. the tables i have found that need creating so far are images and users thats the names of the tables..

#9 GingerRobot

GingerRobot
  • Staff Alumni
  • Advanced Member
  • 4,086 posts
  • LocationUK

Posted 13 July 2006 - 09:03 AM

Well you will have to create the tables to be able to use the script, do you have access to phpMyAdmin?

#10 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 13 July 2006 - 09:05 AM

ask the person that sent u it, to send the table info to create the tables

#11 Synitex

Synitex
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 13 July 2006 - 09:06 AM

Yeah i got access to PHPMyAdmin

#12 GingerRobot

GingerRobot
  • Staff Alumni
  • Advanced Member
  • 4,086 posts
  • LocationUK

Posted 13 July 2006 - 09:45 AM

Do you know how to use it? You will need to log into it and create the tables. You may well have problems for a while though because you do not know all the fields and types the script requires. Brown2005 is right, your best bet would be to contact the person who gave you the script.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users