n!ch0
2010-10-31 22:34:07 UTC
EDIT USER PAGE:
When I did this a year ago, and I wanted to print out all the data from the table, I used the while loop. When I wanted to only grab certain variables from a table, I just created a new set of variables, as show below. Using the same method from a year ago, I started working on printing various data to the screen (such as "Welcome $username"). 5 minutes of typing... refresh page... nada.
So I stripped away just about every tag but the essentials and it still wouldn't work
=======================================================================
...
$userID = 3;
$sql = "SELECT * FROM users WHERE userID='$userID'";
$result = mysql_query($sql);
$rows = mysql_fetch_row($result);
echo $rows['username'];
...
=======================================================================
Normally, this would just grab the username from a row in Table users where the userID = 3
But instead - it does nothing. I just see a blank page. It's a simple 5 lines of code and it's like "im just gonna do w.e the fk i wanna do mmmk thxforplaying"
PS: Keep in mind there is nothing wrong with the connection to the database, and I'm able to print ALL values in a while loop, but I can't grab single values