0

Hi Everyone,

I have a page that displays information from a mysql database. The information is taken from the members table where the id is in the url e.g. http://www.clancorner.net/tounament.php?go=MW2&id=2. And that works perfectly, pulls ou all the information i asked for. Unfortunatley i now need to just echo "Invalid tournament id" if the id is not in the table members and i have tried numerous thing that just havn't worked. Heres the code i am using at the minute:

<?
if($_GET["go"]=="MW2")
{
    $tourneyid = mysql_escape_string($_GET['id']);
	$touneyname = mysql_escape_string($_GET['name']);
    mysql_connect("localhost","username","pass");
    mysql_select_db("tournamentsMW2");
    $sql = "SELECT * FROM tournamentsMW2 WHERE id='" . $tourneyid . "'";
    $result = mysql_query($sql);
    $row = mysql_fetch_assoc($result);
	
	//Set Variables
	$name=$r["name"];
	$datetime=$r["datetime"];
	$buyin=$r["buyin"];
	$type=$r["type"];
	$mode=$r["mode"];
}
?>

Thanks in advance!

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by BlueCharge
0

You could try

$result = mysql_query($sql);
$num = mysql_numrows($result);
if ($num == 0) {
echo 'No Results';
}
else {
// Rest of code
}

Basically checks for the number of rows your query finds.

Edited by sourcez: n/a

0

You could try

$result = mysql_query($sql);
$num = mysql_numrows($result);
if ($num == 0) {
echo 'No Results';
}
else {
// Rest of code
}

Basically checks for the number of rows your query finds.

Thank you very much my friend, that worked like a treat :D:D

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.