Voor een shoutbox gebruik ik een script dat heel goed werkte op een linux server echter ik moest mijn site over switchen naar een windows server en nu krijg ik een rij fouten. Hij connect wel met mijn database want als ik handmatig dingen in de database invoer laat ie ze wel zien. Alleen het wegschrijven naar de database lukt niet.
De fouten zijn:
Notice: Undefined variable: name_id_c in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 33
Notice: Undefined variable: link_c in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 36
Notice: Undefined variable: all in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 47
Notice: Use of undefined constant name_id_c - assumed 'name_id_c' in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 119
Notice: Undefined index: name_id_c in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 119
Notice: Use of undefined constant link_c - assumed 'link_c' in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 124
Notice: Undefined index: link_c in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 124
Notice: Undefined variable: php_self in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 129
Notice: Undefined variable: add in C:\Inetpub\vhosts\xs57.nl\httpdocs\NWP\shout\shout.php on line 139
Het stukje script waar het omgaat is de volgende:
<?
if ($name_id_c){
setcookie ("name_id_c", $name_id_c, time()+86400);
}
if ($link_c){
setcookie ("link_c", $link_c, time()+86400);
}
?>
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<body onload="window.scrollTo(0,99999);">
<?
include("connect.php");
$result = mysql_query("SELECT * FROM shout");
$all_rows = mysql_num_rows($result);
if ($all == "true"){
$start = "0";
$posts = "999";
} else {
if ($all_rows < 15){
$start = "0";
} else {
$start = $all_rows - 15;
}
$posts = "15";
}
$result = mysql_query("SELECT * FROM shout ORDER BY time ASC LIMIT $start,$posts");
$rows = mysql_num_rows($result);
if ($rows > 0) {
while($row = mysql_fetch_array($result)){
// Bad word check
$badwords = mysql_query("SELECT * FROM badwords");
$rowords = mysql_fetch_array($badwords);
$words = explode(",", $rowords[words]);
$bad = "*********************";
$i = "0";
while ($words[$i]){
$length = strlen($words[$i])-2;
$bad = substr($words[$i], 0, 2) . substr($bad, -$length);
$row[text] = ereg_replace($words[$i],$bad, $row[text]);
$i++;
}
// End of bad word check
$time = date("d. F Y H:i",$row[time]);
// Change emotions
$smile = "<img src='images/shout/happy.gif' align='absmiddle'>";
$ironic = "<img src='images/shout/ironic.gif' align='absmiddle'>";
$nothappy = "<img src='images/shout/mad.gif' align='absmiddle'>";
$very_happy = "<img src='images/shout/very_happy.gif' align='absmiddle'>";
$tongue = "<img src='images/shout/tongue.gif' align='absmiddle'>";
$nothing = "<img src='images/shout/nothing.gif' align='absmiddle'>";
$vain = "<img src='images/shout/vain.gif' align='absmiddle'>";
$row[text] = ereg_replace(":-\/",$vain, $row[text]);
$row[text] = ereg_replace(":\|",$nothing, $row[text]);
$row[text] = ereg_replace(":-\|",$nothing, $row[text]);
$row[text] = ereg_replace(":-P",$tongue, $row[text]);
$row[text] = ereg_replace(":P",$tongue, $row[text]);
$row[text] = ereg_replace(":p",$tongue, $row[text]);
$row[text] = ereg_replace(":-p",$tongue, $row[text]);
$row[text] = ereg_replace(":)",$smile, $row[text]);
$row[text] = ereg_replace(":-)",$smile, $row[text]);
$row[text] = ereg_replace(":D",$very_happy, $row[text]);
$row[text] = ereg_replace(":-D",$very_happy, $row[text]);
$row[text] = ereg_replace(":\(",$nothappy, $row[text]);
$row[text] = ereg_replace(":-\(",$nothappy, $row[text]);
$row[text] = ereg_replace(";)",$ironic, $row[text]);
$row[text] = ereg_replace(";-)",$ironic, $row[text]);
if ($row[ip] != "") {
$logged = "Yes!";
} else {
$logged = "No";
}
echo "<table cellpadding='2' cellspacing='0' width='100%'><tr><td align='left'>";
$amounts = mysql_query("SELECT * FROM shout WHERE ip = '$row[ip]'");
$entries = mysql_num_rows($amounts);
if ($row[link] != ""){
echo "<a target='_blank' href='http://$row[link]' title='$time - Logged:$logged Shouts:$entries'>$row[name_id]: </a>";
} else {
echo "<b title='$time - Logged:$logged Shouts:$entries'>$row[name_id]: </b></a>";
}
echo "$row[text]";
echo "</td></tr></table>";
}
}
?>
<table width="100%" cellpadding="2" cellspacing="0"><tr><td align="center">
<?
if ($HTTP_COOKIE_VARS[name_id_c]){
$name_value = $HTTP_COOKIE_VARS[name_id_c];
} else {
$name_value = "Your name";
}
if ($HTTP_COOKIE_VARS[link_c]){
$link_value = $HTTP_COOKIE_VARS[link_c];
} else {
$link_value ="Your link";
}
echo "<form name=\"form1\" method=\"post\" action=\"$php_self\">
<input class=\"inputtext\" type=\"text\" name=\"name_id\" value=\"$name_value\" onFocus=\"this.value='';\" size=\"20\">
<input class=\"inputtext\" type=\"text\" name=\"text\" value=\"Your message\" onFocus=\"this.value='';\" size=\"20\">
<input class=\"inputtext\" type=\"text\" name=\"link\" value=\"$link_value\" onFocus=\"this.value='';\" size=\"20\">
<input class=\"button\" type=\"submit\" name=\"add\" value=\"Go\"> <input class=\"button\" type=\"reset\" value=\"Reset\"><br>
<a href=\"?all=true\">All posts</a>
</form>";
?>
</td></tr></table>
<?
if ($add){
if ($link){
$link = trim($link);
$link = ereg_replace("http://", "", $link);
$s=substr_count($link,"http://");
$d=substr_count($link,".");
if ($s==0 && $d>=1){
$link_ok = "ok";
} else {
$link = "";
}
}
$time = time();
$ip = getenv("REMOTE_ADDR");
$name_id = strip_tags($name_id);
$text = strip_tags($text, '<a>');
if($name_id != "Your name" && $text != "Your message"){
mysql_query("insert into shout (ip,name_id,link,text,time) values ('$ip', '$name_id', '$link', '$text', '$time')");
echo "<script>location.href='$PHP_SELF?name_id_c=$name_id&link_c=$link';</script>";
}
}
mysql_close();
?>
</body>
740 views