Jump to content

Recommended Posts

So I've been using PHP to query MySQL dbs for a while now and have never had this happen to me. All of a sudden I cannot get the data to display using my normal code.

This no longer works:
[code]
<?

mysql_connect("localhost", "db_user", "pass") or die("Could not connect");
mysql_select_db("db_name") or die("Could not select database");

$result = mysql_query("SELECT * FROM `users` WHERE `username`='admin' ") or die(mysql_error());
$row = mysql_fetch_row($result);

echo $row[username];

?>
[/code]

But this does:
[code]
<?

mysql_connect("localhost", "db_user", "pass") or die("Could not connect");
mysql_select_db("db_name") or die("Could not select database");

$result = mysql_query("SELECT * FROM `users` WHERE `username`='admin' ") or die(mysql_error());
$row = mysql_fetch_row($result);

echo $row[1];

?>
[/code]

I've triple checked that "username" is "username" in the db. I'm at a total loss. What would cause this all of a sudden?
Link to comment
https://forums.phpfreaks.com/topic/10019-weird-goings-on/
Share on other sites

[!--quoteo(post=375273:date=May 19 2006, 08:44 AM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ May 19 2006, 08:44 AM) [snapback]375273[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Use the mysql_fetch_assoc() function, not the mysql_fetch_row() function.

Ken
[/quote]

doh!

I'll crawl back into my hole now....
Link to comment
https://forums.phpfreaks.com/topic/10019-weird-goings-on/#findComment-37208
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.