spare Posted August 22, 2006 Share Posted August 22, 2006 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. Quote Link to comment Share on other sites More sharing options...
trq Posted August 22, 2006 Share Posted August 22, 2006 $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 Link to comment Share on other sites More sharing options...
spare Posted August 23, 2006 Author Share Posted August 23, 2006 [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 Quote Link to comment Share on other sites More sharing options...
trq Posted August 23, 2006 Share Posted August 23, 2006 [quote]I'm getting it..... Oookay. I got it.[/quote]Does that mean the thread is resolved? Ive marked it so... please do so yourself in the future. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.