Jump to content

[SOLVED] simple doublet check is failing


froboz

Recommended Posts

I've run into a bit of a wall on one of my projects, I don't know if I'm just being blind on my own code or what because I cannot wrap my head around this one:

 

$result = "SELECT * FROM v_disciplines WHERE username = 'USERNAME' AND discipline = '".$discipline."'";

$doublet_check = mysql_num_rows($result);

 

gives the following error

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\php\process_character.php on line 40

 

my table v_disciplines exists with the fields player, disciplines and level. I've used it before with no problem and am using it in the current script with no problem except for here. 'USERNAME' is a placeholder during developement.

 

Link to comment
https://forums.phpfreaks.com/topic/129191-solved-simple-doublet-check-is-failing/
Share on other sites

You need to perform a query on the SQL statement. Here's the PHP Manual's example...

 

<?php

$link = mysql_connect("localhost", "mysql_user", "mysql_password");
mysql_select_db("database", $link);

//PERFORM QUERY
$result = mysql_query("SELECT * FROM table1", $link);
//PERFORM QUERY 
$num_rows = mysql_num_rows($result);

echo "$num_rows Rows\n";

?>

Thank you for the reply, this is of course true and a miss by me. however:

 

$result = mysql_query("SELECT * FROM v_disciplines WHERE username = 'USERNAME' AND discipline = '".$discipline."'");

$doublet_check = mysql_num_rows($result);

 

still produces the same error.

You said...

 

my table v_disciplines exists with the fields player, disciplines and level. I've used it before with no problem and am using it in the current script with no problem except for here. 'USERNAME' is a placeholder during developement.

 

So shouldn't you change it to...

 

$result = "SELECT * FROM v_disciplines WHERE username = 'USERNAME' AND disciplines = '".$discipline."'";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.