Joseph Longo
asked on
SQL: Query Not Working
Hello,
For whatever reason, I cannot get this query to work:
Any ideas as to why?
For whatever reason, I cannot get this query to work:
<?php
$sql = "SELECT * FROM states ORDER BY state ASC";
$result = mysql_query($db_connect, $sql);
if (mysql_num_rows($result) > 0) {
while($row = mysql_fetch_assoc($result)){
?>
<option value="<?php echo $row["state"]; ?>" ><?php echo $row["state"]; ?></option>
<?php
}
}
?>
</select>
Any ideas as to why?
Are you getting any error?
Hi,
Does the table exist? Is the connection working fine? Please remove ASC in your query.
Does the table exist? Is the connection working fine? Please remove ASC in your query.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Apparently, for whatever reason the query doesn't work on my computer at home. I have an old MacBook Pro ---like 11 years old, which is running an older version of PHP. However, once I upload my scripts from my older machine to a newer machine and use mysqli, the script works as is. So, no worries. Thanks everyone for their assistance.
I would love to have an old MacBook Pro!
Glad things are looking up. Best of luck with your project, ~Ray
Glad things are looking up. Best of luck with your project, ~Ray