Jump to content

rocky48

Members
  • Posts

    261
  • Joined

  • Last visited

Everything posted by rocky48

  1. Still the same errors. Here is the Code i used to test the code: <?php define ($conn,"",false); $sql=""; $qry=""; $res=""; $ret=""; include("connect_Verses4Cards_LOCAL.php"); $conn=get_db_conn_verse(); function buildSelectOptions($name, array $options, $current=null){ $htmlString = "<select name='{$name}' id='{$name}'>\n"; $htmlString .= "\t<option value='-1'> -- Please select -- </option>\n"; foreach($options as $value=>$option){ $htmlString .= "\t<option value='{$value}'"; if($value == $current){ $htmlString .= " selected"; } $htmlString .= ">{$option}</option>\n"; } $htmlString .= "</select>\n"; return $htmlString; } function getEvents(){ $qry = "SELECT id ,Event_Type FROM Events ORDER BY id"; $sql = mysqli_query($conn, $qry); if(mysqli_num_rows($sql) < 1){ return array(); } while($res = mysqli_fetch_array($sql)){ $ret[$res['id']] = $res['Event_Type']; } return $ret; } function getMoods(){ $qry = "SELECT id ,Event_Sub_Type FROM Event_Sub ORDER BY id"; $sql = mysqli_query($conn, $qry); if(mysqli_num_rows($sql) < 1){ return array(); } while($res = mysqli_fetch_array($sql)){ $ret[$res['id']] = $res['Event_Sub_Type']; } return $ret; } echo buildSelectOptions('event', getEvents(), $_GET['event']); echo buildSelectOptions('mood', getMoods(), $_GET['mood']); ?> <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <?php echo buildSelectOptions('event', getEvents($conn), $_GET['event']); echo buildSelectOptions('mood', getMoods($conn), $_GET['mood']); ?> </body> </html> I still dont understand where event and mood are defined?
  2. I have tried your code and am geting a lot of errors! One thing you assumed the second table was called mood, but it is actually called Event_Type. I know you are going to say its bad identification, but I stuck with it. The name in the table is Event_Sub_Type. Mainly they are notices and warnings. This one occurs five times: Notice: Undefined variable: conn in C:\wamp\www\1066mk4\Local_Test\Event_test.php on line 2 which in turn cause: Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\wamp\www\1066mk4\Local_Test\Event_test.php on line 31 and Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\wamp\www\1066mk4\Local_Test\Event_test.php on line 32 In the buildselectoptions you have as the first index event and mood. Where are they defined? As for defining variables do you use define() or do you use $conn=""; ? Thanks!
  3. Of the dropdown menu!! I see you create a common function and then run that function for each of the queries! Do you mean mysqli_close()? The original code has run succesfully for the past year on my website, without any errors. I will try your suggested code and see what happens!
  4. I was shown how to create a dropdown list created from a database last year, the only trouble is that the first line is blank. Can you have one of the items selected, like you do in a normal html list? Here is the code: //Function to build select options based on passed array $Events = array($Events_info['id'], $Events_info['Event_Type']); buildSelectOptions($Events); function buildSelectOptions($options) { $optionsHTML = "<select name=\"Event\">\r\n"; foreach($options as $id => $label) { $optionsHTML .= "<option value='{$id}'>{$label}</option>\n"; } return $optionsHTML; } //Run query to get the ID and Name from the table //Then populate into an array $clist_sql = "SELECT id, Event_Type FROM Events ORDER BY id"; $clist_res= mysqli_query($conn, $clist_sql) or die(mysqli_error($conn)); if (mysqli_num_rows($clist_res) < 1) { //this Event not exist $display_block = "<p><em>You have selected an invalid Event.<br/> Please try again.</em></p>"; } $Events = array(); while($Events_info = mysqli_fetch_array($clist_res)) { $Events [$Events_info['id']] = $Events_info['Event_Type']; } $EventOptions = buildSelectOptions($Events); //Function to build select options based on passed array $Mood = array($Mood_info['id'], $Mood_info['Event_Sub_Type']); buildSelectOptions1($Mood); function buildSelectOptions1($options) { $optionsHTML1 = "<select name=\"Mood\">\r\n"; foreach($options as $id => $label) { $optionsHTML1 .= "<option value='{$id}'>'{$label}'</option>\n"; } return $optionsHTML1; } Your help would be appreciated!
  5. I feel a right idiot! I should have realised that if a file has any PHP in it it should have a php extension. The revealed code should have made me realise this! Now the file has the correct extension all is revealed! Thanks for pointing me in the right direction!
  6. I meant to have said only index (Home) and Links have been changed using database menu.
  7. I am also struggling to explain what is happening. I can't duplicate the problem on my live site as it is only running PHP v 5.2, but I will try when I have time to transfer the database there. Having said that it works on the second tab, that is no longer true, as when I booted up my computer today, only the index.php file worked. The following is what is printed on the sreen: Menu error."; echo $display_block; }else { while($menu_items = mysqli_fetch_array($menu_res)){ $item=$menu_items['Url']; echo $item; } //free results mysqli_free_result($menu_res); //close connection to MySQL mysqli_close($conn); ?> You say that for this code to be run there must be no data rows in the table, but as the select query is the same for each tab/page. when a query is run does the system lock the table, so that if it is run again it can't find any data? I have cleared the result and closed the table, is that not sufficient? I have update the database to test url is: www.1066cards4u.co.uk/test
  8. The point is that the above code works as I said in the index.php file and also if I select the next tab 'Links.html' on the index page (see my webpage quoted above), but subsequent tabs DOES run the check on line 46 including all lines after the 'Menu error' message to the end of the code are printed to the screen. The data on my database is still the same so why is it not finding any records on the 3rd and subsequent tabs?To clarify, all these tests have been done from the index.php menu tabs. As for your second statement, the code I am running is as shown above. This is substituted for the normal unordered list in all of the files that have this menu. I am not running another while loop! If you examine the code on the live site it may become clearer. I'm running the code I am developing on Localhost.
  9. Thanks it works BUT! It works on the index.php (Home) and the next tab Links.html, but all subsequent tabs are going through the error coding that detects more than 0 rows are in the query. The select query obviously runs on the new page, so it because the query runs from the output of another query? It seems ilogical that it runs in the second tab, I would have expected that it would only work in the index.php tab! Here is the modified code: <?php include ("connect_Menu_LOCAL.php"); $conn = get_db_conn_Menu(); $menu_items['Url']=""; $menu_sql = "SELECT Url FROM dtop"; $menu_res = mysqli_query($conn, $menu_sql) or die(mysqli_error($conn)); if (mysqli_num_rows($menu_res) < 1) { //this URL does not exist $display_block = "<p><em>Menu error.</em></p>"; echo $display_block; }else { while($menu_items = mysqli_fetch_array($menu_res)){ $item=$menu_items['Url']; echo $item; } } //free results mysqli_free_result($menu_res); //close connection to MySQL mysqli_close($conn); ?> Your help will be appreciated!
  10. I am trying to write some code to extract values from a mysql database to form a menu. my existing site uses an unordered list and places them in the tabs at the top of the page. (see my website www.1066cards4u.co.uk). I have tried using while(list($key, $value) = each($a)) type code to extract the url's. In this case I have excluded $key as I only want $value which is the full url including the <li> tags. when I run this code it repeats each $value twice. Here is the section of the code that produces the menu: <?php include ("connect_Menu_LOCAL.php"); $conn = get_db_conn_Menu(); $menu_sql = "SELECT Url FROM dtop"; $menu_res = mysqli_query($conn, $menu_sql) or die(mysqli_error($conn)); if (mysqli_num_rows($menu_res) < 1) { //this URL does not exist $display_block = "<p><em>Menu error.</em></p>"; echo $display_block; }else { while($menu_items = mysqli_fetch_array($menu_res)){ while(list(, $value) =each($menu_items)) { echo "$value" . '<br />'; } } } ?> I think it is caused by the fact that there are 2 whiles, but I am not experience enough to know what should go there. I have tried removing one of the whiles, but of course it does not work. I feel that I have almost solved this if I can lick this problem. Your help will be appreciated!
  11. I am getting as series of errors all of the same type concerning constants that are argument of a posted value. Viz: Notice: Use of undefined constant color - assumed 'color' in C:\wamp\www\1066mk4\Prnpdf.php on line 6 Here is a snippet of the code: $color = $_POST[color]; $image=$_POST[image]; $pdf->SetLeftMargin(float0); $pdf->SetFont($_POST[fontface],'',$_POST[font]); $pdf->SetXY($BoxX, $_POST[Top]); $pdf->Image($image,$floatx,$floaty,$floatw,$floath,jpg,''); The last line shown is a different error in as much as it is an argument of the image type as used in fpdf. Your help will be appreciated.
  12. Yes! I eventually spotted that and removed the square brackets.
  13. I have corrected that typo, but still getting errors: Notice: Use of undefined constant id - assumed 'id' in C:\wamp\www\1066mk4\Alt_inputform3.php on line 15 & Notice: Use of undefined constant Event_Type - assumed 'Event_Type' in C:\wamp\www\1066mk4\Alt_inputform3.php on line 15 & Notice: Array to string conversion in C:\wamp\www\1066mk4\Alt_inputform3.php on line 53 Errors 1 & 2, I have defined these constants in lines 8 & 9. Have I not done this correctly? As for the 3rd error I have a similar line on line 23, but it does not error on that line. I thought it may be the constant $optionHTML were the same in both cases so I added a 1 to the second instance. Here is the modified code: <?php include ("connect_Verses4Cards_LOCAL.php"); $conn = get_db_conn_verse(); $display_block=""; $Events =""; $Events_info['id'] =""; $Events_info['Event_Type'] =""; $Mood_info['id'] =""; $Mood_info['Event_Sub_Type'] =""; $optionsHTML =""; $optionsHTML1 =""; //Function to build select options based on passed array $Events = array($Events_info[id], $Events_info[Event_Type]); buildSelectOptions($Events); function buildSelectOptions($options) { $optionsHTML = "<select name=\"Event\">\r\n"; foreach($options as $id => $label) { $optionsHTML .= "<option value='{$id}'>{$label}</option>\n"; } return $optionsHTML; } //Run query to get the ID and Name from the table //Then populate into an array $clist_sql = "SELECT id, Event_Type FROM Events ORDER BY id"; $clist_res= mysqli_query($conn, $clist_sql) or die(mysqli_error($conn)); if (mysqli_num_rows($clist_res) < 1) { //this Event not exist $display_block = "<p><em>You have selected an invalid Event.<br/> Please try again.</em></p>"; } $Events = array(); while($Events_info = mysqli_fetch_array($clist_res)) { $Events [$Events_info['id']] = $Events_info['Event_Type']; } $EventOptions = buildSelectOptions($Events); //Function to build select options based on passed array $Mood[] = array($Mood_info['id'], $Mood_info['Event_Sub_Type']); buildSelectOptions1($Mood); function buildSelectOptions1($options) { $optionsHTML1 = "<select name=\"Mood\">\r\n"; foreach($options as $id => $label) { $optionsHTML1 .= "<option value='{$id}'>{$label}</option>\n"; } return $optionsHTML1; } //Run query to get the ID and Name from the table //Then populate into an array $clist1_sql = "SELECT id, Event_Sub_Type FROM Event_Sub ORDER BY id"; $clist1_res= mysqli_query($conn, $clist1_sql) or die(mysqli_error($conn)); if (mysqli_num_rows($clist1_res) < 1) { //this Mood not exist $display_block = "<p><em>You have selected an invalid Mood.<br/> Please try again.</em></p>"; } $Mood = array(); while($Mood_info = mysqli_fetch_array($clist1_res)) { $Mood [$Mood_info['id']] = $Mood_info['Event_Sub_Type']; } $MoodOptions = buildSelectOptions1($Mood); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!-- Design by Free CSS Templates http://www.freecsstemplates.org Released for free under a Creative Commons Attribution 2.5 License Name : Yosemite Description: A two-column, fixed-width design with dark color scheme. Version : 1.0 Released : 20091106 --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="keywords" content="" /> <meta name="description" content="Input form for getting Verse output" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>1066 Cards 4U - Verse Input Form</title> <link href="style.css" rel="stylesheet" type="text/css" media="screen" /> </head> <body> <div id="wrapper"> <div id="menu"> <ul> <li class="current_page_item"><a href="index.php">Home</a></li> <li><a href="Links.html">Links</a></li> <li><a href="Verse_Menu.html">Verses</a></li> <li><a href="Techniques.html">Techniques</a></li> <li><a href="blog.html">Blog</a></li> <li><a href="Gallery.html">Gallery</a></li> <li><a href="contact.html">Contact</a></li> <li><a href="AboutUs.html">About Us</a></li> <li><a href="stats1.html">Stats</a></li> </ul> </div><!-- end #menu --> <div id="header"> <div id="logo"> <h1><a href="http://www.1066cards4u.co.uk">1066 Cards 4U</a></h1> </div><!-- end #wrapper --> </div><!-- end #header --> <div id="page"> <div id="page-bgtop"> <div id="page-bgbtm"> <div id="content"> <h1>Verse Choices Form</h1> <p> <br></br> <br></br> You can filter the database, by selecting one of the items in each drop down menu and clicking the submit button.<br></br> This will list all greetings of the chosen type of Event and Mood.<br></br> If you do not make a choice the default selections will be used.</p> <br></br> <h3>BASIC VERSION</h3> <br></br> <!-- Start of FORM --> <form action="VerseQuery.php" method="post"> <select name="Event_Type"> <option value= "<?php echo $EventOptions;?>" </option> </select> <select name="Mood"> <option value= "<?php echo $MoodOptions;?>" </option> </select> <input type="submit" value="submit"/> </form><!-- End of FORM --> <br></br> <h3>ADVANCED VERSION</h3> <p>If you wish to change the Font color to any color, use the following button</p> <br></br> <!-- Start of FORM --> <form action="AltVerseQuery1.php" method="post"> <select name="Event_Type"> <option value= "<?php echo $EventOptions;?>" </option> </select> <select name="Mood"> <option value= "<?php echo $MoodOptions;?>" </option> </select> <input type="submit" value="submit"/> </form><!-- End of FORM --> <br></br><br></br> <form method="post" action="Verse_Menu.html"> <input type="submit" value="Return To Verse Menu"/> </form> </div><!-- end #content --> <div id="sidebar"> <div id="search" > <form method="get" action="http://1066cards4u.co.uk"> <div> <input type="text" name="s" id="search-text" value="" /> <input type="submit" id="search-submit" value="GO" /> </div> </form> </div> <div style="clear: both;"> </div> <h2>Useful Links</h2> <ul.a> <li><p><a href="Articles/Instructions for Using Verse Database-V2.12.pdf" target="_blank">Insructions for using Verse Printing UtilityPrintable PDF Version</a></p></li> <li><p><a href="Articles/Nominal Settings.PDF" target="_blank">Nominal Settings and Cutting List for Verse Database PDF Version</a></p></li> <li><p><a href="Articles/How to use the Color Chooser_rasterized.PDF" target="_blank">How to use the Color Picker</a></p></li> </ul.a> </div><!-- end #sidebar --> <div style="clear: both;"> </div> </div><!-- end #page-bgtop --> </div><!-- end #page-bgbtm --> </div><!-- end #page --> </div> <div id="footer"> <p>Copyright (c) 2008 Sitename.com. All rights reserved. Design by <a href="http://www.freecsstemplates.org/" rel="nofollow">FreeCSSTemplates.org</a>.</p> </div><!-- end #footer --> </body> </html> Any other sugestions?
  14. I am trying to tidy up my code and make it able to run using PHP 5.5.12. I have a syntax error that I can't see why it is giving this error. The code is being run on localhost with php.ini error set to E_ALL. $optionsHTML = "<select name=\"Event\">\r\n"; This works on the live file, but it has a very limited php.ini file. I don't think you will need all of the code, but I will post just in case: <?php include ("connect_Verses4Cards_LOCAL.php"); $conn = get_db_conn_verse(); $display_block=""; $Events =""; $Events_info['id'] =""; $Events_info['Event_Type'] =""; $Mood_info['id'] =""; $Mood_info['Event_Sub_Type'] ="";" //Function to build select options based on passed array $Events = array($Events_info[id], $Events_info[Event_Type]); buildSelectOptions($Events); function buildSelectOptions($options) { $optionsHTML = "<select name=\"Event\">\r\n"; foreach($options as $id => $label) { $optionsHTML .= "<option value='{$id}'>{$label}</option>\n"; } return $optionsHTML; } //Run query to get the ID and Name from the table //Then populate into an array $clist_sql = "SELECT id, Event_Type FROM Events ORDER BY id"; $clist_res= mysqli_query($conn, $clist_sql) or die(mysqli_error($conn)); if (mysqli_num_rows($clist_res) < 1) { //this Event not exist $display_block = "<p><em>You have selected an invalid Event.<br/> Please try again.</em></p>"; } $Events = array(); while($Events_info = mysqli_fetch_array($clist_res)) { $Events [$Events_info['id']] = $Events_info['Event_Type']; } $EventOptions = buildSelectOptions($Events); //Function to build select options based on passed array $Mood[] = array($Mood_info['id'], $Mood_info['Event_Sub_Type']); buildSelectOptions1($Mood); function buildSelectOptions1($options) { $optionsHTML = "<select name=\"Mood\">\r\n"; foreach($options as $id => $label) { $optionsHTML .= "<option value='{$id}'>{$label}</option>\n"; } return $optionsHTML; } //Run query to get the ID and Name from the table //Then populate into an array $clist1_sql = "SELECT id, Event_Sub_Type FROM Event_Sub ORDER BY id"; $clist1_res= mysqli_query($conn, $clist1_sql) or die(mysqli_error($conn)); if (mysqli_num_rows($clist1_res) < 1) { //this Mood not exist $display_block = "<p><em>You have selected an invalid Mood.<br/> Please try again.</em></p>"; } $Mood = array(); while($Mood_info = mysqli_fetch_array($clist1_res)) { $Mood [$Mood_info['id']] = $Mood_info['Event_Sub_Type']; } $MoodOptions = buildSelectOptions1($Mood); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!-- Design by Free CSS Templates http://www.freecsstemplates.org Released for free under a Creative Commons Attribution 2.5 License Name : Yosemite Description: A two-column, fixed-width design with dark color scheme. Version : 1.0 Released : 20091106 --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="keywords" content="" /> <meta name="description" content="Input form for getting Verse output" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>1066 Cards 4U - Verse Input Form</title> <link href="style.css" rel="stylesheet" type="text/css" media="screen" /> </head> <body> <div id="wrapper"> <div id="menu"> <ul> <li class="current_page_item"><a href="index.php">Home</a></li> <li><a href="Links.html">Links</a></li> <li><a href="Verse_Menu.html">Verses</a></li> <li><a href="Techniques.html">Techniques</a></li> <li><a href="blog.html">Blog</a></li> <li><a href="Gallery.html">Gallery</a></li> <li><a href="contact.html">Contact</a></li> <li><a href="AboutUs.html">About Us</a></li> <li><a href="stats1.html">Stats</a></li> </ul> </div><!-- end #menu --> <div id="header"> <div id="logo"> <h1><a href="http://www.1066cards4u.co.uk">1066 Cards 4U</a></h1> </div><!-- end #wrapper --> </div><!-- end #header --> <div id="page"> <div id="page-bgtop"> <div id="page-bgbtm"> <div id="content"> <h1>Verse Choices Form</h1> <p> <br></br> <br></br> You can filter the database, by selecting one of the items in each drop down menu and clicking the submit button.<br></br> This will list all greetings of the chosen type of Event and Mood.<br></br> If you do not make a choice the default selections will be used.</p> <br></br> <h3>BASIC VERSION</h3> <br></br> <!-- Start of FORM --> <form action="VerseQuery.php" method="post"> <select name="Event_Type"> <option value= "<?php echo $EventOptions;?>" </option> </select> <select name="Mood"> <option value= "<?php echo $MoodOptions;?>" </option> </select> <input type="submit" value="submit"/> </form><!-- End of FORM --> <br></br> <h3>ADVANCED VERSION</h3> <p>If you wish to change the Font color to any color, use the following button</p> <br></br> <!-- Start of FORM --> <form action="AltVerseQuery1.php" method="post"> <select name="Event_Type"> <option value= "<?php echo $EventOptions;?>" </option> </select> <select name="Mood"> <option value= "<?php echo $MoodOptions;?>" </option> </select> <input type="submit" value="submit"/> </form><!-- End of FORM --> <br></br><br></br> <form method="post" action="Verse_Menu.html"> <input type="submit" value="Return To Verse Menu"/> </form> </div><!-- end #content --> <div id="sidebar"> <div id="search" > <form method="get" action="http://1066cards4u.co.uk"> <div> <input type="text" name="s" id="search-text" value="" /> <input type="submit" id="search-submit" value="GO" /> </div> </form> </div> <div style="clear: both;"> </div> <h2>Useful Links</h2> <ul.a> <li><p><a href="Articles/Instructions for Using Verse Database-V2.12.pdf" target="_blank">Insructions for using Verse Printing UtilityPrintable PDF Version</a></p></li> <li><p><a href="Articles/Nominal Settings.PDF" target="_blank">Nominal Settings and Cutting List for Verse Database PDF Version</a></p></li> <li><p><a href="Articles/How to use the Color Chooser_rasterized.PDF" target="_blank">How to use the Color Picker</a></p></li> </ul.a> </div><!-- end #sidebar --> <div style="clear: both;"> </div> </div><!-- end #page-bgtop --> </div><!-- end #page-bgbtm --> </div><!-- end #page --> </div> <div id="footer"> <p>Copyright (c) 2008 Sitename.com. All rights reserved. Design by <a href="http://www.freecsstemplates.org/" rel="nofollow">FreeCSSTemplates.org</a>.</p> </div><!-- end #footer --> </body> </html> My experience is limited, so any help would be appreciated!
  15. The $conn was something I was trying in a previous attempt to solve the problem and was something I overlooked. Am I right in assuming that I should use $dbo like so: $qrslt = $dbo->query($Rel_Hol_sql); If so do I need the include? Also in the function do I need to declare the argument in the function like so: function doDB4($dbo) These atre the errors I get when running the code with the above changes: Notice: Undefined variable: dbo in C:\wamp\www\1066mk4\EvTest2.php on line 12 & Fatal error: Call to a member function query() on a non-object in C:\wamp\www\1066mk4\EvTest2.php on line 12 That says to me that $Rel_Hol_sql is not an object, so how do I write my code in such a way as to make the select query an object. I've got to admit I am have trouble getting my head around Object Oriented style of coding.
  16. Sorry about my outburst previously, I had other things that were making me tetchy! Lets start again! I have read the list that ch0cu3r mentioned, so I guess that this means that I could change mysqli_connect() to mysqli_construct() or conversly the mysqli_new()? I still don't understand why ginerjm was so persistant about root? according to the PHP Manual the correct syntax for the connection using PDO was: $dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass); The root being substituted for the $user. Is it that I did not put quotes around it? I am still determined to learn about PDO, even if I do not implement it for some time. My site is running on an old version of PHP so there is no immediate rush to change anything. To help me learn PDO I have written some code in a test file to hep me debug it. I have used an include file for connection, which appears to work as the echo message 'connected' is displayed. <?Php $host_name = "localhost"; $database = "db464231930"; // Change your database nae $username = "root"; // Your database user id $password = "xxxxx"; // Your password //////// Do not Edit below ///////// try { $dbo = new PDO('mysql:host='.$host_name.';dbname='.$database, $username, $password); echo 'CONNECTED'; } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "<br/>"; die(); } ?> Here is the code for the select query: <?php include(RelHol_connect_LOCAL.php); //gather the Events $RelHol_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) = 'August' And YEAR(Events.Event_Date)= '2015' And Religion.Religion = 'Christian' ORDER BY Events.Event_Date ASC"; $qrslt = $conn->query($Rel_Hol_sql); if (!$qrslt) { echo "Error running query"; exit(); } while ($row = $qrslt->fetch(PDO::FETCH_ASSOC)) { $Rel_Event=$Row['Religion']; $Event_text=$row['Event_Description']; //add to display $display_block .= " <tr> <td width=\"18%\" valign=\"top\">".$Rel_Event."<br/></td> <td width=\"45%\" valign=\"top\">" .$Event_text."<br/></td>"; $display_block .="</table>"; } ?> <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <?php echo $display_block; ?> </body> </html> However when this is run I get a blank screen, and no error messages. Is the method I am using to display the table incorrect? By the way I have tested the query in phpmyadmin and it works OK. Any help would be appreciated.
  17. I have been a member for many years and I have never been treated so condescendingly by a member! Most members have been very helpful. I know aged 67 programming is more challenging than for younger programmers, but at that age I have plenty of time to spare!
  18. 1) Root is the default user on MySQL on localhost, where I am testing the code. 2) I plagerised the manual and copied this from the section on connection. I know that I seem like a novice, but I usually get there in the end. 3) Isn't English a funny language! what's in an I! 4) True enough, but that's defeatist language. 5) Thanks for the code I will check this out and re-post. I did not say it was too technical, I said it was confusing! There seem to be several ways of apparently arriving at the same answer.
  19. I installed WAMP and ran my code it gave me a warning that the mysqli statements were depreciated! I am having trouble using PDO! I have written the code, but it does not output any data. It is not giving any error messages, so I am not sure where it is failing. The area on the page is blank. As I am not conversant with this extension to PHP I am not sure where I am going wrong. I just need some guidance to point me in the right direction?
  20. I have decided that using mysqli to connect to my database is now a depreciated service, so I am trying to change the code to use PDO. I have downloaded all the manual which confuses my as it seems there are many ways of doing the same thing. I have had a bash at changing a small section of my index page that look to see if there are any religious holidays today. I have only written the part that looks for the data and desplays it in a table. I will show the code I have written first and then the original mysqli code after: try { $conn= new PDO('mysql:host=localhost;dbname=db464231930', root, 'xxxxx'); } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "<br/>"; die(); } function RelDay($conn){ //gather the Events $RelHol_sql = "SELECT Events15.ID, Events15.Event_Date, Events15.Event_Description, Events15.Faith_ID, Religion.ID, Religion.Religion FROM Events15 LEFT JOIN Religion ON Events15.Faith_ID = Religion.ID WHERE DAY(Events15.Event_Date)= Day(Now()) And MONTH(Events15.Event_Date)=Month(Now()) And YEAR(Events15.Event_Date)=YEAR(Now()) ORDER BY Events15.Event_Date ASC"; $display_block .= " <table width=\"120%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"white\" > <tr> <th>RELIGION</th> <th>EVENT</th> </tr>"; foreach($conn -> query($Rel_Hol_sql) as $Row){ $Rel_Date=$Row['Event_Date']; $Rel_Event=$Row['Religion']; $Event_text=$row['Event_Description']; } } //add to display $display_block .= " <tr> <td width=\"18%\" valign=\"top\">".$Rel_Event."<br/></td> <td width=\"45%\" valign=\"top\">" .$Event_text."<br/></td>"; //close up the table $display_block .="</table>"; echo $display_block; mysqli code: <?php include("RelHol_connect_LOCAL.php"); \doDB3(); //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) > 0) { //gather the Events $get_Event_sql = "SELECT Events15.ID, Events15.Event_Date, Events15.Event_Description, Events15.Faith_ID, Religion.ID, Religion.Religion FROM Events15 LEFT JOIN Religion ON Events15.Faith_ID = Religion.ID WHERE DAY(Events15.Event_Date)= Day(Now()) And MONTH(Events15.Event_Date)=Month(Now()) And YEAR(Events15.Event_Date)=YEAR(Now()) ORDER BY Events15.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=\"120%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"white\" > <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=\"18%\" valign=\"top\">".$Rel_Event."<br/></td> <td width=\"45%\" valign=\"top\">" .$Event_text."<br/></td>"; } //free results mysqli_free_result($get_Event_res); } 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>"; } //close connection to MySQL mysqli_close($mysqli); //close up the table $display_block .="</table>"; echo $display_block; ?> As you can see I have not written the data test part yet, but I want to get the data gathering right first. Your help is appreciated.
  21. I have a menu that is used in all of my web pages and if I add something it means that I have to change the code on all of the the pages, which is time consuming. I have not written any code yet, but I just want some advice on how to go about this problem. Most of the web pages I have looked at are not very helpful. Some suggest jScript, but I am not very conversant with this language. Any help would be appreciated!
  22. Ran a validation and found the errors! I did not realise how helpful a validation can be. Thanks for your help!
  23. Hi Psycho Thanks that did the trick! Having solved that another problem has arisen. When the Submit button is clicked absolutly nothing happens. No error, it just stays on the page. Again extactly the same code works on PC and iPad versions. Regarding you comments about lines 133 & 137, they are all one line and the </td> is on line 140. I am guessing that it must be in the stylesheet, but I can see anything that I know of that would influence the Submit button. Do you think that this problem should be a new thread, if so I will re-post?
  24. Hi Pyscho Thank you for looking at this code. I have corrected the code, but it made no difference! Here is a link to the form that runs the code: http://www.1066cards4u.co.uk/Mobile/mAlt_inputform1.html? I hope this makes it easier to debug. Many thanks!
  25. I have been developing a mobile phone version of my website and have a problem I can't solve. The code works fine on the PC and iPad version, but when I output the data into a table on the mobile version, it does not wrap the text in the cell. I have tried changing the CSS style using- word-wrap: break-word; but this does not make any difference. Both the header row and all of the data rows seem all bunched up. Here is the CSS script: body { margin:0px; padding:0px; font-family:Arial, Helvetica, sans-serif; } img { border:none; } ul,li,h1,h2,h3,h4,h5,h6,p,span,td,div { margin:0px; padding:0px; line-height:0px; list-style:none; } li a,a,a:hover,li a:hover { text-decoration:none; } input, textarea, select { font:100% Arial, Helvetica, sans-serif; vertical-align:middle; color:#000; outline:none; } form, fieldset { margin:0; padding:0; border-style:none; } /*Site Gentral Start*/ #wrapper { width:100%; height:auto; float:left; } #page { width:300px; height:auto; margin:0px auto; } /*header Start*/ .header { width:300px; height:auto; float:left; background:#fbfaf9; } .logo { width:300px; height:auto; float:left; padding:0px 0px 10px 18px; background:url(../images/border.png) bottom repeat-x; } .banner { width:300px; height:auto; float:left; padding:0px 0px 0px 18px; } .small-logo { width:140px; height:auto; float:left; } .home { width:40px; height:50px; float:right; padding-top:30px; } /*content Start*/ .content { width:300px; height:auto; float:left; padding:0px 0px 0px 18px; background:#fbfaf9; } .content ul { margin:12px 0px 0px 0px; padding:0px; } .content ul li { background:url(../images/menu-bg.png) no-repeat; height:25px; font:bold 12px Arial, Helvetica, sans-serif; color:#383333; padding:14px 0px 0px 15px; margin-bottom:15px; display:block; } .content ul li a,a:hover { color:#383333; } .content h1 { font:18px Arial, Helvetica, sans-serif; color:#8f9294; padding:5px 0px 5px 0px; } .content p { font:12px Arial, Helvetica, sans-serif; color:#8f9294; line-height:18px; padding-right:22px; text-align:justify; padding-bottom:15px; } #dtable { font-size:small; color:black; } /*footer Start*/ .footer { width:300px; height:auto; float:left; padding:5px 0px 20px 18px; background:#fbfaf9; } .footer-left { width:50px; height:auto; float:left; } .footer-right { width:60px; height:auto; float:left; } .footer-center { width:290px; float:none; background:url(../images/footer-center.png); height:28px; text-align:center; font:12px Arial, Helvetica, sans-serif; color:#FFFFFF; padding-top:12px; } Here is the php/html script I am running: <?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)); 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=\"100%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"white\" > <tr> <th>ID</th> <th>VERSE</th> <th>MOOD/SUB TYPE</th> <th>CHOOSE</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=\"7%\" valign=\"top\">".$Verse_id."</td> <td width=\"47%\" valign=\"top\">".$Verse_text."</td> <td width=\"31%\" valign=\"top\">" .$Mood_info."</td> <td width=\"15%\" valign=\"middle\" <form METHOD=\"POST\" ACTION=\"mVInput1.php\"> <input type=\"Radio\" name=\"VID\" value=$VID > </td></tr>"; } $display_block.="<input type=submit value=Submit> </form>"; //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>"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name= "viewport" content="width=360"/> <title>Welcome</title> <link href="css/stylesheet.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="wrapper"><!--Wrapper start--> <div id="page"><!--Page start--> <div class="header"><!--Header start--> <div class="logo"><a href="#"><img src="images/logo.png" alt="" /></a></div> <div class="small-logo"><a href="#"><img src="images/Site_small.png" alt="" /></a></div> <div class="home"><a href="index.html"><img src="images/home.png" alt="" /><p>Home</p></a><br></div> </div><!--Header End--> <!--content start--> <div class="content"> <div id="dtable"> <?php echo $display_block; ?></div> </div><!-- end #content --> <!--content End--> <!--Footer start--> <div class="footer"> <div class="footer-center">© 1066Cards4U</div> </div> <!--Footer End--> </div> </div> <!--Wrapper End--> </body> </html> Why is this happening? Can anybody help?
×
×
  • 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.