I am diving into php and mysql and html using to trial by fire method because i wanted to make a game and since im an IT professional i have a big head and think i can do anything 🙂 so here i ran into a problem. I have a "shout box" code that works fine if you only have one table and one shout box. I am trying to create an individual team shoutbox for the players so that only their team can see the conversation. i have gotten as far as getting a table created upon creation of the team in the game with their team# but im having trouble linking the php page for the shoutbox to point to the variable.
here is the error
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''.shoutbox28.' VALUES('',1,'hi',unix_timestamp())' at line 1
if($_POST['message'] != "")
{
$_POST['message']=mysql_real_escape_string(trim(strip_tags($_POST['message'])));
$message=($_POST['message']);
//smileys
$key = array(":)", ":(", ";)", ":D", ":innocent", ":hug", ":/", ":x", ":blush", ":P", ":*", ":broken", ":o", ":mad", ":sly", "B-)", ":-S", "=))", ":-$", ":thumbs", ":devil", ":angel", ":nerd", ":whatever", ":sleep", ":roll", ":loser", ":clown", ":hmmm", ":drool");
$images = array("<img src=smileys/1.gif>", "<img src=smileys/2.gif>", "<img src=smileys/3.gif>", "<img src=smileys/4.gif>", "<img src=smileys/5.gif>", "<img src=smileys/6.gif>", "<img src=smileys/7.gif>", "<img src=smileys/8.gif>", "<img src=smileys/9.gif>", "<img src=smileys/10.gif>", "<img src=smileys/11.gif>", "<img src=smileys/12.gif>", "<img src=smileys/13.gif>", "<img src=smileys/14.gif>", "<img src=smileys/15.gif>", "<img src=smileys/16.gif>", "<img src=smileys/17.gif>", "<img src=smileys/18.gif>", "<img src=smileys/19.gif>", "<img src=smileys/20.gif>", "<img src=smileys/21.gif>", "<img src=smileys/22.gif>", "<img src=smileys/23.gif>", "<img src=smileys/24.gif>", "<img src=smileys/25.gif>", "<img src=smileys/26.gif>", "<img src=smileys/27.gif>", "<img src=smileys/28.gif>", "<img src=smileys/29.gif>", "<img src=smileys/30.gif>");
$message = str_replace($key, $images, $message);
$shout="shoutbox".$ir['gang'];
mysql_query("INSERT INTO '.$shout.' VALUES('',{$ir['userid']},'$message',unix_timestamp())",$c) or die (mysql_error());
print "<form action='". $_SERVER['PHP_SELF'] ."' method='post' name='form' form='form1' onSubmit=\"return disableForm(this);\"><b>Message: </b><input type='text' name='message' maxlength='255' size='31'><br><input type='Submit' value='Post Message'><input type='reset' value='Reset Message'></form><br/><br/>";
}
else
{
//Submit button JS Start
print <<<EOF
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function disableForm(theform) {
if (document.all || document.getElementById) {
for (i = 0; i < theform.length; i++) {
var tempobj = theform.elements[i];
if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
tempobj.disabled = true;
}
return true;
}
else {
return false;
}
}
// End -->