php or mysql parse error ( ? )
03-06-04, 12:19 PM
Newbie Coder
Join Date: Mar 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
php or mysql parse error ( ? )
im making a league for my clan and ive got this error which ive had before and solved easyily since it was always my silly bad syntax errors... however this one has me:
PHP Code:
$result = mysql_query ( "SELECT * FROM league_teams" ) or die( "Query failed: " . mysql_error ());
$numteams = mysql_num_rows ( $result );
$newteamid = ++ $numteams ;
$newteamname = $_REQUEST [ 'teamName' ];
$query = "INSERT INTO league_teams (team_id, team_name, team_wins, team_draws, team_losses, team_kills) VALUES (' $newteamid ', ' $newteamname ','0','0','0','0')" ;
$result = mysql_query ( $query ) or die( "Query failed: " . mysql_error ());
$result = mysql_query ( "SELECT * FROM league_players" ) or die( "Query failed: " . mysql_error ());
$numplayers = mysql_num_rows ( $result );
print "Debugging:<br>\n" ; //debugging
print "newteamid: $newteamid <br>\n" ; //debugging
print "numplayers: $numplayers <br>\n" ; //debugging
for ( $i = 0 ; $i <= 10 ; $i ++) {
$numplayers ++;
$playeraddname = $_REQUEST [ 'playerName$i' ];
$playeraddrank = $_REQUEST [ 'playerRank$i' ];
$playeraddid = $numplayers ;
print "playeraddname $i = $playeraddname <br>\n" ; //debugging
print "playeraddrank $i = $playeraddrank <br>\n" ; //debugging
if(!empty( $playeraddname ) && isset( $playeraddname ) && !empty( $playeraddrank ) && isset( $playeraddrank )) {
$query = "INSERT INTO league_players (team_id, player_name, player_rank, player_played, player_kills, player_id) VALUES (' $newteamid ', ' $playeraddname ', ' $playeraddrank ', '0', '0', ' $playeraddid ')" ;
$result = mysql_query ( $query ) or die( "Query failed: " . mysql_error ()); //error line
}
}
showMain ( '' );
i cant see it, am i doing something i shouldnt?! the input form has ten rows of text inputs.. player names and ranks and a single input text box for the team name.
the error is:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/father/public_html/bseteam/league/admin.php on line 97
thanks in advance for anyhelp anyone can give me
03-07-04, 11:38 AM
Community VIP
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
it will help alot to know which line in your code has the error!! it says it's in line 97,, bring lines 95-100 so we check ..
anyway I checked your code and it seems fine .. this kind of errors appear when a semicolon/dot is missing!
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9 ]
03-07-04, 05:07 PM
Newbie Coder
Join Date: Mar 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
i marked the line in the code with "// error line". and i looked up and down for a semi colon missing or other parse error but could not find it
03-07-04, 05:13 PM
Coding Addict
Join Date: Dec 2003
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Code:
$result = mysql_query ( "SELECT * FROM league_teams" ) or die( "Query failed: " . mysql_error ());
$numteams = mysql_num_rows ( $result );
$newteamid = $numteams ++;
$newteamname = $_REQUEST [ 'teamName' ];
$query = "INSERT INTO league_teams (team_id, team_name, team_wins, team_draws, team_losses, team_kills) VALUES (' $newteamid ', ' $newteamname ','0','0','0','0')" ;
$result = mysql_query ( $query ) or die( "Query failed: " . mysql_error ());
$result = mysql_query ( "SELECT * FROM league_players" ) or die( "Query failed: " . mysql_error ());
$numplayers = mysql_num_rows ( $result );
print "Debugging:<br>\n" ; //debugging
print "newteamid: $newteamid <br>\n" ; //debugging
print "numplayers: $numplayers <br>\n" ; //debugging
for ( $i = 0 ; $i <= 10 ; $i ++) {
$numplayers ++;
$playeraddname = $_REQUEST [ 'playerName$i' ];
$playeraddrank = $_REQUEST [ 'playerRank$i' ];
$playeraddid = $numplayers ;
print "playeraddname $i = $playeraddname <br>\n" ; //debugging
print "playeraddrank $i = $playeraddrank <br>\n" ; //debugging
if(!empty( $playeraddname ) && isset( $playeraddname ) && !empty( $playeraddrank ) && isset( $playeraddrank )) {
$query = "INSERT INTO league_players (team_id, player_name, player_rank, player_played, player_kills, player_id) VALUES (' $newteamid ', ' $playeraddname ', ' $playeraddrank ', '0', '0', ' $playeraddid ')" ;
$result = mysql_query ( $query ) or die( "Query failed: " . mysql_error ()); //error line
}
}
showMain ( '' );
the $newteamid was messed...
also idk maby right or not but showMain(''); is that corrent? should be.
03-08-04, 07:24 PM
Newbie Coder
Join Date: Mar 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
lol, thanks for the replys guys.. but i was barking in the wrong bloomin forest..lmao.. i not only marked the wrong error line.. but i posted the wrong block of code and the error turned out to be one of my debugging lines which i constantly over looked. hey i was tired... wheres the embarrased smilie in this place?
but thanks for your help guys
03-08-04, 07:26 PM
Coding Addict
Join Date: Dec 2003
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
yet
$newteamid = $numteams++;
was first wrong ;D
03-09-04, 08:49 AM
Newbie Coder
Join Date: Mar 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
is it? i was under the impression that ++$var would increase the var by one then print it and $var++ would print then increase?
03-09-04, 12:08 PM
Coding Addict
Join Date: Dec 2003
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
NVm your rit
03-09-04, 02:14 PM
Newbie Coder
Join Date: Mar 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
lol
ty anyway
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off