Php syntax error?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
satikas
Forum Newbie
Posts: 19
Joined: Sat Mar 28, 2009 9:14 am

Php syntax error?

Post 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.
user___
Forum Contributor
Posts: 297
Joined: Tue Dec 05, 2006 3:05 pm

Re: Php syntax error?

Post 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.
satikas
Forum Newbie
Posts: 19
Joined: Sat Mar 28, 2009 9:14 am

Re: Php syntax error?

Post by satikas »

What you mean "clean it"? I need every line there.
divito
Forum Commoner
Posts: 89
Joined: Sun Feb 22, 2009 7:29 am

Re: Php syntax error?

Post by divito »

He means to make it look neater.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Php syntax error?

Post 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.
Post Reply