Page 1 of 1

Php syntax error?

Posted: Tue Apr 28, 2009 11:30 am
by satikas
I have no idea where to post it because this issue involves php, html and javascript.
Anyway im trying to hide a content returned from the MySQL db.
But it wont work, either its a syntax error or crappy javascript.
Firstly picture will be displayed. Then its links. My goal is to hide the links by default and display em on IMAGE mouse over:
(Bold not working, look for the tags).

Code: Select all

 
[b]<script type="text/javascript" src="javascripts/showhide.js"></script>[/b]
<?php 
session_start();
 require_once "globalconfig.php";
  $result = mysql_query("SELECT * FROM defaultbooks ORDER BY ID"); 
   while($r=mysql_fetch_array($result)){ 
    $filename=$r["filename"];
     $url=$r["url"];
      echo "<a href='http://$url' target='_blank'><img src='images/bookmarks/default/$filename'  [b]onMousehover='showHide(/'hidden_div/'); return false;'[/b] border='0' width='130'></a>
      <br><a href='user_bookmarks_href_add.php?filename=$filename' target='contentframe'>
      <img src='images/main/link.png' border='0'></a><br>";
  if(isset($_COOKIE['user1'])){ ?>
[b]<div id="hidden_div" style="display: none;">[/b]
   <?php $ename = $_COOKIE['user1'];
    $getlinks = mysql_query("SELECT * FROM booklinks WHERE ename = '$ename' AND filename = '$filename' ORDER BY ID"); 
     while($linkdata=mysql_fetch_array($getlinks)){ 
      $lurl=$linkdata["url"];
      echo "<a href='http://$lurl' target='_blank'>$lurl</a><br>"; [b]?></div><?php[/b]
      }}}
 if(isset($_COOKIE['user1'])){ ?>
   <?php $ename = $_COOKIE['user1'];
   $userbooks = mysql_query("SELECT * FROM userbooks WHERE ename = '$ename' ORDER BY ID"); 
    while($data=mysql_fetch_array($userbooks)){ 
     $ufilename=$data["filename"];
      $uurl=$data["url"];
       echo "<a href='http://$uurl' target='_blank'>
       <img src='images/bookmarks/users/$ufilename' border='0' vspace='2' width='130'></a>
       <br><a href='user_bookmarks_href_add.php?filename=$ufilename' target='contentframe'>
       <img src='images/main/link.png' border='0'></a><br>";
  $ename = $_COOKIE['user1'];
   $getlinks = mysql_query("SELECT * FROM booklinks WHERE ename = '$ename' AND filename = '$ufilename' ORDER BY ID"); 
    while($linkdata=mysql_fetch_array($getlinks)){ 
     $lurl=$linkdata["url"];
      echo "<a href='http://$lurl' target='_blank'>$lurl</a><br>";
      }}} ?>
 
Thanks for any help.

Re: Php syntax error?

Posted: Tue Apr 28, 2009 1:24 pm
by user___
You must not insert anything before header()/session_start() but php that outputs nothing. Otherwise, I recommend you to clear your code a little and include the JS, so that we can help you. You really should clean it.

Re: Php syntax error?

Posted: Tue Apr 28, 2009 3:07 pm
by satikas
What you mean "clean it"? I need every line there.

Re: Php syntax error?

Posted: Tue Apr 28, 2009 3:23 pm
by divito
He means to make it look neater.

Re: Php syntax error?

Posted: Tue Apr 28, 2009 5:04 pm
by McInfo
PEAR Coding Standards - You don't have to follow every rule exactly, but if you need some advice on how to write readable code, this is a good place to start.

Edit: This post was recovered from search engine cache.