View Full Version : Adding another php/mysql program on the same page
donmarvin
08-30-2004, 08:30 PM
The calendar works great and is fabulous. But I added to the same page another php program which accesses the same database (but different table) and now the list of events that appears below the calendar only shows the first letter of the Title. :cry: Everything else is fine including the mouseover which shows the entire Title. Coincidentally, my other table also has a field named Title.
Does anyone know -- do I have to have these two programs on separate pages or is there a way to have them both?
Thanks.
Brian
08-30-2004, 08:32 PM
Can you post or PM me a link to your page?
donmarvin
08-30-2004, 08:34 PM
http://setonshrine.com/bulletin.php
donmarvin
08-30-2004, 08:37 PM
Also, here is the same page but with just the calendar minus the other program. The titles come out fine.
http://setonshrine.com/calendar.php
Brian
08-30-2004, 08:41 PM
Your demo page works as expected, so there must be something on that page causing this problem. What's interesting is that the variable that prints the event title is unset before the script ever executes so it should be blank.
Additionally, if I look at the next month, one of the events shows up correctly?
There is no function to limit the length of the title string, so I don't know what may be causing this. Let me ponder on this a bit...
donmarvin
08-30-2004, 08:47 PM
Brian, I just realized something. The only event on the calendar whose Title did not get cut off after the first letter is the Mass For Labor, a single event. All the other events are recurring. It must have something to do with that.
Brian
08-30-2004, 08:49 PM
What does this other script on the page do?
donmarvin
08-30-2004, 08:50 PM
Yes, that's it. I just changed the Feast of the Assumption from a Recurring Event to a Single Event and now the title displays in whole.
Brian
08-30-2004, 08:51 PM
Yes, that's it. I just changed the Feast of the Assumption from a Recurring Event to a Single Event and now the title displays in whole.
What about a floating event? It uses the same variables as recurring events do...
donmarvin
08-30-2004, 08:53 PM
The other script is for the "News and Announcements". Any current News items in the database are displayed on the page before the calendar.
donmarvin
08-30-2004, 08:59 PM
I just added a floating event for the first Sunday of October. Only the first letter of the title appears just as with the Recurring Events.
Brian
08-30-2004, 09:02 PM
Add this just below the <?php line in showCalendar.php:
unset($title);
Does that help?
donmarvin
08-30-2004, 09:12 PM
It didn't work. If it's a conflict with the field names I can easily change the field name in the other program.
Is there something wrong with the code I used in the other program? It's my first attempt at PHP so it might not be right:
<?php
$connection=mysql_connect(IIII,****,****);
if (!$connection) {
echo "Could not connect to MySql server!";
exit;
}
$db=mysql_select_db("setonshrine",$connection);
if (!$db) {
echo "Could not select database";
exit;
}
$today = date("Y-m-d");
$sql="SELECT * FROM events WHERE expiry >= '$today' ORDER BY id";
$mysql_result=mysql_query($sql,$connection);
$num_rows=mysql_num_rows($mysql_result);
if ($num_rows > 0)
{
echo "<P class='olive2' align='left'>News and Announcements</p>";
while ($row=mysql_fetch_array($mysql_result))
{
$title=$row["title"];
$description=$row["description"];
$description2=$row["description2"];
$description3=$row["description3"];
$website=$row["website"];
$email=$row["email"];
echo "<p class='grey'> • <b>$title</b><p>";
echo "<blockquote>$description</blockquote>";
if ($description2 != "")
{
echo "<blockquote>$description2</blockquote>";
}
if ($description3 != "")
{
echo "<blockquote>$description3</blockquote>";
}
if ($website != "" or $email != "")
{
echo "<blockquote>Further info: ";
if ($website != "")
{
echo "<a href='$website' target=_blank>Website</a> ";
}
if ($email != "")
{
echo "<a href='mailto:$email'>Email</a>";
}
echo "</blockquote>";
}
} //while row
echo "<HR><BR>";
} // if have results
mysql_close($connection);
?>
Brian
08-30-2004, 11:11 PM
I don't see anything in there that would cause this...
Can you change the $title variable to something like $titlex?
donmarvin
08-31-2004, 06:02 AM
It works perfectly now! :banana:
Thank you, Brian! :thanks:
donmarvin
08-31-2004, 09:04 AM
BTW, FYI, using unset($title); prevented me from being able to add any new events. An alert box would appear saying the title field was empty.
vBulletin® v3.8.4, Copyright ©2000-2013, Jelsoft Enterprises Ltd.