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
scarface222
Forum Contributor
Posts: 354 Joined: Thu Mar 26, 2009 8:16 pm
Post
by scarface222 » Tue Jun 16, 2009 3:39 pm
hey guys this is my code and i get the message Notice: Undefined variable: result in C:\Web Files\wamp\www\***\***.php on line 60 which is the highlighted line. Any ideas? I thought the variable is defined.
Code: Select all
if(!$_POST['action']){
header ("Location: index.html");
}
else{
$link = connect(HOST, USER, PASSWORD);
switch($_POST['action']){
case "update":
$res = getContent($link, 20);
while($row = mysql_fetch_array($res)){
[color=#FF0000]$result .= "<li><strong>".$row['user']."</strong><img src=\"css/images/bullet.gif\" alt=\"-\" [/color]/>".$row['message']." <span class=\"date\">".$row['date']."</span></li>";
}
echo $result;
break;
case "insert":
echo insertMessage($_POST['nick'], $_POST['message']);
break;
}
Last edited by
scarface222 on Tue Jun 16, 2009 7:20 pm, edited 1 time in total.
Mark Baker
Forum Regular
Posts: 710 Joined: Thu Oct 30, 2008 6:24 pm
Post
by Mark Baker » Tue Jun 16, 2009 4:42 pm
$result .= "<li>..."
is concatenating "<li>..." to the existing value of $result, except that $result doesn't yet exist.
Try predefining $result as '';
scarface222
Forum Contributor
Posts: 354 Joined: Thu Mar 26, 2009 8:16 pm
Post
by scarface222 » Tue Jun 16, 2009 7:08 pm
Thanks for the reply bro but I don't quite understand what you are saying. $result=";? Could you explain more sorry I am kind of an amateur sometimes.
scarface222
Forum Contributor
Posts: 354 Joined: Thu Mar 26, 2009 8:16 pm
Post
by scarface222 » Tue Jun 16, 2009 7:19 pm
i predefined as =""; lol and it worked before the while statement thanks bro