Jump to content


Photo

PHP & MySQL result processing: what am I doing wrong?


  • Please log in to reply
2 replies to this topic

#1 bugmuncher

bugmuncher
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 07 April 2006 - 09:10 AM

Hello, all. I believe I am a newbie.

In the following example, I'm trying to get 2 text fields out of my database, just to see what they are (and hopefully to use them!

I figured I would use mysql_fetch_assoc to make an array of pairs of orgName and orgSuggestedCopy.

But when I run the script, instead of getting whole records, I get "m" for both echos.

I think I am approaching this the wrong way.

--------------------

$query="SELECT orgName, orgSuggestedCopy FROM organizations WHERE oid='$firstSub'";
$result=mysql_query($query)
or die ("Error");

$debug="mysql_fetch_assoc($result)";
echo $debug['orgName'];
echo $debug['orgSuggestedCopy'];

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 07 April 2006 - 09:58 AM

Change this:
$debug="mysql_fetch_assoc($result)";
to:
$debug= mysql_fetch_assoc($result);


#3 roland

roland
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 08 April 2006 - 04:46 AM

[quote name='bugmuncher' date='Apr 7 2006, 04:10 AM' post='362463']
Hello, all. I believe I am a newbie.

In the following example, I'm trying to get 2 text fields out of my database, just to see what they are (and hopefully to use them!

I figured I would use mysql_fetch_assoc to make an array of pairs of orgName and orgSuggestedCopy.

But when I run the script, instead of getting whole records, I get "m" for both echos.

I think I am approaching this the wrong way.

--------------------

$query="SELECT orgName, orgSuggestedCopy FROM organizations WHERE oid='$firstSub'";
$result=mysql_query($query)
or die ("Error");

$debug="mysql_fetch_assoc($result)";
echo $debug['orgName'];
echo $debug['orgSuggestedCopy'];
[/quote]

Try this...
$query="SELECT orgName, orgSuggestedCopy FROM organizations WHERE oid='$firstSub'";
$result=mysql_query($query, $link)
or die ("Error");

while($debug="mysql_fetch_assoc($result)){
echo $debug['orgName'];
echo $debug['orgSuggestedCopy'];
}
[/quote]







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users