MySQL query...Weird Parse error

A

Anonymous

Guest
Code:
$query = "SELECT * FROM members WHERE rank =  .$_GET['rank'] . ";

Ok, I tried having it like " .$_GET['rank'] . " but that didn't work....what's wrong with my query? The rank is picked up by the URL.
 
HaVoC said:
Code:
$query = "SELECT * FROM members WHERE rank =  .$_GET['rank'] . ";

It looked like you tried to use string concatenation inside quotation marks. This is what you wanted, probably:

Code:
$query = 'SELECT * FROM members WHERE rank =  ' . $_GET['rank'];
 
Amazing....such a simple mistake....anyways, it only lists 1 of the user instead of all of them. How would I make it list ALL the names in 'name'?
 
HaVoC said:
How would I make it list ALL the names in 'name'?

To list every record, just skip the WHERE clause.

Code:
SELECT * FROM members;
 
Yes, but I want it to list everyone with the rank 1.

So
if ($rank == 1)
fgdfgdfg
echo("$name");
I got it to print the name, but only 1, I want it to print all the names with the rank 1, or 2 or 3 ect.
 
Then this is what you want:

Code:
SELECT * FROM members WHERE rank = 1;

If it's not working, then there's something funky with your records or your query. Check them.
 
Ok for that query, do I use single or double quotes. And do I put
WHERE rank = 1, the 1 in single quotes? And also there's 13 ranks. Do I have to make a page for each rank??
 
I'm sorry, Havoc, but we can't teach you everything. I recommend that you go buy/beg/borrow a current PHP/MySQL book or see extensive (i.e. read at least a half-dozen) tutorials on the web. There's a lot of basic stuff that you're obviously missing (Stringsand Expressions, for example), and it would kill us if we tried to hold your hand through all of that.
 
please learn some basic SQL!! :D would help you a lot

even i did it the same way...

learnt php but was unaware of SQL capabilities ... finally had to learn SQL
 
The big mistake that many PHP newbies (and book authors!) make is trying to dive right into MySQL before they even know the basics of PHP. You should be very comfortable with PHP before you start trying to tackle complex extensions like MySQL and GD. That means completing a couple medium-sized projects from start to finish.
 
Back
Top