Jump to content

help with error please


justAnoob

Recommended Posts

Here is my table the is suppose to be displayed. But is not.

No table is displayed and also in the error console of FF I get an

"unterminated string literal" which points to this below.

 

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']; ?>"

 

 

 

<?php
include "connection.php";
$sql = mysql_query("SELECT id, 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);

if ($result = mysql_query($sql))
{
if (mysql_num_rows($result))
{
  $row = mysql_fetch_array($result);
?>
  <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> 
<?php
}
}
?>
          
          
	  		  
           
          </td>
        </tr>
      </table>
     </div>
    </div>
   </div>  </td>
</tr>
</table>

I'm pretty sure that I am displaying the table correctly. I have done this before. Maybe something is wrong though. I'm stumped.

Link to comment
Share on other sites

what is this whole mess here:

 

<?php
//...
$result=mysql_query($sql);

if ($result = mysql_query($sql))
{

 

lose the:

 

$result=mysql_query($sql);

 

and:

 

if ($result = mysql_query($sql))
{

 

you have already executed your query with this:

 

$sql = mysql_query ("...");

 

you don't need to execute the query 3 times.

 

code will look like this now:

 

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

if (mysql_num_rows($sql) > 0)
{
  $row = mysql_fetch_array($sql);
?>
  <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>
<?php
}
?>
         
         
               
           
          </td>
        </tr>
      </table>
     </div>
    </div>
   </div>  </td>
</tr>
</table>

Link to comment
Share on other sites

hey, this ain't my code.

 

this will not work:

 

if ($result = mysql_query($sql))

 

and was the reason for no output.

 

EDIT: had proper error handling (adding an ELSE condition to each IF), this would have been picked up ages ago.

 

That is my code and it does work. In fact that is how all select queries should be written, this way you know $result holds a result resource prior to passing it to mysql_num_rows() or mysql_fetch_assoc().

 

See here.

Link to comment
Share on other sites

Thorpe... If statements don't block mysql warnings... @'s do. If is a good thing to always do on a mysql query, though because it's never certain to work.

 

"if (@mysql_query"

 

I know how mysql_query works. Point is, you need to check your $result before passing it to any of the other mysql functions.

Link to comment
Share on other sites

k, but the comparison operator is incorrect.  should be === (or at least ==), but you're best to check type as well.

 

instead of:

 

if ($result = mysql_query($sql))

 

if ($sql)

 

would suffice.

 

OR:

 

if ($result === mysql_query ($sql))

 

now, i'm not trying to be of a disturbance, and i see you are of Alumni status, so respect is given where respect is due, but that code has redundancies:

 

one with mysql_query function being called twice:

$sql = mysql_query("...");
$result=mysql_query($sql);

Link to comment
Share on other sites

k, but the comparison operator is incorrect.  should be === (or at least ==), but you're best to check type as well.

 

instead of:

 

if ($result = mysql_query($sql))

 

if ($sql)

 

would suffice.

 

OR:

 

if ($result === mysql_query ($sql))

 

now, i'm not trying to be of a disturbance, and i see you are of Alumni status, so respect is given where respect is due, but that code has redundancies:

 

one with mysql_query function being called twice:

$sql = mysql_query("...");
$result=mysql_query($sql);

 

I never told the OP to execute mysql_query more than once. That was there mistake.

 

Using a comparison operator would fail to assign the result to $result, where not trying to do a comparison. Just checking the expression equates to true.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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