dmccabe Posted March 31, 2008 Share Posted March 31, 2008 Please help me out I am having a complete brain fart here: $aid = $_GET['aid']; $query = "SELECT * FROM `tbl_corpaccount` WHERE `aid` = $aid"; $result = mysql_query($query); if (!mysql_query($query)) { die('Error: ' . mysql_error()); } echo $query; $accname = $result['accname']; $accname is never containing a value. but why? I have run the query on my db and it works fine. Link to comment https://forums.phpfreaks.com/topic/98787-brain-fart/ Share on other sites More sharing options...
atl_andy Posted March 31, 2008 Share Posted March 31, 2008 Don't you need to fetch the results first? while($row = mysql_fetch_row($result) { echo $row['accname']; // Or whatever you need to do with it. } Or you could use mysql_fetch_assoc or mysql_fetch_array Link to comment https://forums.phpfreaks.com/topic/98787-brain-fart/#findComment-505494 Share on other sites More sharing options...
Bladescope Posted March 31, 2008 Share Posted March 31, 2008 *tweak* <?php // ... while($row = mysql_fetch_row($result)) { echo $row['accname']; // Or whatever you need to do with it. } // ... ?> Link to comment https://forums.phpfreaks.com/topic/98787-brain-fart/#findComment-505497 Share on other sites More sharing options...
dmccabe Posted March 31, 2008 Author Share Posted March 31, 2008 hmmm... still nothing $aid = $_GET['aid']; $query = "SELECT * FROM `tbl_corpaccount` WHERE `aid` = $aid"; $result = mysql_query($query); while($row = mysql_fetch_row($result)) { echo "1.".$row['accname']; Link to comment https://forums.phpfreaks.com/topic/98787-brain-fart/#findComment-505533 Share on other sites More sharing options...
Bladescope Posted March 31, 2008 Share Posted March 31, 2008 using mysql_fetch_row, use $result[0]; as opposed to $result['accname']; Edit: If you're using that script and it's coming up with nothing, then it's your SQL query. Link to comment https://forums.phpfreaks.com/topic/98787-brain-fart/#findComment-505536 Share on other sites More sharing options...
clown[NOR] Posted March 31, 2008 Share Posted March 31, 2008 maybe this'll work? while($row = mysql_fetch_assoc($result)) { Link to comment https://forums.phpfreaks.com/topic/98787-brain-fart/#findComment-505537 Share on other sites More sharing options...
dmccabe Posted March 31, 2008 Author Share Posted March 31, 2008 That makes no sense? $result instead of row? and I how do I pull a value from it? $result[0]['accname'] ? Link to comment https://forums.phpfreaks.com/topic/98787-brain-fart/#findComment-505539 Share on other sites More sharing options...
dmccabe Posted March 31, 2008 Author Share Posted March 31, 2008 link=topic=190145.msg853500#msg853500 date=1206964366] maybe this'll work? while($row = mysql_fetch_assoc($result)) { We have a winner Link to comment https://forums.phpfreaks.com/topic/98787-brain-fart/#findComment-505540 Share on other sites More sharing options...
clown[NOR] Posted March 31, 2008 Share Posted March 31, 2008 wow! what did i win? Link to comment https://forums.phpfreaks.com/topic/98787-brain-fart/#findComment-505546 Share on other sites More sharing options...
dmccabe Posted March 31, 2008 Author Share Posted March 31, 2008 A big thanks Link to comment https://forums.phpfreaks.com/topic/98787-brain-fart/#findComment-505553 Share on other sites More sharing options...
clown[NOR] Posted March 31, 2008 Share Posted March 31, 2008 woho your welcome Link to comment https://forums.phpfreaks.com/topic/98787-brain-fart/#findComment-505608 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.