PDA

View Full Version : Notice: Use of undefined constant PHP ERROR HELP PLEASE




babyjenniferLB
Jun 1, 2007, 04:43 PM
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.



macfaninpdx
Jun 1, 2007, 06:25 PM
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.

babyjenniferLB
Jun 1, 2007, 06:41 PM
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.

<?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>

macfaninpdx
Jun 1, 2007, 06:50 PM
In the end of the printf line of code, , $row[id], $row[title], $row[author], $row[id]); you should have quotation marks around the array keys, like this:
, $row["id"], $row["title"], $row["author"], $row["id"]);

fwhh
Jun 1, 2007, 06:50 PM
If this is in line 35, it should be:
..., $row["id"], $row["title"], $row["author"], $row["id"]);
and in line 31:
$db = mysql_select_db("jennifersp", $server);
I think you forgot the quotes....

babyjenniferLB
Jun 2, 2007, 12:03 PM
thank you, fixed.