Page 1 of 2
MySQL Error
Posted: Thu Mar 27, 2008 5:11 pm
by violentj
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>
This is the script im having problems with.
ANY HELP WOULD BE GREATLY APPRECIATED
If u can get it sorted i have a spare script too
Code: Select all
<?
$time=time();
$site[location] = 'http://www.virus-mafia.com/'; ///SITE LOCATION
$site[img] = 'http://virus-mafia.com/images/'; ///SITE IMAGES
$dir="../images/icons/$tru/";
$arr_allow_ex=array("gif","jpg","png");
$maxupload[sup] = '5000'; //supporter upload in bytes
$maxupload[nor] = '2500'; //normal upload in bytes
$db[host] = 'insert'; //DATABASE HOST "mysql4.namesco.net"
$db[user] = 'insert'; //DATABASE USERNAME
$db[pass] = 'insert'; //DATABASE PASSWORD
$db[name] = 'insert'; //DATABASE NAME
$connect = mysql_connect($db[host],$db[user], $db[pass]);
mysql_select_db("$db[name]") or die ("Could not connect to database");
$tab[user] = 'users';
$tab[html] = 'html';
$tab[news] = 'news';
$tab[game] = 'games';
$tab[stat] = 'stats';
$tab[censor] = 'censors';
$tab[banned] = 'bans';
$tab[paypal] = 'paypal';
$tab[board] = "board";
$tab[clist] = "contacts";
$tab[city] = "city";
$tab[crew] = "crew";
$tab[invite] = "invites";
$tab[mail] = "mailbox";
$tab[pimp] = "pimp";
$tab[revenge] = "revenges";
$tab[cron] = "cronjobs";
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"); }
if($tru){
$tab[board] = "r".$tru."_board";
$tab[clist] = "r".$tru."_contacts";
$tab[city] = "r".$tru."_city";
$tab[crew] = "r".$tru."_crew";
$tab[invite] = "r".$tru."_invites";
$tab[mail] = "r".$tru."_mailbox";
$tab[pimp] = "r".$tru."_$tab[pimp]";
$tab[revenge] = "r".$tru."_revenges";
$tab[cron] = "r".$tru."_cronjobs";
}
$getcensors = mysql_query("SELECT censor FROM $tab[censor];");
$censorwords = array();
while($censor=mysql_fetch_array($getcensors)) {
array_push($censorwords, $censor[0]);
}
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];
?>
Hawleyjr: Username & Password Removed. Please use PHP tags when posting.
Re: MySQL Error
Posted: Thu Mar 27, 2008 5:24 pm
by EverLearning
In your SQL statement you have array elements in a double quoted string. You can't access them with
,
since interpreter will only resolve the '$tab' part and $tab is an array.
Put curly braces around them, and your statement should work. And I suggest you put quotes around the array keys
.
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.
Re: MySQL Error
Posted: Fri Mar 28, 2008 10:10 am
by kryles
I hope the Mod also removed the host/user/password information from the PHP code also

Re: MySQL Error
Posted: Fri Mar 28, 2008 4:47 pm
by violentj
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
Code: Select all
<?
//Good ol' time
$time=time();
//////PRETTY SIMPLE, MAKE SURE URL LOCATIONS END WITH "/"
$site[location] = 'http://violentj.110mb.com/'; ///SITE LOCATION
$site[img] = 'http://virus-mafia.com/images/'; ///SITE IMAGES
//////UPLOAD SETTINGS
$dir="../images/icons/$tru/";
$arr_allow_ex=array("gif","jpg","png");
$maxupload[sup] = '5000'; //supporter upload in bytes
$maxupload[nor] = '2500'; //normal upload in bytes
//////DATABASE CONFIG, AND CONNECTION
$db[host] = 'insert'; //DATABASE HOST "mysql4.namesco.net"
$db[user] = 'insert'; //DATABASE USERNAME
$db[pass] = 'insert'; //DATABASE PASSWORD
$db[name] = 'insert'; //DATABASE NAME
$connect = mysql_connect($db[host],$db[user], $db[pass]);
mysql_select_db("$db[name]") or die ("Could not connect to database");
//////DATABASE TABLES
$tab[user] = 'users';
$tab[html] = 'html';
$tab[news] = 'news';
$tab[game] = 'games';
$tab[stat] = 'stats';
$tab[censor] = 'censors';
$tab[banned] = 'bans';
$tab[paypal] = 'paypal';
/////GAME DATABASE TABLES
$tab[board] = "board";
$tab[clist] = "contacts";
$tab[city] = "city";
$tab[crew] = "crew";
$tab[invite] = "invites";
$tab[mail] = "mailbox";
$tab[pimp] = "pimp";
$tab[revenge] = "revenges";
$tab[cron] = "cronjobs";
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/"); }
if($tru){
$tab[board] = "r".$tru."_board";
$tab[clist] = "r".$tru."_contacts";
$tab[city] = "r".$tru."_city";
$tab[crew] = "r".$tru."_crew";
$tab[invite] = "r".$tru."_invites";
$tab[mail] = "r".$tru."_mailbox";
$tab[pimp] = "r".$tru."_$tab[pimp]";
$tab[revenge] = "r".$tru."_revenges";
$tab[cron] = "r".$tru."_cronjobs";
}
//////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];
?>
Re: MySQL Error
Posted: Fri Mar 28, 2008 7:05 pm
by EverLearning
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
Correct code should be:
Code: Select all
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/"); }
Re: MySQL Error
Posted: Sat Mar 29, 2008 4:03 pm
by violentj
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
Code: Select all
<?
$time=time();
$site[location] = 'http://virus-mafia.com/'; ///SITE LOCATION
$site[img] = 'http://virus-mafia.com/images/'; ///SITE IMAGES
////UPLOAD SETTINGS
$dir="../images/icons/$tru/";
$arr_allow_ex=array("gif","jpg","png");
$maxupload[sup] = '5000'; //supporter upload in bytes
$maxupload[nor] = '2500'; //normal upload in bytes
//////DATABASE CONFIG, AND CONNECTION
$db[host] = '***'; //DATABASE HOST "mysql4.namesco.net"
$db[user] = '***'; //DATABASE USERNAME
$db[pass] = '***'; //DATABASE PASSWORD
$db[name] = '***'; //DATABASE NAME
$connect = mysql_connect($db[host],$db[user], $db[pass]);
mysql_select_db("$db[name]") or die ("Could not connect to database");
//////DATABASE TABLES
$tab[user] = 'users';
$tab[html] = 'html';
$tab[news] = 'news';
$tab[game] = 'games';
$tab[stat] = 'stats';
$tab[censor] = 'censors';
$tab[banned] = 'bans';
$tab[paypal] = 'paypal';
/////GAME DATABASE TABLES
$tab[board] = "board";
$tab[clist] = "contacts";
$tab[city] = "city";
$tab[crew] = "crew";
$tab[invite] = "invites";
$tab[mail] = "mailbox";
$tab[pimp] = "pimp";
$tab[revenge] = "revenges";
$tab[cron] = "cronjobs";
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/"); }
if($tru){
$tab[board] = "r".$tru."_board";
$tab[clist] = "r".$tru."_contacts";
$tab[city] = "r".$tru."_city";
$tab[crew] = "r".$tru."_crew";
$tab[invite] = "r".$tru."_invites";
$tab[mail] = "r".$tru."_mailbox";
$tab[pimp] = "r".$tru."_$tab[pimp]";
$tab[revenge] = "r".$tru."_revenges";
$tab[cron] = "r".$tru."_cronjobs";
}
//////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];
?>
plz tell me if there is a fault, as ive checked it several time and again cant find anything wrong!
Re: MySQL Error
Posted: Sat Mar 29, 2008 4:39 pm
by EverLearning
Curly braces. AGAIN.

Re: MySQL Error
Posted: Sat Mar 29, 2008 4:43 pm
by violentj
ive put them there havent i?!
Re: MySQL Error
Posted: Sat Mar 29, 2008 4:51 pm
by EverLearning
Code: Select all
//////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];
Where are curly braces in this code?
Re: MySQL Error
Posted: Sat Mar 29, 2008 4:57 pm
by violentj
wat?
Code: Select all
//////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];
???
Re: MySQL Error
Posted: Sat Mar 29, 2008 5:28 pm
by EverLearning
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.
Re: MySQL Error
Posted: Sat Mar 29, 2008 6:02 pm
by violentj
ive looked at the cide and tried ti find the error but i cant (that was the point of coming to the forum). thanx anywayz
Re: MySQL Error
Posted: Sat Mar 29, 2008 7:00 pm
by EverLearning
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.
Re: MySQL Error
Posted: Mon Mar 31, 2008 11:24 am
by violentj
curly braces have made NO difference to the error!
Code: Select all
//////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];
suggestions!
Re: MySQL Error
Posted: Mon Mar 31, 2008 11:38 am
by kryles
Code: Select all
<?php
$time=time();
$site[location] = 'http://www.virus-mafia.com/'; ///SITE LOCATION
$site[img] = 'http://virus-mafia.com/images/'; ///SITE IMAGES
$dir="../images/icons/$tru/";
$arr_allow_ex=array("gif","jpg","png");
$maxupload[sup] = '5000'; //supporter upload in bytes
$maxupload[nor] = '2500'; //normal upload in bytes
$db[host] = 'insert'; //DATABASE HOST "mysql4.namesco.net"
$db[user] = 'insert'; //DATABASE USERNAME
$db[pass] = 'insert'; //DATABASE PASSWORD
$db[name] = 'insert'; //DATABASE NAME
$connect = mysql_connect($db[host],$db[user], $db[pass]);
mysql_select_db("$db[name]") or die ("Could not connect to database");
$tab[user] = 'users';
$tab[html] = 'html';
$tab[news] = 'news';
$tab[game] = 'games';
$tab[stat] = 'stats';
$tab[censor] = 'censors';
$tab[banned] = 'bans';
$tab[paypal] = 'paypal';
$tab[board] = "board";
$tab[clist] = "contacts";
$tab[city] = "city";
$tab[crew] = "crew";
$tab[invite] = "invites";
$tab[mail] = "mailbox";
$tab[pimp] = "pimp";
$tab[revenge] = "revenges";
$tab[cron] = "cronjobs";
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"); }
if($tru){
$tab[board] = "r".$tru."_board";
$tab[clist] = "r".$tru."_contacts";
$tab[city] = "r".$tru."_city";
$tab[crew] = "r".$tru."_crew";
$tab[invite] = "r".$tru."_invites";
$tab[mail] = "r".$tru."_mailbox";
$tab[pimp] = "r".$tru."_$tab[pimp]";
$tab[revenge] = "r".$tru."_revenges";
$tab[cron] = "r".$tru."_cronjobs";
}
$getcensors = mysql_query("SELECT censor FROM {$tab[censor]};");
$censorwords = array();
while($censor=mysql_fetch_array($getcensors)) {
array_push($censorwords, $censor[0]);
}
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];
?>
try that.