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!
I am having trouble with my mysql setup in the setup.php of my mmorpg script (see below). I have tried to find the error but cannot find out what is wrong!!
my site is virus-mafia.com
my MySQL data,
username=<Removed by mod>
pass=<Removed by mod>
name=<Removed by mod>
You should've echoed the SQL statement, it would've shown you whats wrong with your statement values. Also use mysql_error() to show you error MySql server returned.
Ok now i have edited it and am now getting this error message,
Parse error: syntax error, unexpected T_STRING, expecting '}' in /www/110mb.com/v/i/o/l/e/n/t/j/violentj/htdocs/setup.php on line 45
again ive tried looking to see wtf is wrong but i cant find out! ive tried backslashing but that dont work, and i dont fully understand the echoing thing
This is what I see at a glance, maybe there are more errors:
1. you forgot the closing curly brace around $tab['game'](as much is said in the error message you got)
2. you also have '/' sign in the next line which has no place there, and would cause php interpreter to throw a syntax error if you already didn't have one
3. $site[location] in the 46. line should also be enclosed in curly braces
if(($tru) && (!mysql_fetch_row(mysql_query("SELECT round FROM {$tab['game']} WHERE round='$tru' AND starts<$time AND ends>$time;"))))
{ header("Location: {$site[location]}play.php/"); }
I have now encountered the following error but my MySQL statement (im sure) are correct (unless its me being naive)
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /content/StartupHostPlus/v/i/virus-mafia.com/web/setup.php on line 63
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /content/StartupHostPlus/v/i/virus-mafia.com/web/setup.php on line 69
//////CENSORS
$getcensors = mysql_query("SELECT censor FROM $tab[censor];");
$censorwords = array();
while($censor=mysql_fetch_array($getcensors)) {
array_push($censorwords, $censor[0]);
}
//GRAB THEY MASTER AND GAME ID
if($tru){ $id = mysql_fetch_array(mysql_query("SELECT id FROM $tab[pimp] WHERE code='$trupimpn';")); }
else{ $id = mysql_fetch_array(mysql_query("SELECT id FROM $tab[user] WHERE code='$trupimp';")); }
$id=$id[0];
//////CENSORS
$getcensors = mysql_query("SELECT censor FROM $tab[censor];");
$censorwords = array();
while($censor=mysql_fetch_array($getcensors)) {
array_push($censorwords, $censor[0]);
}
//GRAB THEY MASTER AND GAME ID
if($tru){ $id = mysql_fetch_array(mysql_query("SELECT id FROM $tab[pimp] WHERE code='$trupimpn';")); }
else{ $id = mysql_fetch_array(mysql_query("SELECT id FROM $tab[user] WHERE code='$trupimp';")); }
$id=$id[0];
This forum is a place of learning, and you should't expect others to do your work. Sooo... Read my first post and take a look at your SQL statements I quoted in my last post. Everything you need is there.
You need curly braces around array elements in quoted strings.
I already provided examples in previous posts, you just need to go through the WHOLE of your code and apply what I've written above.
//////CENSORS
$getcensors = mysql_query("SELECT censor FROM {$tab[censor]};");///this is the line im havin trouble with
$censorwords = array();
while($censor=mysql_fetch_array($getcensors)) {
array_push($censorwords, $censor[0]);
}
//GRAB THEY MASTER AND GAME ID
if($tru){ $id = mysql_fetch_array(mysql_query("SELECT id FROM $tab[pimp] WHERE code='$trupimpn';")); }
else{ $id = mysql_fetch_array(mysql_query("SELECT id FROM $tab[user] WHERE code='$trupimp';")); }
$id=$id[0];