drums Posted October 30, 2009 Share Posted October 30, 2009 I created a new dB that is simpler with 13 fields but there must be a conflict because I get no errors or data. So I make a query for each of the 5 data entry spots on the page. Do I need to close it or something? I can't figure what else the problem could be... <? $query = mysql_query("select * from xlsdata where spot='1st'") or die("SQL error: " . mysql_error());if (FALSE === ($record = mysql_fetch_array($query))){ } ?> <h2><?php echo $record['date-event']; ?></h2> <p><?php echo $record['beginning']; ?> <blockquote> <?php if(!empty($record['bullet1'])) echo "<li>".$record['bullet1']."</li>"; ?> <?php if(!empty($record['bullet2'])) echo "<li>".$record['bullet2']."</li>"; ?> <?php if(!empty($record['bullet3'])) echo "<li>".$record['bullet3']."</li>"; ?> <?php if(!empty($record['bullet4'])) echo "<li>".$record['bullet4']."</li>"; ?> <?php if(!empty($record['bullet5'])) echo "<li>".$record['bullet5']."</li>"; ?> <?php if(!empty($record['bullet6'])) echo "<li>".$record['bullet6']."</li>"; ?> <?php if(!empty($record['bullet7'])) echo "<li>".$record['bullet7']."</li>"; ?> <?php if(!empty($record['bullet8'])) echo "<li>".$record['bullet8']."</li>"; ?> <?php if(!empty($record['bullet9'])) echo "<li>".$record['bullet9']."</li>"; ?> </blockquote> <?php echo $record['end']; ?></p> <? $query = mysql_query("select * from xlsdata where spot='2nd'") or die("SQL error: " . mysql_error());if (FALSE === ($record = mysql_fetch_array($query))){ } ?> <h2><?php echo $record['date-event']; ?></h2> <p><?php echo $record['beginning']; ?> <blockquote> <?php if(!empty($record['bullet1'])) echo "<li>".$record['bullet1']."</li>"; ?> <?php if(!empty($record['bullet2'])) echo "<li>".$record['bullet2']."</li>"; ?> <?php if(!empty($record['bullet3'])) echo "<li>".$record['bullet3']."</li>"; ?> <?php if(!empty($record['bullet4'])) echo "<li>".$record['bullet4']."</li>"; ?> <?php if(!empty($record['bullet5'])) echo "<li>".$record['bullet5']."</li>"; ?> <?php if(!empty($record['bullet6'])) echo "<li>".$record['bullet6']."</li>"; ?> <?php if(!empty($record['bullet7'])) echo "<li>".$record['bullet7']."</li>"; ?> <?php if(!empty($record['bullet8'])) echo "<li>".$record['bullet8']."</li>"; ?> <?php if(!empty($record['bullet9'])) echo "<li>".$record['bullet9']."</li>"; ?> </blockquote> <?php echo $record['end']; ?></p> <? $query = mysql_query("select * from xlsdata where spot='3rd'") or die("SQL error: " . mysql_error());if (FALSE === ($record = mysql_fetch_array($query))){ } ?> ... to spot='5th' Quote Link to comment https://forums.phpfreaks.com/topic/179690-solved-cant-i-have-2-queries-on-a-page/ Share on other sites More sharing options...
DavidAM Posted October 31, 2009 Share Posted October 31, 2009 You have short tags ("<?") around the queries but full tags ("<?php") around the other code. It may be that your server is configured not to allow short tags. In that case, they are being ignored by the PHP processor and sent to the browser. The browser will ignore them because they are an unknow HTML tag (since they start with "<"). Always use full tags ... <?php Also, turn on error reporting so you can see any errors you get. So the beginning of every php file should be: <?php error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/179690-solved-cant-i-have-2-queries-on-a-page/#findComment-948157 Share on other sites More sharing options...
Stuie_b Posted October 31, 2009 Share Posted October 31, 2009 Try the following... <?php $spots = array ("1st","2nd","3rd","4th","5th"); foreach($spots as $spot) { $query = mysql_query("select * from xlsdata where spot='$spot'") or die("SQL error: " . mysql_error()); $record = mysql_fetch_array($query); $count = mysql_num_rows($query); ?> Returned <h2><?php echo $count; ?></h2> Rows <h2><?php echo $record['date-event']; ?></h2> <p><?php echo $record['beginning']; ?> <blockquote> <?php if(!empty($record['bullet1'])) echo "<li>".$record['bullet1']."</li>"; ?> <?php if(!empty($record['bullet2'])) echo "<li>".$record['bullet2']."</li>"; ?> <?php if(!empty($record['bullet3'])) echo "<li>".$record['bullet3']."</li>"; ?> <?php if(!empty($record['bullet4'])) echo "<li>".$record['bullet4']."</li>"; ?> <?php if(!empty($record['bullet5'])) echo "<li>".$record['bullet5']."</li>"; ?> <?php if(!empty($record['bullet6'])) echo "<li>".$record['bullet6']."</li>"; ?> <?php if(!empty($record['bullet7'])) echo "<li>".$record['bullet7']."</li>"; ?> <?php if(!empty($record['bullet8'])) echo "<li>".$record['bullet8']."</li>"; ?> <?php if(!empty($record['bullet9'])) echo "<li>".$record['bullet9']."</li>"; ?> </blockquote> <?php echo $record['end']; ?></p> <?php } ?> Tbh the only changes where to put everything into one place instead of duplicating code and i added a line to show how many (if any) rows where returned.. This should ensure you are getting a return from mysql, also as DavidAM says make sure the correct error report levels are set and short tags are phrased.. Stuie Quote Link to comment https://forums.phpfreaks.com/topic/179690-solved-cant-i-have-2-queries-on-a-page/#findComment-948158 Share on other sites More sharing options...
drums Posted October 31, 2009 Author Share Posted October 31, 2009 SaaWEEEEET!!!! I came back to say I fixed it and saw what you had. Very nice, thanks so much. Quote Link to comment https://forums.phpfreaks.com/topic/179690-solved-cant-i-have-2-queries-on-a-page/#findComment-948177 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.