Here is a tricky one that im having issues with...

I have a page called events.php that has a include to query sql and pull events from the database after todays date and include the artist information from a include file. here is the code. The events page has a include of events2.php...

<?php
$con = mysql_connect("hostname","username","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("database", $con);
$today = date("Y-m-d");
$result = mysql_query("SELECT * FROM events where Date > '$today' limit 0,4");
   while ($row = mysql_fetch_array($result)) {
   echo "<?include ('";
   echo $row['IncFile'];
   echo "');?>";
   echo '<div class="clear"></div><BR>';
   }
   mysql_close($con);
?>
</td>
</tr>
</table>

the above creates the name of the include file to include. And it does so when viewing the source code for event.php it shows the following

<?include ('events/Event-Showdown.inc');?><div class="clear"></div><BR>
<?include ('events/Event-TOW.inc');?><div class="clear"></div><BR>
<?include ('events/Event-Jamie-Davis.inc');?><div class="clear"></div><BR>
<?include ('events/Event-Postal-Monkey.inc');?><div class="clear"></div><BR>

However it doesnt show the data within such as below. all it shows is a blank. I would asume that insead of seeing the above code I should be seeing the below within the events.php what am i doing wrong.

<!-- Showdown -->
<? $thisevt = event('June 30th','Showdown','http://www.myspace.com/ShowdownOrlandoFL',
'Showdown plays Country music, and a little <br>sprinkle off Classic Rock here and there.<br>
<br>Members:
Willy Bouton: Bass Guitar and Vocals
Danny Evans: Drums
Bill Posten: Keyboards
Billy Varnes: Lead Guitar and Vocals<br>
<em>Excerpt from the <a href="http://www.myspace.com/ShowdownOrlandoFL" target="new_frame">Showdown Website.</a></em>',
'Showdown.png','image','yes');
echo $thisevt;
?>
<!-- END Showdown -->

Recommended Answers

All 5 Replies

Instead of:

echo "<?include ('";
echo $row['IncFile'];
echo "');?>";

do:

include "{$row['IncFile']}";

Well it got a little better. Now i get the following. and the error on line 20 is the

include "{$row['IncFile']}";

Warning: main(/Events/Events-Dan-Story-Band.inc) [function.main]: failed to open stream: No such file or directory in C:\Websites\www\Mysitename.com\www\concerts-events2.php on line 20

Warning: main() [function.include]: Failed opening '/Events/Events-Dan-Story-Band.inc' for inclusion (include_path='.;c:\php4\pear') in C:\Websites\www\Mysitename.com\www\concerts-events2.php on line 20

that would indicate the include file is not being created

the include file exist in C:\Websites\www\Mysitename.com\www\events\Events-Dan-Story-Band.inc. So im not sure what is going on.

Failed opening '/Events/Events-Dan-Story-Band.inc'

The first slash points back to the webroot. So I think it is trying to open C:\Websites\www\events\Events-Dan-Story-Band.inc

Try removing the first slash.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.