Jump to content

[resolved] Stupid code is not working


spare

Recommended Posts

Hello,

Could somebody please help me.  This is just about to drive me crazy.  I have been beating my head for countless hours over the past two days. 

I am trying to add one of those annoying algorythim images to a registration page.  I have a db table with fields named id, code, and codename.

I want a random selection of a 'codename' (also the name of an image in a folder).  The results of the 'codename' will, via a switch, display the matching image. The related 'code' field will be required to match what the visitor has entered in the text field on the registration page or else an error message.

The basic query works on PHPMyAdmin but the results won't echo on the registration page and echo as 'empty' when I run it on another page.

[code]
$regcd= "SELECT * FROM ".$glob['dbprefix']."ATC_humanreg WHERE id >0 ORDER BY RAND() LIMIT 1";

$results=$db->mySQLsafe($regcd[0]['codename']);

echo '<pre>';
print_r($regcd);
echo '</pre>';
echo '<pre>';
print_r($results);
echo '</pre>';
[/code]
This is what I get back
[quote]SELECT * FROM ATC_humanreg WHERE id >0 ORDER BY RAND() LIMIT 1

''[/quote]
When I try
[code]
$regcd = "SELECT codename FROM ".$glob['dbprefix']."ATC_humanreg WHERE id >0 ORDER BY RAND() LIMIT 1";

$results=$db->mySQLsafe($regcd[0]['codename']);

echo '<pre>';
print_r($results);
echo '</pre>';
[/code]
I get this
[quote]''[/quote]
Why are the query result not appearing?  What am I doing wrong?

I appreciate any help or suggestions.
Link to comment
https://forums.phpfreaks.com/topic/18346-resolved-stupid-code-is-not-working/
Share on other sites

[quote author=thorpe link=topic=105244.msg420319#msg420319 date=1156286745]
$regcd is a string... you define it yourself. You then try and reference it as some sort of multidimensional array. $regcd[0]['codename'] Whats with that?
[/quote]
The onset of complete burnout. :P 

I'm getting it..... Oookay.  I got it. 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.