monkeybidz Posted February 15, 2008 Share Posted February 15, 2008 Can I get information from a var that is defined further down in the code to work in the whole page without redefining it or make it work at the top of the page or code? Quote Link to comment Share on other sites More sharing options...
mem0ri Posted February 15, 2008 Share Posted February 15, 2008 Sounds like you need to be working in JavaScript. PHP won't allow you to dynamically manipulate code like that...once it's run through, it's run through until the page is refreshed. Quote Link to comment Share on other sites More sharing options...
Steve Angelis Posted February 15, 2008 Share Posted February 15, 2008 What do you mean? I would call it up at the beginning from the database, would be easiest if you don't want to recall it later, and then just echo it or do whatever you want to with it later on. Quote Link to comment Share on other sites More sharing options...
monkeybidz Posted February 15, 2008 Author Share Posted February 15, 2008 I will try to move the query to the top. There is so many query's on that page, that I hope it does not conflict with others by me moving it up. Quote Link to comment Share on other sites More sharing options...
mem0ri Posted February 15, 2008 Share Posted February 15, 2008 If you'd like to post code maybe we can help clean up some of your queries? You really shouldn't need to have more than a couple of queries on any given page. Quote Link to comment Share on other sites More sharing options...
monkeybidz Posted February 15, 2008 Author Share Posted February 15, 2008 Here is the main query that is returning $current_bid as empty. This is why I wanted to grab another var to define this one. Maybe there is something I am missing here: <?php $query = "select id, title, pict_url, photo_uploaded, current_bid, starts from PHPAUCTION_auctions WHERE closed='0' AND suspended=0 AND private='n' AND starts<=".$NOW." ORDER BY starts DESC LIMIT ".$SETTINGS['lastitemsnumber']; $result = mysql_query($query); if ($result) { $num_auction = mysql_num_rows($result); } else { $num_auction = 0; } $i = 0; $current_bid = mysql_result($result, $i, "current_bid"); ?> Quote Link to comment Share on other sites More sharing options...
haku Posted February 15, 2008 Share Posted February 15, 2008 Your query is not formed properly, which is almost definitely why you are getting an empty result. Echo the query, and you should be able to quickly see where the formatting problems are. Quote Link to comment Share on other sites More sharing options...
monkeybidz Posted February 15, 2008 Author Share Posted February 15, 2008 How would I go about that? Quote Link to comment Share on other sites More sharing options...
aschk Posted February 15, 2008 Share Posted February 15, 2008 I can't actually see anything wrong with the query. However, where does $NOW and $SETTINGS['lastitemsnumber'] come from? You can replace $NOW with the MySQL variant. $query = "select id, title, pict_url, photo_uploaded, current_bid, starts from PHPAUCTION_auctions WHERE closed='0' AND suspended=0 AND private='n' AND starts <= NOW() ORDER BY starts DESC LIMIT ".$SETTINGS['lastitemsnumber']; Quote Link to comment Share on other sites More sharing options...
monkeybidz Posted February 15, 2008 Author Share Posted February 15, 2008 I am looking in to a possible non insertion to current_bid from another page. I will post back. Quote Link to comment Share on other sites More sharing options...
monkeybidz Posted February 16, 2008 Author Share Posted February 16, 2008 Problem was another file not inserting anythin to table. Thanks guys. 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.