Jump to content

help with error please


justAnoob

Recommended Posts

Just posting up the important sutff

I have one div which shows a full size image. And smaller divs which show the thumbnail. on mouseover of the thumbs, the full size is displayed in the bigger div    .    $row['imgpath'] should always show in the bigger div until mouseover of the other thumbs.

 

<?php
$sql = mysql_query("SELECT imgpath, imgpath2, imgpath3, imgpath4, imgpath5, thumb_1, thumb_2, thumb_3, thumb_4, thumb_5 FROM member_pictures WHERE thumb_1 = " . $_SESSION['picposted'] . "");
$result=mysql_query($sql);
?>

 

script language="JavaScript">
<!--
//thumbnail script
image0 =new Image();
image1 =new Image();
image2 =new Image();
image3 =new Image();
image4 =new Image();
// This defines the source of the display image 
image0.src ="<?php echo $row['imgpath']; ?>"
image1.src ="<?php echo $row['imgpath2']; ?>"
image2.src ="<?php echo $row['imgpath3']; ?>"
image3.src ="<?php echo $row['imgpath4']; ?>"
image4.src ="<?php echo $row['imgpath5']; ?>"
// This defines the source of the preview image 
document.images['pimage0'].src=image0.src;
document.images['pimage1'].src=image1.src;
document.images['pimage2'].src=image2.src;
document.images['pimage3'].src=image3.src;
document.images['pimage4'].src=image4.src;
// This defines what to do when an image is clicked on 
function image_click(clicks)
{
if(clicks==0){document.images['large'].src=image0.src;}
if(clicks==1){document.images['large'].src=image1.src;}
if(clicks==2){document.images['large'].src=image2.src;}
if(clicks==3){document.images['large'].src=image3.src;}
if(clicks==4){document.images['large'].src=image4.src;}
}
// --></script>  

 

<div align="center"><img src="<?php echo "$row['imgpath']"; ?>" align="middle" border="0" width="380 height="225" name="large"></div>
<div align="center">
     <a onmouseover="javascript:image_click(0)"><img src="<?php echo "$row['thumb_1']"; ?>"  width="90" height="80" name="pimage0" border=0></a>
    </div>
   </td>
  <td bordercolor="#FFFFFF">
   <div align="center">
    <a onmouseover="javascript:image_click(1)"><img src="<?php echo "$row['thumb_2']"; ?>"  width="90" height="80" name="pimage1" border=0></a>
   </div>
.....................and so on

i think in this one

u have an error

<div align="center"><img src="<?php echo "$row['imgpath']"; ?>" align="middle" border="0" width="380 height="225" name="large"></div>
<div align="center">
     <a onmouseover="javascript:image_click(0)"><img src="<?php echo "$row['thumb_1']"; ?>"  width="90" height="80" name="pimage0" border=0></a>
    </div>
   </td>
  <td bordercolor="#FFFFFF">
   <div align="center">
    <a onmouseover="javascript:image_click(1)"><img src="<?php echo "$row['thumb_2']"; ?>"  width="90" height="80" name="pimage1" border=0></a>
   </div>
.....................and so on

 

remove the "" after echo..

 

like this

<div align="center"><img src="<?php echo $row['imgpath']; ?>" align="middle" border="0" width="380 height="225" name="large"></div>
<div align="center">
     <a onmouseover="javascript:image_click(0)"><img src="<?php echo $row['thumb_1']; ?>"  width="90" height="80" name="pimage0" border=0></a>
    </div>
   </td>
  <td bordercolor="#FFFFFF">
   <div align="center">
    <a onmouseover="javascript:image_click(1)"><img src="<?php echo $row['thumb_2']; ?>"  width="90" height="80" name="pimage1" border=0></a>
   </div>
.....................and so on

Here is the all the code. I just left out the CSS

 

<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
session_start();
include_once 'header.php';
include "connection.php";
$sql = mysql_query("SELECT imgpath, imgpath2, imgpath3, imgpath4, imgpath5, thumb_1, thumb_2, thumb_3, thumb_4, thumb_5,FROM member_pictures WHERE thumb_1 = " . $_SESSION['picposted'] . "");
$result=mysql_query($sql);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>

<script language="JavaScript">
<!--
//thumbnail script
image0 =new Image();
image1 =new Image();
image2 =new Image();
image3 =new Image();
image4 =new Image();
// This defines the source of the display image 
image0.src ="<?php echo $row['imgpath']; ?>"
image1.src ="<?php echo $row['imgpath2']; ?>"
image2.src ="<?php echo $row['imgpath3']; ?>"
image3.src ="<?php echo $row['imgpath4']; ?>"
image4.src ="<?php echo $row['imgpath5']; ?>"
// This defines the source of the preview image 
document.images['pimage0'].src=image0.src;
document.images['pimage1'].src=image1.src;
document.images['pimage2'].src=image2.src;
document.images['pimage3'].src=image3.src;
document.images['pimage4'].src=image4.src;
// This defines what to do when an image is clicked on 
function image_click(clicks)
{
if(clicks==0){document.images['large'].src=image0.src;}
if(clicks==1){document.images['large'].src=image1.src;}
if(clicks==2){document.images['large'].src=image2.src;}
if(clicks==3){document.images['large'].src=image3.src;}
if(clicks==4){document.images['large'].src=image4.src;}
}
// --></script>  
</head>

<body>
<table width="954" border="0" align="center">
<tr>
  <td height="702">
   <div id="PictureBox">
    <div id="divvy">
     <span class="bigger">
        Your picture has been posted -     </span>
     <span class="different">Picture Preview<span class="goto_around"> (goto </span></span><span class="style1"><span class="style3"><a href="http://www.mysite.com/example.php" class="goto">Active Pictures</a></span></span><span class="different"><span class="goto_around"> to add pictures)</span></span><br />
     <div id="postnew">
      <table width="705" bordercolor="#000000" bgcolor="#9AA4AD" id="table">
        <tr>
          <td>
          <table width="400" border="1" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td colspan="4"><div align="center"><img src="<?php echo "$row['imgpath']"; ?>" align="middle" border="0" width="380 height="225" name="large"></div></td>
  </tr>
  <tr> 
    <td colspan="4">
    <div align="center">
     Mouse over thumbnails to view larger image.
    </div>
    </td>
  </tr>
  <tr>
   <td bordercolor="#FFFFFF">
    <div align="center">
     <a onmouseover="javascript:image_click(0)"><img src="<?php echo "$row['thumb_1']"; ?>"  width="90" height="80" name="pimage0" border=0></a>
    </div>
   </td>
  <td bordercolor="#FFFFFF">
   <div align="center">
    <a onmouseover="javascript:image_click(1)"><img src="<?php echo "$row['thumb_2']"; ?>"  width="90" height="80" name="pimage1" border=0></a>
   </div>
  </td>
  <td bordercolor="#FFFFFF">
   <div align="center">
    <a onmouseover="javascript:image_click(2)"><img src="<?php echo "$row['thumb_3']"; ?>"  width="90" height="80" name="pimage2" border=0></a>
   </div>
  </td>
  <td bordercolor="#FFFFFF">
   <div align="center">
    <a onmouseover="javascript:image_click(3)"><img src="<?php echo "$row['thumb_4']"; ?>"  width="90" height="80" name="pimage3" border=0></a>
   </div>
  </td>
  <td bordercolor="#FFFFFF">
   <div align="center">
    <a onmouseover="javascript:image_click(4)"><img src="<?php echo "$row['thumb_5']"; ?>"  width="90" height="80" name="pimage4" border=0></a>
   </div>
  </td>
</tr>
</table> 
          
          
	  		  
           
          </td>
        </tr>
      </table>
     </div>
    </div>
   </div>  </td>
</tr>
</table>


</body>
</html>

change this

<td bordercolor="#FFFFFF">
   <div align="center">
    <a onmouseover="javascript:image_click(1)"><img src="<?php echo "$row['thumb_2']"; ?>"  width="90" height="80" name="pimage1" border=0></a>
   </div>
  </td>
  <td bordercolor="#FFFFFF">
   <div align="center">
    <a onmouseover="javascript:image_click(2)"><img src="<?php echo "$row['thumb_3']"; ?>"  width="90" height="80" name="pimage2" border=0></a>
   </div>
  </td>
  <td bordercolor="#FFFFFF">
   <div align="center">
    <a onmouseover="javascript:image_click(3)"><img src="<?php echo "$row['thumb_4']"; ?>"  width="90" height="80" name="pimage3" border=0></a>
   </div>
  </td>
  <td bordercolor="#FFFFFF">
   <div align="center">
    <a onmouseover="javascript:image_click(4)"><img src="<?php echo "$row['thumb_5']"; ?>"  width="90" height="80" name="pimage4" border=0></a>
   </div>
  </td>
</tr>
</table>

 

like

<td bordercolor="#FFFFFF">
   <div align="center">
    <a onmouseover="javascript:image_click(1)"><img src="<?php echo $row['thumb_2']; ?>"  width="90" height="80" name="pimage1" border=0></a>
   </div>
  </td>
  <td bordercolor="#FFFFFF">
   <div align="center">
    <a onmouseover="javascript:image_click(2)"><img src="<?php echo $row['thumb_3']; ?>"  width="90" height="80" name="pimage2" border=0></a>
   </div>
  </td>
  <td bordercolor="#FFFFFF">
   <div align="center">
    <a onmouseover="javascript:image_click(3)"><img src="<?php echo $row['thumb_4']; ?>"  width="90" height="80" name="pimage3" border=0></a>
   </div>
  </td>
  <td bordercolor="#FFFFFF">
   <div align="center">
    <a onmouseover="javascript:image_click(4)"><img src="<?php echo $row['thumb_5']; ?>"  width="90" height="80" name="pimage4" border=0></a>
   </div>
  </td>
</tr>
</table>

just changed it whle you were probably typing

 

changed

$result=mysql_query($sql);

 

to this

$row = mysql_fetch_array($sql)

 

 

Now this.

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

 

One day I think i understand it, next day I'm confused

I'm not sure how it could be explained any simpler. mysql_fetch_array() expects a result resource which is what mysql_query() returns.

 

The ifs and check against mysql_num_rows() are there to prevent errors. You should always check your results before attempting to use them.

I'm not sure how it could be explained any simpler. mysql_fetch_array() expects a result resource which is what mysql_query() returns.

 

The ifs and check against mysql_num_rows() are there to prevent errors. You should always check your results before attempting to use them.

sorry i too didnt got it :confused:

 

so do mean that without if condition mysql_fetch_array() doesnot work

I'm not sure how it could be explained any simpler. mysql_fetch_array() expects a result resource which is what mysql_query() returns.

 

The ifs and check against mysql_num_rows() are there to prevent errors. You should always check your results before attempting to use them.

sorry i too didnt got it :confused:

 

so do mean that without if condition mysql_fetch_array() doesnot work

 

If there are no results there's no point passing an empty result resource to mysql_fetch_assoc().

Actually, just the part where you say that the rest of the code goes here.  I'm sorry, I'm not just looking for someone to give me the answer. I would still like to understand it.

 

Given my code above, the part where I sat '// rest of your code should go here'. That is the only place where $row is defined and guaranteed to have data.

i think the error is in the query

$sql = mysql_query("SELECT imgpath, imgpath2, imgpath3, imgpath4, imgpath5, thumb_1, thumb_2, thumb_3, thumb_4, thumb_5 FROM member_pictures WHERE thumb_1 = " . $_SESSION['picposted'] . "");

 

try running the query in the mysql and see what result u get

by the way wht is the $_SESSION['picposted'] value

Nope, totally confused now. And wondering if the general way I have the code will even work at all, or if I should change everything.

 

just try running the query in the mysql and see if u can get any results.

 

if not then use the code which has been given by thrope

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.