Jump to content

Mysql doesn't like my string...

- - - - -

  • Please log in to reply
1 reply to this topic

#1
bbqroast

bbqroast

    Codecall Addict

  • Members
  • PipPipPipPipPipPipPip
  • 554 posts
  • Location:/etc/passwd
	$statData = mysql_query("SELECT * FROM `netstats` WHERE `player` = $profileIGN");

	if ($statData == false)	{

		echo 'This user has not been recorded yet :(';

	} else {

		$broken = mysql_result($statData, 0, 'broken');

		echo "This player has broken $broken blocks, <br>";

	}
Having connected to the database selected my database, and even run some other queries (which were successful) I run this code.
$statData is ALWAYS set to false!
If you really want me to I could post a picture of the database, I clearly see that $profileIGN has been set to bbqr0ast, and that a entry in the MySQL table is there.

I even tried changing the `player` part to ID and changing $profileIGN to 1, that worked fine...
I'm guessing MySQL doesn't like my string, anyone know why?
Please, write clearly with proper structure. Double spacing makes the text feel un-jointed, Capitalizing Every Word Means People Stop Before Every Word Sub-Consciously Which Is A Pain In The Backside, and use code tags! (The right most styling box).

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
Ah, the venerable string. Try this:
"SELECT * FROM `netstats` WHERE `player` = [B]'[/B]$profileIGN[B]'[/B]"
It is assumed to not be of a string constant if not in quotes, rather a macro function or other data type.

You could always test queries in mysql program, or PHPMyAdmin, or check mysql_error() for last returned error and it would likely throw a syntax issue.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users