adamhhh Posted February 21, 2007 Share Posted February 21, 2007 hi guys been wondering over this for a little while and cant figure it out. Basically Im including the file below, where I use a query to extract some data. This file is included in another file and the results returned. This works fine however Im having trouble returning the results and getting a field in this file below. I can return the results and then get the results in the other file, but not in the same one. So: $query111 = "SELECT * FROM places WHERE place_id = 5559"; $result111 = mysql_query($query111) or die ("The system doesn't like your login details- please try again with different ones."); $row111 = mysql_fetch_assoc($result111); return $row111; $place_id2 = $row111['place_id']; So I cant return row111 and get something from it. Any ideas? Link to comment https://forums.phpfreaks.com/topic/39450-probably-a-silly-problem/ Share on other sites More sharing options...
dead_elves Posted February 21, 2007 Share Posted February 21, 2007 It's a shot in the dark, but where is $result111 being returned from? If it's from within a function and you use the same variable names, you might end up with scoping issues. Also, I've found that if an array is initially used within a control structure (if, for, etc), you have to declare it outside the control structure in order to use it again outside the control structe (ie. return it). EDIT: obviously you'd have to declare the variable before you used it in the if, for, whatever. Link to comment https://forums.phpfreaks.com/topic/39450-probably-a-silly-problem/#findComment-190355 Share on other sites More sharing options...
redarrow Posted February 21, 2007 Share Posted February 21, 2007 try this please ok. <?php $query111= "SELECT * FROM `places` WHERE `place_id` = '5559' "; $result111=mysql_query($query111) or die ("The system doesn't like your login details- please try again with different ones. mysql_error()"); $row111 = mysql_fetch_assoc($result111); return $row111; $place_id2 = $row111['place_id']; ?> Link to comment https://forums.phpfreaks.com/topic/39450-probably-a-silly-problem/#findComment-190359 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.