Forum Moderators: coopster

Message Too Old, No Replies

Error in my mysql querry

         

skoff

11:00 pm on Dec 10, 2008 (gmt 0)

10+ Year Member



Hi guys

I have a little problem here that i cant fix by myself. I tried something but i got a false result. So here is my problem, I want to show every goal that the player scored and these are in a table named "info" and i have another table named "calendar" that you have the game number and the team i played against like game 6 i played vs edmonton or game 7 i played against colorado. What i want to do is when i go to the page of a player i see the list of every goal he scored. So this is the my code :

<?php

$db_host = 'localhost';
$db_user = 'root';
$db_pwd = '';

if (!mysql_connect($db_host, $db_user, $db_pwd))
die("Can't connect to database");
mysql_select_db("test");
$face=$_GET['player'].".jpg";
$logo=$_GET['team'].".png";
if(!isset($_GET['player'])) {
echo 'Choisir un joueur';
die;
}
$result = mysql_query("select info.game,info.goal,info.player,calendar.adv from info,calendar where info.game = calendar.game = info." . mysql_real_escape_string($_GET['player'])."") or die(mysql_error());

while ($row = mysql_fetch_array($result))
{
echo "<table width='100%' border='0' cellspacing='0' cellpadding='0 '>";
echo " <tr>";
echo " <td width='10%'>Match #" . $row["game"] . " VS " . $row["adv"] . "</td>";
echo " <td width='90%'>" . $row["player"] . "</td>";
echo " </tr>";
echo "</table>";
}

mysql_close();

?>

the problem is when i test this page i have an error :
Field 'info.Lang' unknown in where clause

but i need to specify that its Lang's goals i want to see.. i really dont know how to solve this.. i hope i was clear.. im not that good in english

thanks for your help

Alcoholico

1:52 am on Dec 11, 2008 (gmt 0)

10+ Year Member



First, you're very prone to an SQL attack, never pass user input without proper filtering.
This query should work:

SELECT
info.game,
info.goal,
info.player,
calendar.adv
FROM
info, calendar
WHERE
info.game = calendar.game
AND
info.player = '$player';

Remember to replace "$player" with the appropiate and filtered user input.
bonne chance!

skoff

2:12 am on Dec 11, 2008 (gmt 0)

10+ Year Member



i have an error : Notice: Undefined variable: player in C:\Program Files\EasyPHP 2.0b1\www\test3.php on line 55

skoff

2:14 am on Dec 11, 2008 (gmt 0)

10+ Year Member



nvm i had $player = $_GET['player']; thks a lot