Web Analytics Made Easy -
StatCounter What's wrong with this code? - CodingForum

Announcement

Collapse
No announcement yet.

What's wrong with this code?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • What's wrong with this code?

    Okay, so I am workig on something called Tudit, and there is something wrong with the following code- but I am not sure what:

    PHP Code:
    <?php

    // Start output buffering.
    ob_start();
    // Initialize a session.
    session_start();

    ?>
    <!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=ISO-8859-1" />
    <title>Tudit: <?php echo $name ?></title>
    <style>
    #display
    {
    width: 80%;
    height: 80%;
    }

    .tab
    {
    background: url(tab.png) repeat-x;
    width: 50px;
    height: 15px;
    border: #000000 thin solid;
    overflow: hidden;
    font-size: 14px;
    font-family: Arial, Helvetica, sans-serif;
    font-color: #fff;
    }
    </style>
    </head>

    <body>

    <?php
    $name
    =$_GET["channel"];
    require_once (
    '../mysql_connect.php'); // Connect to the database

    $result mysql_query("SELECT source1, name1, source2, name2, source3, name3, source4, name4, source5, name5
    FROM channels
    WHERE channame = ' 
    $name ';");

    while(
    $row mysql_fetch_array($result))
      {
      echo 
    '<a href="aggregate.php?readsource=' $row[source1] . '" target="ifrm" class="tab">' $row[name1] . '</a>';
      echo 
    '<a href="aggregate.php?readsource=' $row[source2] . '" target="ifrm" class="tab">' $row[name2] . '</a>';
      echo 
    '<a href="aggregate.php?readsource=' $row[source3] . '" target="ifrm" class="tab">' $row[name3] . '</a>';
      echo 
    '<a href="aggregate.php?readsource=' $row[source4] . '" target="ifrm" class="tab">' $row[name4] . '</a>';
      echo 
    '<a href="aggregate.php?readsource=' $row[source5] . '" target="ifrm" class="tab">' $row[name5] . '</a>';
      }

    ?>
    <iframe src="mosource.php" name="ifrm"  id="ifrm" frameborder="0" height="650" width="900" />
    </body>

    </html>
    <?php // Flush the buffered output.
    ob_flush();
    ?>
    Help please!

  • #2
    Code:
    <?php echo $name ?>
    to

    Code:
    <?php echo $name; ?>

    Comment


    • #3
      LOL good spot, i didnt see it ;p

      Comment


      • #4
        So what is this doing or not doing that you need help with? All you have stated is - "there is something wrong with the following code"

        Since you have not given us any information, I'll take a guess - I see a number of possible problems -

        1) Your title might only be "Tudit:" because at the point in the code where the title is output, the $name variable has not been set to any value and will be null/empty.

        2) Your mysql_query(...) might be failing and needs some error checking.

        3) Your <a href=... links need &'s placed between the different parameters.

        4) Your use of $row[someindex...] is getting interpreted by PHP so that it works, but is causing a Notice error message (this is probably only getting logged due to the error_reporting settings, but logging this causes a small speed penalty and these type of errors should always be corrected in the final code.)

        To help with finding problems like #1 and #4, put the following line in after your opening <?php tag -
        PHP Code:
        error_reporting(E_ALL); 
        Finding out HOW to do something is called research, i.e. keep searching until you find the answer. After you attempt to do something and cannot solve a problem with it yourself, would be when you ask others for help.

        Comment

        Working...
        X