Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help php return undefineded value in actionscript

    Hi I having problem here how come the uid is undefined value on the actionscripts? the uname is able to be display but the uid is undefinded but I don't know why it return undefinded value? uid is the id of the username like eg: 1,2,3


    PHP Code:
    PHP Code:

    $resultpostal
    =mysql_query("SELECT location.uname,location.uid FROM location,districts WHERE districts.districtno ='$postalno' AND 
    location.lat BETWEEN districts.startlat AND districts.endlat AND location.lng BETWEEN districts.startlng AND districts.endlng"
    ); 

    $counterx=0
    while(
    $row=mysql_fetch_array($resultpostal)){ 
    foreach(
    $row as $col_value){ 
    $temp[$counterx]=$col_value
    $counterx++; 



      
    $report.="uid"."=".$temp[0]."&"
      
    $report.="uname"."=".$temp[1]."&"



      echo 
    $report
    Anybody know?

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    That is a really poor way to get results out of a query. Why are you using a foreach() array, assigning each individual array value to another array, then referring to this second array? Why not just use the first array?

    Also you may as well use a "for" loop, as it takes care of the iterator for you (makes the code cleaner than a "while" loop).

    PHP Code:
    for ($counterx 0$counterx mysql_num_rows($resultpostal); $counterx++) {
        
    $row[$counterx] = mysql_fetch_array($resultpostal);
    }

    //Array is ready for you to do whatever you want with it
    foreach($row as $rowval) {
       
    $report.="uid"."=".$rowval['uid']."&uname"."=".$rowval['uname']."&";
    }

    echo 
    $report


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •