Notice: Use of undefined constant PHP ERROR HELP PLEASE

Discussion in 'Web Design and Development' started by Cabbit, Jun 1, 2007.

  1. Cabbit macrumors 68020

    Cabbit

    Joined:
    Jan 30, 2006
    Location:
    Scotland
    #1
    hi hi i seem to get the following error
    Notice: Use of undefined constant jennifersp - assumed 'jennifersp' in
    followed by
    /home/fhlinux169/t/test.jennifersplaygroup.co.uk/user/htdocs/stories.php on line 31

    Notice: Use of undefined constant id - assumed 'id' in /home/fhlinux169/t/test.jennifersplaygroup.co.uk/user/htdocs/stories.php on line 35

    Notice: Use of undefined constant title - assumed 'title' in /home/fhlinux169/t/test.jennifersplaygroup.co.uk/user/htdocs/stories.php on line 35

    Notice: Use of undefined constant author - assumed 'author' in /home/fhlinux169/t/test.jennifersplaygroup.co.uk/user/htdocs/stories.php on line 35

    and it keeps repeating and repeating.

    You can see for your self on http://www.test.jennifersplaygroup.co.uk/ and click on the story book's link. or the un embedded version is http://www.test.jennifersplaygroup.co.uk/stories.php. The error happens with or without being embedded so i can safely rule that one out.
     
  2. macfaninpdx macrumors regular

    Joined:
    Mar 6, 2007
    #2
    We will need to see line 31 of your PHP code on the file stories.php. Possibly line 35, too.

    If I had to take a guess, I would say you are using a viariable without first declaring it. Since it is only a "Notice", it shouldn't be preventing the rest of the code from running.

    You can turn off Notices from displaying in your php.ini file, or you can declare the variable first before trying to read it. For example, you could say $jennifersp = ""; if that is indeed avariable you are trying to use.
     
  3. Cabbit thread starter macrumors 68020

    Cabbit

    Joined:
    Jan 30, 2006
    Location:
    Scotland
    #3
    Code:
    <?php
    $host = "";
    $username = "";
    $password = "";
    $database = "";
    $server = mysql_connect($host, $username, $password);
    $connection = mysql_select_db($database, $server);
    $server = mysql_connect($host, $username, $password);
    $db = mysql_select_db(jennifersp, $server);
    $sql = mysql_query('SELECT * FROM `storys` ORDER BY `id` DESC');
    print "<table><tr><th>Story</th><th>Author</th><th>Comments</th></tr>";
    while($row = mysql_fetch_array($sql, MYSQL_BOTH)) {
    printf("<tr><td><a href='/themes/zen/story_display.php?id=%s'>%s</a></td><td><span style=\"TEXT-ALIGN:center\">%s</span></td><td colspan=2><A HREF=\"javascript:popUp('./story_comment_whole.php?id=%s')\">View</A><br /><br /></td>", $row[id], $row[title], $row[author], $row[id]);
    }
    ?>
    </table>
     
  4. macfaninpdx macrumors regular

    Joined:
    Mar 6, 2007
    #4
    In the end of the printf line of code,
    Code:
    , $row[id], $row[title], $row[author], $row[id]);
    you should have quotation marks around the array keys, like this:
    Code:
    , $row["id"], $row["title"], $row["author"], $row["id"]);
     
  5. fwhh macrumors regular

    Joined:
    Aug 11, 2004
    Location:
    Berlin, Germany
    #5
    If this is in line 35, it should be:
    Code:
    ..., $row["id"], $row["title"], $row["author"], $row["id"]);
    and in line 31:
    Code:
    $db = mysql_select_db("jennifersp", $server);
    I think you forgot the quotes....
     
  6. Cabbit thread starter macrumors 68020

    Cabbit

    Joined:
    Jan 30, 2006
    Location:
    Scotland

Share This Page