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!

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.