Help - Search - Members - Calendar
Full Version: Unknown Column 'id' In 'order Clause' Username Id
Zymic Webmaster Forums > Zymic Free Web Hosting > Zymic Free Web Hosting - General Discussion & Help
PHP_student
Ok, I hope I am posting in the right section unsure.gif

I keep getting this error on my page:

CODE
Unknown column 'ID' in 'order clause'
UserName ID


I have no idea what is wrong. I am good at fixing most errors in my script after they are pointed out, but this one just baffles me.

Here is the full code:

CODE
<?php
$con = mysql_connect("localhost","hidden","hidden");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("altapets_zxq_dbtables", $con);
$result = mysql_query("SELECT * FROM members ORDER BY ID");

echo "<table border='0'>
<tr>
<th>UserName</th>
<th>ID</th>
</tr>";


$sql = "SELECT * FROM users ORDER BY ID";


$result = mysql_query($sql) or die(mysql_error());

while($row = mysql_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['UserName'] . "</td>";
echo "<td>" . $row['ID'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>


It is a script that will show a list of all registered members. Please note that the "hidden" is just so I don't give away my database username and password, as I use them for almost all things.
Ed
The column names are case sensitive, so ensure the column 'ID' exists in your table.
PHP_student
I do, don't I?
Ed
QUOTE(PHP_student @ Sep 30 2009, 07:22 PM) *
I do, don't I?


Not sure why you're asking me, I don't know your database table schema.
PHP_student
Oh! It is in my database table. I thought it was in the code
PHP_student
I thought I fixed it but when I checked my page again I still had that error.

Here is the database code:

CODE
SELECT COUNT(*) AS `Rows`, `userid` FROM `users` GROUP BY `userid` ORDER BY `userid`
Ed
What's the table schema?

PHP_student
Tables:

active_guests
active_users
banned_users
messages
users

I will be using users. So I click on 'structure' of users and...

...you see this:

username
password
userid
userlevel
email
timestamp

I'm using userid. The code in it is the code of my post above ^^^
PHP_student
I'm going to have to take a good review at all of my code and see what is wrong
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.