Jump to content

rocky48

Members
  • Posts

    261
  • Joined

  • Last visited

Everything posted by rocky48

  1. I run a query that queries the database to see if there are any events happening today and if so outputs the lines into a table. If there are no events it echos a message saying there are no events. The query works on my PC, but the version that runs on the iPad does not work. The php part of the web page is exactly the same, as I copied and pasted the whole PHP part of the code into the iPad version from the working version. Here is the code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="generator" content="CoffeeCup HTML Editor (www.coffeecup.com)"> <meta name="dcterms.created" content="Sat, 02 Mar 2013 20:21:23 GMT"> <meta name="description" content=""> <meta name="keywords" content=""> <meta name="viewport" content="width=768px, minium-scale=1.0, maximum-scale=1.0" /> <title></title> <link rel="stylesheet" href="stylesheets/ipad.css" /> <!--[if IE]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body> <div id="fb-root"></div> <!end fb-root> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <div id="wrap"> <!Start wrap> <div id="header"> <!Start header> <img src="images/BattleAbbeygatehouse.jpg" width="100" height="100" alt="" title="" border="0" /> <img src="images/1066Green.jpg" width="600" height="100" alt="" title="" border="0" /> </div> <!end header> <div id="content"> <!Start content> <div id="main"> <!Start main> <h1>WELCOME TO OUR SITE</h1> <p>We are passionate about card making and we would like to invite you to share your interests in card making with us.</br> </br> On our Website we have many interesting items on our site that we think will be of interest to you. <ul TYPE=SQUARE> <li>Some links to suppliers websites</li> <li>Many articles on card making techniques</li> <li>A unique utility which allows you to print greetings verse for your cards</li> <li>Database of nearly 1000 verses</li> <li>The ability to type in your own verse</li> <li>Videos on card-making techniques in our Gallery</li> <li>Feedback facility to allow visitors to comment on our site</li> </ul> </p> </br> <p>We hope that you will enjoy our site and you will visit us again SOON!</p> <br/> <h3> TODAYS RELIGIOUS & HISTORICAL EVENTS <br/> </h3> <br/> <div id= "php-code"> <! Start php-code> <?php include("RelHol_connect.php"); doDB(); //verify the Event exists $verify_Event_sql = "SELECT Events.ID, Events.Event_Date, Events.Event_Description, Religion.ID, Religion.Religion FROM Events LEFT JOIN Religion ON Events.Faith_ID = Religion.ID WHERE DAY(Events.Event_Date)= Day(Now()) And MONTH(Events.Event_Date)=Month(Now()) And YEAR(Events.Event_Date)=YEAR(Now()) ORDER BY Events.Event_Date ASC"; $verify_Event_res = mysqli_query($mysqli, $verify_Event_sql) or die(mysqli_error($mysqli)); if (mysqli_num_rows($verify_Event_res) < 1) { //this Event does not exist $display_block = "<p><em>No Religious festivals or holidays today.</em></p>"; } //gather the Events $get_Event_sql = "SELECT Events.ID, Events.Event_Date, Events.Event_Description, Events.Faith_ID, Religion.ID, Religion.Religion FROM Events LEFT JOIN Religion ON Events.Faith_ID = Religion.ID WHERE DAY(Events.Event_Date)= Day(Now()) And MONTH(Events.Event_Date)=Month(Now()) And YEAR(Events.Event_Date)=YEAR(Now()) ORDER BY Events.Event_Date ASC"; $get_Event_res = mysqli_query($mysqli, $get_Event_sql) or die(mysqli_error($mysqli)); //create the display string $display_block .= " <table width=\"100%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"#87CEEB\" > <tr> <th>RELIGION</th> <th>EVENT</th> </tr>"; while ($Event_today = mysqli_fetch_array($get_Event_res)) { $Rel_Date = $Event_today['Event_Date']; $Rel_Event = $Event_today['Religion']; $Event_text = ($Event_today['Event_Description']); //add to display $display_block .= " <tr> <td width=\"8%\" valign=\"top\">".$Rel_Event."<br/></td> <td width=\"25%\" valign=\"top\">" .$Event_text."<br/></td>"; } //free results mysqli_free_result($get_Event_res); //close connection to MySQL mysqli_close($mysqli); //close up the table $display_block .="</table>"; ?> </div> <! php-code> </div> <! No coresponding 'div' ??????> <br /><br /><br /> <div class="fb-like" data-href="http://www.1066cards4u.co.uk" data-send="true" data-layout="box_count" data-width="300" data-show-faces="true" data-font="arial"></div> <! end fb-like </div> <!end main> <div id="side"> <!Start side> <div id="sidea"> <!Start sidea> <h3>Main Menu</h3> <p><ul> <li><a href="index1.html">Home</a></li> <li><a href="iLinks.html">Links</a></li> <li><a href="iTechniques.html">Techniques</a></li> <li><a href="iVerse_Menu.html">Verse's</a></li> <li><a href="icontact.html">Contact Us</a></li> <li><a href="iNews.html">News</a></li> <li><a href="iAboutUs.html">About Us</a></li> <li><a href="iGallery.html">Gallery</a></li> <li><a href="iRegHol.html">Religious Holiday's</a></li> </ul></p> </br> </div> <!end sidea> <div id="sideb"> <!Start sideb> <h2 style="text-decoration:blink; color: red">NEWS FLASH!</h2> <!--<h4><font color="red">Just added! You can now type your own verses and print them!!</h4> --> <!--<h4><font color="red">NEW LOOK website!</br>Smarter looking site, but unfortunately as the Forum has not been used since the launch we have decided to remove it.</br>However if you have any ideas or suggestions please use the Feedback Form on the contact us tab.</h4>--> <h4><font color="blue">We have made many minor changes - so please see NEWS page for details (Bulletin #.</font> </h4> <h4><font color="blue"> </br>For instructions on how to use the Verse Printing Utility! SEE NEW INSTRUCTION PDF file. ( Version 2.9 - 28th November 2012)</font> </h4> <h4><font color="blue"></br>A form for adding verses has been added to the Contact Us page! </font> </h4> </div> <!end sideb> <div id="sidec"> <!Start sidec> </div> <!end sidec> </div> <!end side> </div> <!end content> <div id="footer"> <!Start footer> <p>© 2012 Content:1066 Cards 4U. All rights reserved. <br /> With thanks to Matt Taylor - matthewjamestaylor.com</p> </div> <!end footer> </div> <!end wrap> </body> </html> I thought it may be unequal Div tags so I have marked the start and end tags with comments and I found that there were unequal munber of tags, but when I removed the ofending tag it upset the layout of the screen. The sides a & b disappeared and the footer was at the bottom of thr side bar. The main content was in the right place, but again it does not print the output of the query. The Facebook content is shown OK. As an experiment I stripped the rest of the html content and div's and just left the php code plus some html to display the result and this output the query OK. I am sure the problem is with the DIV's, but I can't see where. Can anyone spot the error, cos I must be missing it?
  2. Don't understand what you mean? PHP is SERVER based and the code is run at the server end and the output is parsed to the local machine. Other PHP based scripts work on the iPad, it's just this one won't work and I can't see why. Does this make it any clearer?
  3. Hi trq The code is running on my ISP server. I have developed a version that can be viewed on an iPad screen. The index file in my case is index.php for the pc version and index1.php for the iPad version. There is a php code at the beginning of the PC version that redirects to the index1.php if an iPad is detected. The code above is within the html code on the home page. It's really wierd that the code that works on the PC does not work on the iPad! Any ideas are welcome.
  4. I run a query that queries the database to see if there are any events happening today and if so outputs the lines into a table. If there are no events it echos a message saying there are no events. The query works on my PC, but the version that runs on the iPad does not work. The php part of the web page is exactly the same, as I copied and pasted the whole PHP part of the code into the iPad version from the working version. Here is the PHP code: <?php include("RelHol_connect.php"); doDB(); //verify the Event exists $verify_Event_sql = "SELECT Events.ID, Events.Event_Date, Events.Event_Description, Events.Faith_ID, Religion.ID, Religion.Religion FROM Events LEFT JOIN Religion ON Events.Faith_ID = Religion.ID WHERE Events.Event_Date = Now() ORDER BY Events.Event_Date ASC"; $verify_Event_res = mysqli_query($mysqli, $verify_Event_sql) or die(mysqli_error($mysqli)); if (mysqli_num_rows($verify_Event_res) < 1) { //this Event does not exist $display_block = "<p><em>No Religious festivals or holidays today.</em></p>"; echo $display_block; }else { //gather the Events $get_Event_sql = "SELECT Events.ID, Events.Event_Date, Events.Event_Description, Events.Faith_ID, Religion.ID, Religion.Religion FROM Events LEFT JOIN Religion ON Events.Faith_ID = Religion.ID WHERE Events.Event_Date = Now() ORDER BY Events.Event_Date ASC"; $get_Event_res = mysqli_query($mysqli, $get_Event_sql) or die(mysqli_error($mysqli)); //create the display string $display_block .= " <table width=\"100%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"#87CEEB\" > <tr> <th>RELIGION</th> <th>EVENT</th> </tr>"; while ($Event_today = mysqli_fetch_array($get_Event_res)) { $Rel_Date = $Event_today['Event_Date']; $Rel_Event = $Event_today['Religion']; $Event_text = ($Event_today['Event_Description']); //add to display $display_block .= " <tr> <td width=\"8%\" valign=\"top\">".$Rel_Event."<br/></td> <td width=\"25%\" valign=\"top\">" .$Event_text."<br/></td>"; } //free results mysqli_free_result($get_Event_res); //close connection to MySQL mysqli_close($mysqli); //close up the table $display_block .="</table>"; } ?> Is the iPad treating the data diferently than the PC? I have cleared history on the iPad just incase it was caching the page. I'm puzzled!
  5. Corrected the fact that the queries were different. Also noticed that I had WHERE twice in the second query. Thanks mac_gyver! You gave me the clue to the solution the Echo $displayblock should have been put just after the error message as if this is true it does not action the second query and therefore does not print the error message if place where I originally had it.
  6. I copied the wrong WHERE code in my first code listing, but I have now put the modified WHERE code in both queries, but it does not print the text if the number of rows is <1. The first query is to catch this criteria and the second query will print any rows if there is any data tyo output for that date. I have modified as suggested, but it still does not print the message. For clarity I list the code as modified: <?php include("RelHol_connect.php"); doDB(); //verify the Event exists $verify_Event_sql = "SELECT Events.ID, Events.Event_Date, Events.Event_Description, Religion.ID, Religion.Religion FROM Events LEFT JOIN Religion ON Religion.ID = Faith_ID WHERE Events.Event_Date = CURDATE() ORDER BY Events.Event_Date ASC"; $verify_Event_res = mysqli_query($mysqli, $verify_Event_sql) or die(mysqli_error($mysqli)); if (mysqli_num_rows($verify_Event_res) < 1) { //this Event does not exist $display_block = "<p><em>No Religious festivals or holidays today.</em></p>"; }else { //gather the Events $get_Event_sql = "SELECT Events.ID, Events.Event_Date, Events.Event_Description, Events.Faith_ID, Religion.ID, Religion.Religion FROM Events LEFT JOIN Religion ON Events.Faith_ID = Religion.ID WHERE WHERE Events.Event_Date = CURDATE() ORDER BY Events.Event_Date ASC"; $get_Event_res = mysqli_query($mysqli, $get_Event_sql) or die(mysqli_error($mysqli)); //create the display string $display_block .= " <table width=\"100%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"#87CEEB\" > <tr> <th>RELIGION</th> <th>EVENT</th> </tr>"; while ($Event_today = mysqli_fetch_array($get_Event_res)) { $Rel_Date = $Event_today['Event_Date']; $Rel_Event = $Event_today['Religion']; $Event_text = ($Event_today['Event_Description']); //add to display $display_block .= " <tr> <td width=\"8%\" valign=\"top\">".$Rel_Event."<br/></td> <td width=\"25%\" valign=\"top\">" .$Event_text."<br/></td>"; } //free results mysqli_free_result($get_Event_res); //close connection to MySQL mysqli_close($mysqli); //close up the table $display_block .="</table>"; //echo $display_block; } ?> Any more ideas as to why it is not printing the message when there are no rows?
  7. Opps! I was using a wrong version of the query, so I modified it to: WHERE DAY(Events.Event_Date)= Day(Now()) And MONTH(Events.Event_Date)=Month(Now()) And YEAR(Events.Event_Date)=YEAR(Now()) It now does not print the table headers, but it does print the message, when there is no data!
  8. Hi DavidAnnis Don't understand why you say it does not check for the day? Without the code I am trying to add it works, and if there is any events today it iterates and fills the table with the events for today. If there are no events it just displays the table header. What I am trying to achieve is a message on the days there are no events. I will try the query on myphpadmin. My website is www.1066cards4u.co.uk and the code runs on the index page. There are no events today 14th July. For a list of when events are happenning there is a link on the menu. Lazro - I tried your code but it does not work with my DB. I am not an expert, but surely if there are multiple fields output by the query it would have to be an array? Hope this clarifies what I am trying to do!
  9. I am trying to code my script to display a message if the SQL query finds no results. I have used this snippet in a previous script and it works OK, but it does not work in this context. The SQL query looks for data with the same date of today, if it does it adds the data to a table. Here is part of the file where it does the querying: <?php include("RelHol_connect.php"); doDB(); //verify the Event exists $verify_Event_sql = "SELECT Events.ID, Events.Event_Date, Events.Event_Description, Religion.ID, Religion.Religion FROM Events LEFT JOIN Religion ON Religion.ID = Faith_ID WHERE MONTHNAME(Events.Event_Date)= MONTHNAME(Now()) And YEAR(Now()) ORDER BY Events.Event_Date ASC"; $verify_Event_res = mysqli_query($mysqli, $verify_Event_sql) or die(mysqli_error($mysqli)); if (mysqli_num_rows($verify_Event_res) < 1) { //this Event does not exist $display_block = "<p><em>No Religious festivals or holidays today.</em></p>"; }else { //gather the Events $get_Event_sql = "SELECT Events.ID, Events.Event_Date, Events.Event_Description, Events.Faith_ID, Religion.ID, Religion.Religion FROM Events LEFT JOIN Religion ON Events.Faith_ID = Religion.ID WHERE DAY(Events.Event_Date)= Day(Now()) And MONTH(Events.Event_Date)=Month(Now()) And YEAR(Events.Event_Date)=YEAR(Now())"; $get_Event_res = mysqli_query($mysqli, $get_Event_sql) or die(mysqli_error($mysqli)); //create the display string $display_block .= " <table width=\"100%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"#87CEEB\" > <tr> <th>RELIGION</th> <th>EVENT</th> </tr>"; while ($Event_today = mysqli_fetch_array($get_Event_res)) { $Rel_Date = $Event_today['Event_Date']; $Rel_Event = $Event_today['Religion']; $Event_text = ($Event_today['Event_Description']); //add to display $display_block .= " <tr> <td width=\"8%\" valign=\"top\">".$Rel_Event."<br/></td> <td width=\"25%\" valign=\"top\">" .$Event_text."<br/></td>"; } //free results mysqli_free_result($get_Event_res); //close connection to MySQL mysqli_close($mysqli); //close up the table $display_block .="</table>"; echo $display_block; } ?> The first part of the script from '//Verify the event exists' is the code I have added. Before I added this it just printed the table header, if there was no data or lines of data if there was data. Can anyone help?
  10. I am afraid it does not work like that! The POSTed Event_Type and Mood_Type are POSTed on the previous script and are part of the SQL query, which runs first. This then outputs the result as a table. I don't understand why you are saying 'you don't have any <input> tag in your html with that name'? Any way that is history now as the problem was the periods in front of method and action. I have another problem now! When I choose one of the lines in the table and submit using POST then create a SESSION called Test, which saves the result of the POST into the SESSION and proceed to the next script nothing is printed on the screen. Here is the small script I am using to test the output: <? session_start(); echo $_SESSION[Test]; echo $_POST[$VID]; ?> Any ideas why I am not getting the data stored in SESSION?
  11. Hi But Event_Type is only required to satisfy the SQL query, it is nothing to do with the form which is dealing with the OUTPUT from the query. I am not too sure about the periods as somebody in a previous post suggested them. I will remove them!
  12. I did not quite know how to label this post hence the unusual title. I am trying to modify some code that I have written to save the choosen line that is output from an SQL query, using SESSION to make it available in a later script. To achieve this I have started a form with a radio button inside the while loop that outputs the query items that meet the criteria set by a form in the previous script. Before I modified this script it worked albeit without the choice coding. When I submit the choices on the previous script the query is run and it ouputs the results as a table, with an extra column which contains a radio button. I have for test purposes output the value of the variable to check that the variable is storing the value correctly. When I choose a line that the query has output and clcked on the submit button it seems to be causing the code to think it has not got an Event set and displays the error message "You have selected an invalid Event. Please try again.", on line 21 which is part of the code I wrote to make sure that an Event has been choosen, instead of proceeding on to the next script. Here is the complete script: <?php session_start(); include("cverse_connect.php"); doDB(); //check for required info from the query string //verify the Event exists $verify_Event_sql = "SELECT ID, Event_Type FROM Events WHERE ID = '".$_POST["Event_Type"]."'"; $verify_Event_res = mysqli_query($mysqli, $verify_Event_sql) or die(mysqli_error($mysqli)); echo $_POST["Event_Type"]; echo $_POST["Mood"]; if (mysqli_num_rows($verify_Event_res) < 1) { //this Event does not exist $display_block = "<p><em>You have selected an invalid Event.<br/> Please try again.</em></p>"; } else { //get the Event ID while ($Event_info = mysqli_fetch_array($verify_Event_res)) { $Event_ID = stripslashes($Event_info['ID']); $Event_Name = ($Event_info['Event_Type']); } $verify_Mood_sql = "SELECT ID, Event_Sub_Type FROM Event_Sub WHERE ID = '".$_POST["Mood"]."'"; $verify_Mood_res = mysqli_query($mysqli, $verify_Mood_sql) or die(mysqli_error($mysqli)); if (mysqli_num_rows($verify_Mood_res) < 1) { //this Event does not exist $display_block = "<p><em>You have selected an invalid Mood.<br/> Please try again.</em></p>"; } while($Mood_info = mysqli_fetch_array($verify_Mood_res)) { $Mood_ID = ($Mood_info['ID']); $Mood_Name = ($Mood_info['Event_Sub_Type']); } //gather the Events $get_Event_sql = "SELECT Verses.ID AS versesID, Verses.Verse, Verses.Sub_Type, Verses.Event, Events.ID AS eventsID, Events.Event_Type, Event_Sub.ID AS event_SubID, Event_Sub.Event_Sub_Type FROM Verses LEFT JOIN Events ON Verses.Event = Events.ID LEFT JOIN Event_Sub ON Verses.Sub_Type = Event_Sub.ID WHERE Verses.Event = '".$_POST["Event_Type"]."' And Verses.Sub_Type = '".$_POST["Mood"]."' ORDER BY Verses.ID ASC"; $get_Event_res = mysqli_query($mysqli, $get_Event_sql) or die(mysqli_error($mysqli)); //create the display string $display_block .= " <table width=\"70%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"#87CEEB\" > <tr> <th>ID</th> <th>VERSE</th> <th>MOOD/SUB TYPE</th> </tr>"; while ($Verse_info = mysqli_fetch_array($get_Event_res)) { $Verse_id = $Verse_info['versesID']; $Verse_text = nl2br(stripslashes($Verse_info['Verse'])); $Mood_info = $Verse_info['Event_Sub_Type']; $VID = $Verse_id; //add to display $display_block .= " <tr> <td width=\"1%\" valign=\"top\">".$Verse_id."<br/></td> <td width=\"55%\" valign=\"top\">".$Verse_text."<br/></td> <td width=\"35%\" valign=\"top\">" .$Mood_info."<br/></td> <td width=\"35%\" valign=\"top\"> <form .method=.\"POST\" .action=\"VInput1.php\"> <input type=\"Radio\" value=\"$VID\"> $VID </td></tr>"; } $display_block.="<input type=submit value=Choose Verse>"; //free results mysqli_free_result($get_Event_res); mysqli_free_result($verify_Event_res); //close connection to MySQL mysqli_close($mysqli); //close up the table $display_block .= "</table>"; } $_session['Test']=$_POST[$VID] ?> <html> <head> <title> List of Verses</title> <meta charset="utf-8"> <meta name="Description" content="Ecologic Theme"> <meta name="author" content="CoffeeCup Software, Inc."> <meta name="Copyright" content="Copyright (c) 2011 CoffeeCup, all rights reserved."> <title>1066 Cards 4U - Home</title> <link rel="stylesheet" href="stylesheets/default.css" /> <!--[if IE]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body> <header> <h1><a href="index.html"> ..............</a></h1></br></br></br></br> <div><img src="images/1066Green.jpg" width="600" height="80" alt="" title="" border="0" /></div> </header> <section id="mainContent" class="clear"> <nav> <h3>Main Menu</h3> <ul> <li><a href="index.html">Home</a></li> <li><a href="Links.html">Links</a></li> <li><a href="Techniques.html">Techniques</a></li> <li><a href="Alt_inputform.html">Verse's</a></li> <li><a href="contact.html">Contact Us</a></li> <li><a href="News.html">News</a></li> <li><a href="Gallery.html">Gallery</a></li> </ul> </nav> <section id="mainRight2"> <h1>Verses</h1> <?php echo $display_block; ?> </section> <footer> <p>© 2011 Ecologic, Inc. All rights reserved. <a href="http://coffeecup.com">HTML Editor Theme</a> by CoffeeCup Software.</br> © 2012 Content:1066 Cards 4U. All rights reserved. </p> <ul> <li><a href="index.html">Home</a></li> <li><a href="Links.html">Links</a></li> <li><a href="Techniques.html">Techniques</a></li> <li><a href="Alt_inputform.html">Verse's</a></li> <li><a href="contact.html">Contact Us</a></li> <li><a href="News.html">News</a></li> <li><a href="Gallery.html">Gallery</a></li> </ul> </footer> </body> </html> Can anybody see why it is doing this?
  13. Hi Jessica I have tried it and it works! Thanks for your help! Barand Can't understand why I would want to compare the YEAR_MONTH FROM Event_Date to the Current date. The idea is to be able to list events from next year by month.
  14. Hi I had deduced that what you have said was happening, but what about the code I had suggested! Will it work? Thanks for the sugestion on how to format the date.
  15. Hi Jessica Thanks solved it! Realised that the $_POST was a string not a date, so removed the MONTHNAME(). Not sure that the YEAR(Now()) was doing anything, so I removed it and it still works! If I wanted to include the year would this work after the And: YEAR(Events.Event_Date) = '".$_POST["Year"]."' Also How do I get the date to display in European format i.e. dd:mm:yyyy?
  16. Hi I am trying to code, to select for a particular month events that are happening during the chosen month. The month is chosen using a HTML drop-down list and POSTing the result in the PHP file. I first tried without the select parameter using NOW() and it worked fine. This the code for this: <?php include("RelHol_connect.php"); doDB(); $get_Event_sql = "SELECT Events.ID, Events.Event_Date, Events.Event_Description, Religion.ID, Religion.Religion FROM Events LEFT JOIN Religion ON Religion.ID = Faith_ID WHERE MONTHNAME(Events.Event_Date)= MONTHNAME(Now()) And YEAR(Now()) ORDER BY Events.Event_Date ASC"; $get_Event_res = mysqli_query($mysqli, $get_Event_sql) or die(mysqli_error($mysqli)); //create the display string $display_block = "<h2> <table width=\"100%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"#87CEEB\" > <tr> <th>Date</th> <th>Event</th> <th>Faith</th> </tr>"; while ($Event_info = mysqli_fetch_array($get_Event_res)) { $Event_Date = $Event_info['Event_Date']; $Event_text = nl2br(stripslashes($Event_info['Event_Description'])); $Faith = $Event_info['Religion']; //add to display $display_block .= " <tr> <td width=\"5%\" valign=\"top\">DATE FORMAT(".$Event_Date.",%d %m %Y)</td> <td width=\"30%\" valign=\"top\">".$Event_text."</td> <td width=\"15%\" valign=\"top\">" .$Faith."</td> </tr>"; } //free results mysqli_free_result($get_Event_res); //close connection to MySQL mysqli_close($mysqli); //close up the table $display_block .= "</table>"; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <meta charset="utf-8"> <meta name="Description" content="Ecologic Theme"> <meta name="author" content="CoffeeCup Software, Inc."> <meta name="Copyright" content="Copyright (c) 2011 CoffeeCup, all rights reserved."> <title>1066 Cards 4U - Religious Holidays</title> <link rel="stylesheet" href="stylesheets/default.css" /> <!--[if IE]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body> <header> <h1><a href="index.html"> ..............</a></h1></br></br></br></br> <div><img src="images/1066Green.jpg" width="600" height="80" alt="" title="" border="0" /></div> </header> <section id="body"> <h1>Religious Holidays & Festivals</h1> <?php echo $display_block; ?> </section> </body> </html> When I modified the code to introduce the html selection, all I get are the headers displayed. There are no errors reported, so I guess that the query format is wrong! Here is the modified code: <?php include("RelHol_connect.php"); doDB(); echo $_POST["Month"]; $get_Event_sql = "SELECT Events.ID, Events.Event_Date, Events.Event_Description, Religion.ID, Religion.Religion FROM Events LEFT JOIN Religion ON Religion.ID = Faith_ID WHERE MONTHNAME(Events.Event_Date) = MONTHNAME('".$_POST["Month"]."') And YEAR(Now()) ORDER BY Events.Event_Date ASC"; $get_Event_res = mysqli_query($mysqli, $get_Event_sql) or die(mysqli_error($mysqli)); //create the display string $display_block = "<h2> <table width=\"100%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"#87CEEB\" > <tr> <th>Date</th> <th>Event</th> <th>Faith</th> </tr>"; while ($Event_info = mysqli_fetch_array($get_Event_res)) { $Event_Date = $Event_info['Event_Date']; $Event_text = nl2br(stripslashes($Event_info['Event_Description'])); $Faith = $Event_info['Religion']; //add to display $display_block .= " <tr> <td width=\"5%\" valign=\"top\">DATE FORMAT(".$Event_Date.",%d %m %Y)</td> <td width=\"30%\" valign=\"top\">".$Event_text."</td> <td width=\"15%\" valign=\"top\">" .$Faith."</td> </tr>"; } //free results mysqli_free_result($get_Event_res); //close connection to MySQL mysqli_close($mysqli); //close up the table $display_block .= "</table>"; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <meta charset="utf-8"> <meta name="Description" content="Ecologic Theme"> <meta name="author" content="CoffeeCup Software, Inc."> <meta name="Copyright" content="Copyright (c) 2011 CoffeeCup, all rights reserved."> <title>1066 Cards 4U - Religious Holidays</title> <link rel="stylesheet" href="stylesheets/default.css" /> <!--[if IE]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body> <header> <h1><a href="index.html"> ..............</a></h1></br></br></br></br> <div><img src="images/1066Green.jpg" width="600" height="80" alt="" title="" border="0" /></div> </header> <section id="body"> <h1>Religious Holidays & Festivals</h1> <?php echo $display_block; ?> </section> </body> </html> Can anyone spot where I am going wrong? I a novice programmer.
  17. Hi DaveyK Don't understand what point you are trying to make! What's your solution then!
  18. Hi Tried changing to php extension but did not work, just got a blank page. Have never used mod_rewrite which I understand is an Apache utility. I don't know what server my ISP uses, but am checking with them. How do you make the webserver parse the html page as php?
  19. Hi I am trying to include a script that I have tested on its own (and works fine), into the index.html page of my website. I am placing it in an Aside (on the left), when I run this on my ISP test folder it does not work. It displays the code from the first row of the table to the heading in the following html code. I can't spot anything obvious, so what is causing this error. This is the code I am running: <!--<?php require_once('mobile_device_detect.php'); mobile_device_detect('http://www.1066cards4u.co.uk/index1.html','http://www.1066cards4u.co.uk/index1.html','http://www.1066cards4u.co.uk/index1.html',false,'http://www.1066cards4u.co.uk/index1.html','http://www.1066cards4u.co.uk/index1.html','http://www.1066cards4u.co.uk/index1.html','http://www.1066cards4u.co.uk/index1.html',false); ?>--> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="Description" content="Ecologic Theme"> <meta name="author" content="CoffeeCup Software, Inc."> <meta name="Copyright" content="Copyright (c) 2011 CoffeeCup, all rights reserved."> <link rel="shortcut icon" href="favicon.ico" > <link rel="icon" type="image/gif" href="animated_favicon1.gif" > <title>1066 Cards 4 U - Home</title> <link rel="stylesheet" href="stylesheets/default.css" /> <!--[if IE]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <header> <h1><a href="index.html"> ..............</a></h1></br></br></br></br> <div><img src="images/1066Green.jpg" width="600" height="80" alt="" title="" border="0" /></div> </header> <section id= "sidebarR" class= clear> <asideR> <?php include("RelHol_connect.php"); doDB(); $get_Event_sql = "SELECT Events.ID, Events.Event_Date, Events.Event_Description, Religion.ID, Religion.Religion FROM Events LEFT JOIN Religion ON Religion.ID = Faith_ID WHERE MONTHNAME(Events.Event_Date)= MONTHNAME(Now()) ORDER BY Events.Event_Date ASC"; $get_Event_res = mysqli_query($mysqli, $get_Event_sql) or die(mysqli_error($mysqli)); //create the display string $display_block = " <table width=\"30%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"#87CEEB\"> <tr> <th>Date</th> <th>Event</th> <th>Faith</th> </tr>"; while ($Event_info = mysqli_fetch_array($get_Event_res)) { $Event_Date = $Event_info['Event_Date']; $Event_text = nl2br(stripslashes($Event_info['Event_Description'])); $Faith = $Event_info['Religion']; //add to display $display_block .= " <tr> <td width=\"5%\" valign=\"top\">".$Event_Date."</td> <td width=\"30%\" valign=\"top\">".$Event_text."</td> <td width=\"15%\" valign=\"top\">".$Faith."</td> </tr>"; } //free results mysqli_free_result($get_Event_res); //close connection to MySQL mysqli_close($mysqli); //close up the table $display_block .= "</table>"; ?> <h2>Religious Holidays & Festivals</h2> <?php echo $display_block; ?> </asideR> </section> <section id= "sidebarL" class= clear> <asideL> <div class="fb-like" data-href="http://www.1066cards4u.co.uk" data-send="true" data-layout="box_count" data-width="300" data-show-faces="true" data-font="arial"></div> </asideL> </section <section id="mainContent" class="clear"> <nav> <h3>Main Menu</h3> <p><ul> <li><a href="index.html">Home</a></li> <li><a href="Links.html">Links</a></li> <li><a href="Techniques.html">Techniques</a></li> <li><a href="Verse_Menu.html">Verse's</a></li> <li><a href="contact.html">Contact Us</a></li> <li><a href="News.html">News</a></li> <li><a href="AboutUs.html">About Us</a></li> <li><a href="Gallery.html">Gallery</a></li> <li><a href="index1.html">iPad users</a></li> </ul></p> </br> <h2 style="text-decoration:blink; color: red">NEWS FLASH!</h2> <h4><font color="red">I have been working on an iPad version of the web site, which is almost ready to roll. However if you have an iPad and want to use this you can access it by clicking on the link above or in the page footer (Sometimes the main link does not work). I am trying to solve some coding problems that auto detects mobile devices, which will automatically redirect to the iPad code.</h4> <!--<h4><font color="red">NEW LOOK website!</br>Smarter looking site, but unfortunately as the Forum has not been used since the launch we have decided to remove it.</br>However if you have any ideas or suggestions please use the Feedback Form on the contact us tab.</h4>--> <h4><font color="blue">We have made many minor changes - so please see NEWS page for details (Bulletin #.</font> </h4> <h4><font color="blue"> </br>For instructions on how to use the Verse Printing Utility! SEE NEW INSTRUCTION PDF file. ( Version 2.9 - 28th November 2012)</font> </h4> <h4><font color="blue"></br>A form for adding verses has been added to the Contact Us page! </font> </h4> </nav> <section id="mainLeft"> <div><img src="images/B1012F.jpg" width="250" height="250" alt="" title="" border="0" /> </div> <br /> <h1>Welcome to our site</h1> </br> <p>We are passionate about card making and we would like to invite you to share your interests in card making with us.</br> </br> On our Website we have many interesting items on our site that we think will be of interest to you. <ul TYPE=SQUARE> <li>Some links to suppliers websites</li> <li>Many articles on card making techniques</li> <li>A unique utility which allows you to print greetings verse for your cards</li> <li>Database of nearly 1000 verses</li> <li>The ability to type in your own verse</li> <li>Videos on card-making techniques in our Gallery</li> <li>Feedback facility to allow visitors to comment on our site</li> </ul> </p> </br> <p>We hope that you will enjoy our site and you will visit us again SOON!</p> </section> <!-- end mainLeft --> </section> <!-- end mainContent --> <footer> <p>© 2011 Ecologic, Inc. All rights reserved. <a href="http://coffeecup.com">HTML Editor Theme</a> by CoffeeCup Software.</br> © 2012 Content:1066 Cards 4U. All rights reserved. </p> <ul> <li><a href="index.html">Home</a></li> <li><a href="Links.html">Links</a></li> <li><a href="Techniques.html">Techniques</a></li> <li><a href="Verse_Menu.html">Verse's</a></li> <li><a href="contact.html">Contact Us</a></li> <li><a href="News.html">News</a></li> <li><a href="AboutUs.html">About Us</a></li> <li><a href="Gallery.html">Gallery</a></li> <br /> <li><a href="index1.html">iPad users</a></li> </ul> </footer> </br> </br> </br> </br> </body> </html> The added code is in red.
  20. Thanks for the offer but it is now working OK!
  21. Hi I have edited as in reply 1 and it still does not output the count! I removed the while loop, so why is it not outputting the value now????
  22. Hi I have been improving my code and decided I would let the users know how many records of a particular Event there were when the SELECT query was run. The SQL works fine, but when I add it into the display block I use to display the pre text and then the table no output from the count variable is displayed. However I put an echo before the display block and it does output the correct number. Here is a snippet of the code that is causing the problem: $Count_sql = "SELECT Event, COUNT(Sub_Type) FROM Verses WHERE Event='".$_POST["Event_Type"]."'"; $Count_res = mysqli_query($mysqli, $Count_sql) or die(mysqli_error($mysqli)); while ($Count_Event = mysqli_fetch_array($Count_res)) { echo "There are ".$Count_Event['COUNT(Sub_Type)']; } //create the display string $display_block = " <p> The Event Type is: <b> ".$Event_Name."</b> </p> [color=#ff0000]<p> Number of Verses for this event Type:<b> </p> ".$Count_Event['COUNT(Sub_Type)']."</b> [/color] <table width=\"70%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"#87CEEB\" > <tr> <th>ID</th> <th>VERSE</th> <th>MOOD/SUB TYPE</th> </tr>"; The sentence before is displyed but the ".$Count_Event['COUNT(Sub_Type)']." is not displayed. Where am I going wrong?
  23. Thanks for the input! I am a relatively new programmer and not that young anymore, so apoligies for my ignorance! With all the comments that ChristianF made I am now overwelmed with the issues regarding the coding. The script worked when I input a number in a text input form, which is the script that runs before the final script, so I know that the query to the database works OK. I know that the coding is not that well written and may not be that secure, but it worked before I tried to modify it to choose the verse within the table in the PHP script I listed first. I have taken your advice and changed the line: $_SESSION['ID'] = $Event_info['ID']; , but the ID value is not picked up by the final script. If I can get this working then I will look at making the script more secure. Any more suggestions?
  24. I have written a script that queries a MYSQL database and the query is output as a table. In this table I have managed to add a 'Radio' button to each row of the table. When I submit I want the value stored for use in a later script. I have been avised that the best way to do this is using $_SESSION. Here is the script that outputs the query: <?php include("Loc_cverse_connect.php"); doDB(); Session_start(); //verify the Event exists $verify_Event_sql = "SELECT ID, Event_Type FROM Events WHERE ID = '".$_POST["Event_Type"]."'"; $verify_Event_res = mysqli_query($mysqli, $verify_Event_sql) or die(mysqli_error($mysqli)); //echo $_POST["Event_Type"]; if (mysqli_num_rows($verify_Event_res) < 1) { //this Event does not exist $display_block = "<p><em>You have selected an invalid Event.<br/> Please try again.</em></p>"; } else { //get the Event ID while ($Event_info = mysqli_fetch_array($verify_Event_res)) { $Event_ID = stripslashes($Event_info['ID']); $Event_Name = ($Event_info['Event_Type']); } //gather the Events $get_Event_sql = "SELECT Verses.ID AS versesID, Verses.Verse, Verses.Sub_Type, Verses.Event, Events.ID AS eventsID, Events.Event_Type, Event_Sub.ID AS event_SubID, Event_Sub.Event_Sub_Type FROM Verses LEFT JOIN Events ON Verses.Event = Events.ID LEFT JOIN Event_Sub ON Verses.Sub_Type = Event_Sub.ID WHERE Verses.Event = '".$_POST["Event_Type"]."' ORDER BY Verses.ID ASC"; $get_Event_res = mysqli_query($mysqli, $get_Event_sql) or die(mysqli_error($mysqli)); //create the display string $display_block = " <p> The Event Type is <b> '".$Event_Name."'</b> </p> <table width=\"70%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"#87CEEB\" > <tr> <th>ID</th> <th>VERSE</th> <th>MOOD/SUB TYPE</th> <th>Link</th> </tr>"; while ($Verse_info = mysqli_fetch_array($get_Event_res)) { $Verse_id = $Verse_info['versesID']; $Verse_text = nl2br(stripslashes($Verse_info['Verse'])); $Mood_info = $Verse_info['Event_Sub_Type']; //add to display $display_block .= " <tr> <td width=\"1%\" valign=\"top\">".$Verse_id."<br/></td> <td width=\"55%\" valign=\"top\">".$Verse_text."<br/></td> <td width=\"35%\" valign=\"top\">".$Mood_info."<br/></td> <td width=\"9%\" valign=\"top\"> <form action=\"VInput2.html\" ".method."=\"post\"> <input type=\"Radio\" name=\"ID\" value=\"".$Verse_id."\"/> </td> </tr>"; } //free results mysqli_free_result($get_Event_res); mysqli_free_result($verify_Event_res); //close connection to MySQL mysqli_close($mysqli); //close up the table $display_block .= " <input type=\"submit\" value=\"SUBMIT\"> </form> </table>"; } $_SESSION[iD]=".$_POST."; ?> <html> <head> <title> List of Verses</title> </head> <body BGCOLOR="#87CEEB"> <h1>Verses</h1> <?php echo $display_block; ?> </body> </html> I have tried putting the $_SESSION in various places, but it does not pass the value to the final script. I reliased that the line had to be put outside of the loop, otherwise it displayed the ID number of the last row in the query. Here is the final script where I am trying to use the value: <?php include("loc_cverse_connect.php"); doDB(); Session_start(); //Get the Card Variables $Get_Size_sql = "SELECT * FROM `csize` WHERE `Size` ='".$_POST["CSize"]."'"; $Get_Size_res = mysqli_query($mysqli, $Get_Size_sql) or die(mysqli_error($mysqli)); if (mysqli_num_rows($Get_Size_res) < 1) { //this Card does not exist $display_block = "You have selected an invalid Card size. Please try again."; } else { //get the print variables while ($Size_info = mysqli_fetch_array($Get_Size_res)) { $BoxX = stripslashes($Size_info['BoxX']); $Cellw = stripslashes($Size_info['Cellw']); $Cellh = stripslashes($Size_info['Cellh']); $SizeI = stripslashes($Size_info['Size']); $SID = stripslashes($Size_info['SID']); $floatx = stripslashes($Size_info['floatx']); $floaty = stripslashes($Size_info['floaty']); $floatw = stripslashes($Size_info['floatw']); $floath = stripslashes($Size_info['floath']); $ort = stripslashes($Size_info['ort']); } //create the display string $display_block = "$ort"; } //check the variable is being passed through //if (isset($_SESSION['ID'])){ //echo 'ID is '.$_SESSION['ID']; //} //Goto end; //verify the Event exists $Get_Verse_sql = "SELECT ID, Event, Sub_Type, Verse FROM Verses WHERE ID = '".$_SESSION["ID"]."'"; $Get_Verse_res = mysqli_query($mysqli, $Get_Verse_sql) or die(mysqli_error($mysqli)); if (mysqli_num_rows($Get_Verse_res) < 1) { //this Event does not exist $display_block = "You have selected an invalid Event. Please try again."; } else { //get the Event ID while ($Verse_info = mysqli_fetch_array($Get_Verse_res)) { $Verse = stripslashes($Verse_info['Verse']); } //create the display string $display_block = "$Verse"; //free results mysqli_free_result($Get_Verse_res); mysqli_free_result($Get_Size_res); //close connection to MySQL } mysqli_close($mysqli); require('fpdf.php'); class PDF extends FPDF { var $B; var $I; var $U; var $HREF; function PDF($orientation='P', $unit='mm', $size='A4') { // Call parent constructor $this->FPDF($orientation,$unit,$size); // Initialization $this->B = 0; $this->I = 0; $this->U = 0; $this->HREF = ''; } function SetStyle($tag, $enable) { // Modify style and select corresponding font $this->$tag += ($enable ? 1 : -1); $style = ''; foreach(array('B', 'I', 'U') as $s) { if($this->$s>0) $style .= $s; } $this->SetFont('',$style); } } $color = $_POST[color]; $r = substr($color,0,3); $g = substr($color,3,3); $b = substr($color,6,3); $image=$_POST[image]; $pdf = new PDF($ort,'mm','A4'); $pdf->AddPage(); $pdf->AddFont('French Script MT','','frscript.php'); $pdf->AddFont('Batavia','','Batavia_.php'); $pdf->AddFont('Algerian','','Alger.php'); $pdf->AddFont('Bladerunner','','BLADRMF_.php'); $pdf->AddFont('Brush Script','','BRUSHSCI.php'); $pdf->AddFont('Helterskelter','','Helte___.php'); $pdf->AddFont('Justice','','Justice_.php'); $pdf->AddFont('Magneto','','MAGNETOB.php'); $pdf->AddFont('Old English','','OldEngl.php'); $pdf->AddFont('Sneakerhead Outline','','Sneabo__.php'); $pdf->AddFont('Trendy','','Trendy__.php'); $pdf->AddFont('Vladimir Script','','VLADIMIR.php'); $pdf->SetTextColor($r,$g,$b); $pdf->SetFont($_POST[fontface],'',$_POST[font]); $pdf->SetXY($BoxX, $_POST[Top]); $pdf->Image($image,$floatx,$floaty,$floatw,$floath,jpg,''); $pdf->MultiCell($Cellw,$Cellh,$display_block,'' ,'C'); $pdf->SetFont(''); $pdf->Output('verse.pdf','D'); //end: ?> The query output the text that shows that no ID number has been pased to the query. Can anyone help me?
  25. The original questionhas now been solved. The submit had to be outside of the loop. I have another problem, be this is PHP question, so will submit a post there.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.