Jump to content

Recommended Posts

hi there,

 

I\'m new and just coming down from the elation of getting mysql_connect to actually work.

 

I\'m having trouble with mysql_fetch_array and I can\'t see why. I have used the code below to link to the DB:

 

$db = mysql_select_db($database,$connection) or die (\"Couldn\'t select database.\");

$query = \"SELECT loginname FROM dantest\";

$result = mysql_query($query) or die(\"Couldn\'t execute query!\");

$row = mysql_fetch_array($result,MYSQL_ASSOC);

echo $row[\'password\'];

 

The problem is that $row, when echoed, returns the word \'array\' and not the name that I expected. I want to compare the loginname to another variable butI have clearly done something daft!

 

Any help would be greatly appreciated!

 

Cheers

 

Dan


Link to comment
https://forums.phpfreaks.com/topic/1126-resolved-mysql_fetch_array-problem/
Share on other sites

pardon me for being an idiot!

 

I have found the (rather obvious) error through the tried and tested method of staring hard at screen. I was trying to reference another column from within the array. As I only asked for one specific row of info (loginname) asking for $row[\'password\'] was never going to work!

 

Thanks for your time and patience

 

Dan

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.