Jump to content

rocky48

Members
  • Posts

    261
  • Joined

  • Last visited

About rocky48

  • Birthday 03/03/1948

Contact Methods

  • Website URL
    www.1066cards4u.co.uk

Profile Information

  • Gender
    Male
  • Location
    Hastings, UK
  • Interests
    Programming, Radio Control Model Aircraft
  • Age
    74

Recent Profile Visitors

5,334 profile views

rocky48's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

4

Community Answers

  1. Fix What? I know that it is not passing the data via the session, but I can't see why? This code has worked for me since 2012 and it only seems to have gone wrong since I messed up a file. I can't see why that any data has already been output. Nothing should be output until you submit on the varinput.php page. Please can anyone spot why this is happening, because I am stumped!
  2. DanRz - I had forgotten about that thanks! I have now added Error reporting and corrected the capitalisation issue with the session name. It now reports a warning on the line where I corrected the session name: Warning: Undefined array key "test" in /homepages/39/d922140697/htdocs/1066cardcraft/Prnpdf.php on line 42 The fatal error is on this line: Fatal error: Uncaught Exception: FPDF error: Some data has already been output, can't send PDF file (output started at /homepages/39/d922140697/htdocs/1066cardcraft/Prnpdf.php:42) in /homepages/39/d922140697/htdocs/1066cardcraft/fpdf.php:271 Stack trace: #0 /homepages/39/d922140697/htdocs/1066cardcraft/fpdf.php(1049): FPDF->Error('Some data has a...') #1 /homepages/39/d922140697/htdocs/1066cardcraft/fpdf.php(1012): FPDF->_checkoutput() #2 /homepages/39/d922140697/htdocs/1066cardcraft/Prnpdf.php(145): FPDF->Output('D', 'verse.pdf') #3 {main} thrown in /homepages/39/d922140697/htdocs/1066cardcraft/fpdf.php on line 271 What is being output? What baffles me is that these files were working before I miss copied the wrong Vinput file ( I had one file vinput.php and the other vinput1.php and over wrote the second file with the same code as the first file. So the only one that has been changed is the file varinput.php ( I renamed it to stop the confusion). I can't even think about some of the suggestions Mac_gyver made until I resolve why this is not working. All of the choices are in option lists so I can't see that over complicating the code with input checks would achieve anything!
  3. I have screwed up my code, was working but copied wrong file and was running incorrect file. Basically it appears to work and runs without error, but it should print the verse I have chosen but prints 'You have selected an invalid Verse. Please try again' which is an error message in the file Prnpdf.php. My conclusion is therefore that the session is not passing the data from the previous file, varinput.pdf, but the file that I messed up as the one called varinput.php and all the other files are the original files, so I can't see why it is not working! Is there something wrong with the session in that file? The sequence of the files running is as follows: vinput.php -> vquery.php -> varinput.php -> prnpdf.php -> fpdf.php vinput.php <!DOCTYPE html> <html lang="en-GB"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="generator" content="RSD 5.0.3519"> <meta name="description" content="Created by Inger Eik, Dec. 2021"> <title>Verse Input</title> <link rel="stylesheet" href="css/bootstrap4.min.css"> <link rel="stylesheet" href="css/wireframe-theme.min.css"> <script>document.createElement( "picture" );</script> <script class="picturefill" async="async" src="js/picturefill.min.js"></script> <link rel="stylesheet" href="css/main.css"> <style> /* Interaction Elements */ a.link-button.button-link-1 { margin-right: 5px; margin-bottom: 5px; margin-left: 5px; padding-top: 4px; width: 120px; height: auto; border: .0625rem solid rgba(255, 255, 255, .5); background-color: #0f0e14; color: #fff; text-align: center; text-decoration: none; line-height: 22px; } select.select.dd-fc { margin-right: 5px; margin-bottom: 5px; margin-left: 5px; padding-top: 5px; padding-bottom: 3px; width: 120px; border-color: rgba(255, 255, 255, .5); background-color: #0f0e14; color: #fff; opacity: .98; } .container-grid.dropdown-menubar { position: absolute; top: auto; bottom: 0; display: -webkit-box; display: -webkit-flex; display: -moz-box; display: -ms-flexbox; display: flex; -ms-flex-pack: center; margin-right: 0; margin-left: 0; padding-top: 10px; padding-bottom: 5px; max-width: 1200px; width: 100%; background-color: #0f0e14; -webkit-box-pack: center; -webkit-justify-content: center; -moz-box-pack: center; justify-content: center; -webkit-flex-wrap: wrap; -ms-flex-wrap: wrap; flex-wrap: wrap; } @media screen and (min-width: 75rem) { /* Interaction Elements */ a.link-button.button-link-1 { height: auto; } } option:first-child { display:none; } </style> </head> <body> <div class="outer-limit container-grid"> <div class="header container-grid"> <div class="header-inner container-grid"></div> <div class="dropdown-menubar container-grid"> <?php include("inc/menu.php"); ?> </div> </div> <h1 class="heading-5">1066 Card Craft</h1> <div class="content container-grid"> <div class="aside container-grid"> <div class="responsive-picture"> <picture> <img alt="Placeholder Picture" width="485" height="477" src="./img/writing.jpg" loading="lazy"> </picture> <?php include("inc/aside-verse.php"); ?> </div> </div> <div class="main container-grid"> <?php include ("cons/connect_Verses4Cards.php"); $conn = get_db_conn_verse(); //Function to build select options based on passed array function buildSelectOptions($name, array $options, $current=null){ $htmlString = "<select name='{$name}' id='{$name}'>\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($conn){ $qry = "SELECT id ,Event_Type FROM Events ORDER BY id"; $sql = mysqli_query($conn, $qry)or die(mysqli_error($conn)); if(mysqli_num_rows($sql) < 1){ return array(); } while($res1 = mysqli_fetch_array($sql)){ $ret1[$res1['id']] = $res1['Event_Type']; } return $ret1; } function getMoods($conn){ $qry = "SELECT id ,Event_Sub_Type FROM Event_Sub ORDER BY id"; $sql = mysqli_query($conn, $qry)or die(mysqli_error($conn)); if(mysqli_num_rows($sql) < 1){ return array(); } while($res2 = mysqli_fetch_array($sql)){ $ret2[$res2['id']] = $res2['Event_Sub_Type']; } return $ret2; } ?> <h3>Choose Your Verse Options</h3> <br></br> <!-- Start of FORM --> <form action="vquery.php" method="post"> <?php echo buildSelectOptions('event', getEvents($conn), 1);?> <?php echo buildSelectOptions('mood', getMoods($conn), 1);?> <input type="submit" value="submit" /> </form> <!-- End of FORM --> </div> </div> <div class="footer container-grid"> <?php include("inc/footer.php"); ?> </div> </div> <script src="js/jquery.min.js"></script> <script src="js/outofview.js"></script> <script src="js/popper.min.js"></script> <script src="js/bootstrap.min.js"></script> </body> </html> vquery.php <!DOCTYPE html> <html lang="en-GB"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="generator" content="RSD 5.0.3519"> <meta name="description" content="Created by Inger Eik, Dec. 2021"> <title>Verse Query</title> <link rel="stylesheet" href="css/bootstrap4.min.css"> <link rel="stylesheet" href="css/wireframe-theme.min.css"> <script>document.createElement( "picture" );</script> <script class="picturefill" async="async" src="js/picturefill.min.js"></script> <link rel="stylesheet" href="css/main.css"> <?php include_once("cons/connect_Verses4Cards.php"); $conn=get_db_conn_verse(); $display_block =""; //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"]."'"; $verify_Event_res = mysqli_query($conn, $verify_Event_sql) or die(mysqli_error($conn)); 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($conn, $verify_Mood_sql) or die(mysqli_error($conn)); 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"]."' And verses.Sub_Type = '".$_POST["mood"]."' ORDER BY verses.ID ASC"; $get_Event_res = mysqli_query($conn, $get_Event_sql) or die(mysqli_error($conn)); //create the display string $display_block .= " <table width=\"90%\" 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=\"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=\"middle\"> <form METHOD=\"POST\" ACTION=\"varInput.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 up the table $display_block .="</table>"; } ?> <style> /* Interaction Elements */ a.link-button.button-link-1 { margin-right: 5px; margin-bottom: 5px; margin-left: 5px; padding-top: 4px; width: 120px; height: auto; border: .0625rem solid rgba(255, 255, 255, .5); background-color: #0f0e14; color: #fff; text-align: center; text-decoration: none; line-height: 22px; } select.select.dd-fc { margin-right: 5px; margin-bottom: 5px; margin-left: 5px; padding-top: 5px; padding-bottom: 3px; width: 120px; border-color: rgba(255, 255, 255, .5); background-color: #0f0e14; color: #fff; opacity: .98; } .container-grid.dropdown-menubar { position: absolute; top: auto; bottom: 0; display: -webkit-box; display: -webkit-flex; display: -moz-box; display: -ms-flexbox; display: flex; -ms-flex-pack: center; margin-right: 0; margin-left: 0; padding-top: 10px; padding-bottom: 5px; max-width: 1200px; width: 100%; background-color: #0f0e14; -webkit-box-pack: center; -webkit-justify-content: center; -moz-box-pack: center; justify-content: center; -webkit-flex-wrap: wrap; -ms-flex-wrap: wrap; flex-wrap: wrap; } @media screen and (min-width: 75rem) { /* Interaction Elements */ a.link-button.button-link-1 { height: auto; } } option:first-child { display:none; } </style> </head> <body> <div class="outer-limit container-grid"> <div class="header container-grid"> <div class="header-inner container-grid"></div> <div class="dropdown-menubar container-grid"> <?php include("inc/menu.php"); ?> </div> </div> <h1 class="heading-5">1066 Card Craft</h1> <div class="content container-grid"> <div class="aside container-grid"> <div class="responsive-picture"> <picture> <img alt="Placeholder Picture" width="485" height="477" src="./img/writing.jpg" loading="lazy"> </picture> <?php include("inc/aside-verse.php"); ?> </div> </div> <div class="main container-grid"> <h2 class="heading-2">Your Verse Query</h2> <main class="container-grid"> <?php if(isset($display_block)){ echo $display_block;}?> </main> </div> </div> <div class="footer container-grid"> <?php include("inc/footer.php"); ?> </div> </div> <script src="js/jquery.min.js"></script> <script src="js/outofview.js"></script> <script src="js/popper.min.js"></script> <script src="js/bootstrap.min.js"></script> </body> </html> varinput.php <!DOCTYPE html> <html lang="en-GB"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="generator" content="RSD 5.0.3528"> <meta name="description" content="Created by Inger Eik, Dec. 2021"> <title>Input Page</title> <link rel="stylesheet" href="css/bootstrap4.min.css"> <link rel="stylesheet" href="css/wireframe-theme.min.css"> <script>document.createElement( "picture" );</script> <script class="picturefill" async="async" src="js/picturefill.min.js"></script> <link rel="stylesheet" href="css/main.css"> <style> /* Interaction Elements */ a.link-button.button-link-1 { margin-right: 5px; margin-bottom: 5px; margin-left: 5px; padding-top: 4px; width: 120px; height: auto; border: .0625rem solid rgba(255, 255, 255, .5); background-color: #0f0e14; color: #fff; text-align: center; text-decoration: none; line-height: 22px; } select.select.dd-fc { margin-right: 5px; margin-bottom: 5px; margin-left: 5px; padding-top: 5px; padding-bottom: 3px; width: 120px; border-color: rgba(255, 255, 255, .5); background-color: #0f0e14; color: #fff; opacity: .98; } .container-grid.dropdown-menubar { position: absolute; top: auto; bottom: 0; display: -webkit-box; display: -webkit-flex; display: -moz-box; display: -ms-flexbox; display: flex; -ms-flex-pack: center; margin-right: 0; margin-left: 0; padding-top: 10px; padding-bottom: 5px; max-width: 1200px; width: 100%; background-color: #0f0e14; -webkit-box-pack: center; -webkit-justify-content: center; -moz-box-pack: center; justify-content: center; -webkit-flex-wrap: wrap; -ms-flex-wrap: wrap; flex-wrap: wrap; } @media screen and (min-width: 75rem) { /* Interaction Elements */ a.link-button.button-link-1 { height: auto; } } option:first-child { display:none; } </style> </head> <body> <div class="outer-limit container-grid"> <div class="header container-grid"> <div class="header-inner container-grid"></div> <div class="dropdown-menubar container-grid"> <?php include("inc/menu.php"); ?> </div> </div> <h1 class="heading-5">1066 Cards 4 U</h1> <div class="content container-grid"> <div class="aside container-grid"> <?php include("inc/aside.php"); ?> </div> <div class="main container-grid"> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="generator" content="RSD 5.0.3519"> <title>VInput1</title> <link rel="stylesheet" href="css/bootstrap4.min.css"> <link rel="stylesheet" href="css/wireframe-theme.min.css"> <script>document.createElement( "picture" );</script> <script class="picturefill" async="async" src="js/picturefill.min.js"></script> <link rel="stylesheet" href="css/main.css"> </head> <body> <div class="container-grid container-2"></div> <div class="container-grid main"> <?php session_start(); $_SESSION['test']=$_POST['VID']; include("cons/connect_Verses4Cards.php"); $conn=get_db_conn_verse(); $display_block =""; $CardSz =""; $Card_info['Size']=""; $Card_info['Narative']=""; //Function to build select options based on passed array $CardSz = array($Card_info['Size'], $Card_info['Narative']); buildSelectOptions($CardSz); function buildSelectOptions($options) { $optionsHTML = "<select name=\"CSize\">\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 * FROM CSize ORDER BY GP"; $clist_res= mysqli_query($conn, $clist_sql) or die(mysqli_error($conn)); if (mysqli_num_rows($clist_res) < 1) { //this Card does not exist $display_block = "<p><em>You have selected an invalid Country.<br/> Please try again.</em></p>"; } $CardSz = array(); while($Card_info = mysqli_fetch_array($clist_res)) { $CardSz[$Card_info['Size']] = $Card_info['Narative']; } $CardOptions = buildSelectOptions($CardSz); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="keywords" content="" /> <meta name="description" content="On this page the user choose the variables to align the verse on the paper" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>1066 Cards 4U - Variable Input Form</title> <link href="style.css" rel="stylesheet" type="text/css" media="screen" /> </head> <body> <div id="wrapper"> <div id="menu"> <ul> <div id="content"> <h1>Card Variable Input Form</h1> <form name="Lists" action="Prnpdf.php" method="post"> <p><strong>Card Size</strong></p> <select name="CSize"> <option value= "<?php echo $CardOptions;?>" </option> </select> <br/> <p><strong>Input Distance from top in mm:</strong> <input type="number" name="Top" value="50" min="20" max="200"/></p><br/> <p><strong>Input Font size in points:</strong> <select name="font"> <option value="18" > 18 point</option> <option value="20" > 20 point</option> <option value="22" > 22 point</option> <option value="24" selected="selected" > 24 point</option> <option value="26" > 26 point</option> <option value="28" > 28 point</option> <option value="30" > 30 point</option> <option value="32" > 32 point</option> </select></p><br/> <p><strong>Text Colour</strong></p> <select name="color"> <option value="000000000" > Black</option> <option value="255215000" > Gold</option> <option value="192192192" > Silver</option> <option value="255000000" > Red</option> <option value="000255000" > Green</option> <option value="000000255" > Blue</option> <option value="255195203" > Pink</option> <option value="132112255" > Slate Blue</option> <option value="128000128" > Purple</option> <option value="168099030" > Brown</option> </select><br/> <p><strong>Text Font</strong></p> <select name="fontface"> <option value="French Script MT" > French Script MT</option> <option value="Batavia" > Batavia </option> <option value="Algerian" > Algerian </option> <option value="Bladerunner" > Bladerunner </option> <option value="Brush Script" > Brush Script</option> <option value="Helterskelter" > Helterskelter</option> <option value="Justice" > Justice</option> <option value="Magneto" > Magneto</option> <option value="Old English" > Old English</option> <option value="Sneakerhead Outline" > Sneakerhead Outline</option> <option value="Trendy" > Trendy</option> <option value="Vladimir Script" > Vladimir Script</option> </select><br/> <p><strong>Border Images </strong></p> <select name="image"> <option value="images/empty.jpg" selected="selected"> No Border</option> <option value="images/Border10p.jpg" > Rose Border - Portrait</option> <option value="images/Border2p.jpg" > Chequered Border - Portrait</option> <option value="images/Border11p.jpg" > Ribbon Border - Portrait</option> <option value="images/Border5p.jpg" > Yellow Border - Portrait</option> <option value="images/Corner2p.jpg" > Leaf Corners - Portrait</option> <option value="images/corner1p.jpg" > Laurel Corners - Portrait</option> <option value="images/Border12P.jpg" > Holly Corner - Portrait</option> <option value="images/116070.jpg" > Ornate -Portrait</option> <option value="images/116122.jpg" > Ornate2 -Portrait</option> <option value="images/Border10l.jpg" > Rose Border -Landscape </option> <option value="images/Border2l.jpg" > Chequered Border -Landscape</option> <option value="images/Border11l.jpg" > Ribbon Border -Landscape</option> <option value="images/Border5l.jpg" > Yellow Border -Landscape</option> <option value="images/Corner2l.jpg" > Leaf Corners -Landscape</option> <option value="images/corner1l.jpg" > Holly Corner -Landscape</option> <option value="images/Border12L.jpg" > Yellow Border -Landscape</option> <option value="images/Holly1.jpg" > Holly-Landscape</option> <option value="images/Xmastree2.jpg" > Xmas Tree - Landscape</option> <option value="images/Decoborder1.png" > Art Deco Border - Portrait</option> </select><br /><br /> <input type="submit" value="Submit"/> </form> </div><!-- end #content --> </body> </html> </div> <div class="container-grid footer"> <?php include("inc/footer.php"); ?> </div> <script src="js/jquery.min.js"></script> <script src="js/outofview.js"></script> <script src="js/popper.min.js"></script> <script src="js/bootstrap.min.js"></script> </div> </body> </html> prnpdf.php <?php session_start(); include("cons/connect_Verses4Cards.php"); $conn=get_db_conn_verse(); $display_block =""; $color=""; $r =""; $g =""; $b =""; $image =""; //echo $r,$g,$b; //Get the Card Variables $Get_Size_sql = "SELECT * FROM `CSize` WHERE `Size` ='".$_POST["CSize"]."'"; $Get_Size_res = mysqli_query($conn, $Get_Size_sql) or die(mysqli_error($conn)); 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"; } //verify the Event exists //$the_id = mysqli_real_escape_string($mysqli, $_SESSION[VID]); $Get_Verse_sql = "SELECT id, Event, Sub_Type, Verse FROM verses WHERE id='".$_SESSION['Test']."'"; $Get_Verse_res = mysqli_query($conn, $Get_Verse_sql) or die(mysqli_error($conn)); if (mysqli_num_rows($Get_Verse_res) < 1) { //this Event does not exist $display_block = "You have selected an invalid Verse. 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($conn); require('fpdf.php'); class PDF extends FPDF { var $B; var $I; var $U; var $HREF; function __construct($orientation='P', $unit='mm', $size='A4') { // Call parent constructor parent::__construct($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); //$b = substr($color,3,3); //$g = substr($color,4,6); //**** This is what I added to make it work and commented out the original above. $r = hexdec(substr($color,0,2)); $g = hexdec(substr($color,2,2)); $b = hexdec(substr($color,4,2)); //echo $r.'r<br>'; //echo $g.'g<br>'; //echo $b.'b<br>'; //exit(); $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->SetLeftMargin('float0'); $pdf->SetTextColor($r,$g,$b); $pdf->SetFont($_POST['fontface'],'',$_POST['font']); $pdf->SetXY($BoxX, $_POST['Top']); $pdf->Image($image,$floatx,$floaty,$floatw,$floath,'',''); $pdf->MultiCell($Cellw,$Cellh,$display_block,'' ,'C'); //$pdf->SetDisplayMode('fullpage',''); $pdf->SetFont(''); $pdf->Output('verse.pdf','D'); //end: ?>
  4. I can’t remember where I got it I think it was from my research on the internet. My memory is getting bad so I’m going to park this for a week or so as I have other commitments I need to concentrate on. Thanks for the help, ‘I will be back’!
  5. Sorry Guys I have been unavailable the last few days, that's why I haven't answered! I don't live and die for the need to code every minute of the day like you two do! I thougt I had seen the light!! My connection code is not a new PDO, its msqli. Changed that but still got an error: I understand that this normally means that you have not created a new PDO, in the connection code, but I have, so what's causing the error now! This is the connection file I am now using <?php //set up a couple of functions for use by database function get_db_conn_verse() { $host_name = "xxxxxxxxxxxx.hosting-data.io"; $database = "dbsxxxxxxx"; // Change your database name $username = "dbuxxxxxxx"; // Your database user id $password = "xxxxxxxx"; // Your password //connect to server and select database; you may need it $conn = new PDO($host_name, $username, $password, $database); printf("Connected"); //if connection fails, stop script execution $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); ?> I know you are all getting fed-up with my posts, but every time a suggestion is made I do try to implement the suggested changes. I am getting as fed up as you are and want to finish this project as it is taking far too long. I know I am not the best at understanding OOP & PDO as most of my programming was done over 10 years ago and my age and my memory is not very good now. If you would bear with me for a little longer I think I must be close to sorting this out!
  6. Sorry Guys I have been unavailable the last few days, that's why I haven't answered! I done live and die for the need to code every minute of the day like you two do! I think I have seen the light!! My connection code is not a new PDO, its msqli. Changed that but still got an error: I understand that this normally means that you have not created a new PDO, in the connection code, but I have, so what's causing the error now! $conn = new PDO($host_name, $username, $password, $database); The code in the connection file had a mysqli error statement, so obviously it was the wrong statement for PDO so I tried this: That is obviously wrong
  7. I'm new to PDO and am not yet familiar with the language. I am designing a form and am having problems with the prepare statement. The error is on this line: The $conn is my connection code and $sql is an INSERT query. The data for the query is obtained from a form within this file using $_POST. Here is the complete file: <?php session_start(); error_reporting (E_ALL); ini_set('display_errors','1'); $errors = array(); $conn=''; require_once "conn/connect_seniorform.php"; // MORE PHP CODE IF ANY if($_SERVER["REQUEST_METHOD"] == "POST") { // read the inputs if (isset ($_POST['fname'])){ $fname = htmlentities($_POST['fname'],ENT_QUOTES);} if (isset ($_POST['sname'])){ $sname = htmlentities($_POST['sname'],ENT_QUOTES);} if (isset ($_POST['email'])){ $email = htmlentities($_POST['email'],ENT_QUOTES);} if (isset ($_POST['addr'])){ $addr = htmlentities($_POST['addr'],ENT_QUOTES);} if (isset ($_POST['phone'])){ $phone = htmlentities($_POST['phone'],ENT_QUOTES);} if (isset ($_POST['mob'])){ $mob = htmlentities($_POST['mob'],ENT_QUOTES); } if (isset($_POST['bmfa_no'])){ $bmfa_no = htmlentities($_POST['bmfa_no'],ENT_QUOTES);} if (isset($_POST['caa_no'])){ $caa_no = htmlentities($_POST['caa_no'],ENT_QUOTES);} if (isset ($_POST['rewd'])){ $rewd = htmlentities($_POST['rewd'],ENT_QUOTES);} if (isset ($_POST['fam'])){ $fam = htmlentities($_POST['fam'],ENT_QUOTES);} if (isset($_POST['ctry'])){ $ctry = htmlentities($_POST['ctry'],ENT_QUOTES);} if (isset($_POST['ctry_bmfa'])){ $ctry_bmfa = htmlentities($_POST['ctry_bmfa'],ENT_QUOTES);} if (isset ($_POST['bdf'])){ $bdf = htmlentities($_POST['bdf'],ENT_QUOTES);} if (isset($_POST['payopt'])){ $payopt = htmlentities($_POST['payopt'],ENT_QUOTES);} if (isset ($_POST['payopt'])){ $pay = htmlentities($_POST['pay'],ENT_QUOTES);} if (isset ($_POST['date'])){ $date = htmlentities($_POST['date'],ENT_QUOTES);} if (isset ($_POST['sign'])){ $sign = htmlentities($_POST['sign'],ENT_QUOTES);} // process the data now if (count($errors) == 0) { $sql = "INSERT INTO senior_dat(fname,sname,email,dob,addr,phone,mob,bmfa_no,caa_no,rewd,fam,ctry,ctry_bmfa,bdf,payopt,pay,date,sign) VALUES (:fname, :sname, :email,:dob, :addr, :phone, :mob, :bmfa_no, :caa_no, :rewd, :fam, :ctry, :ctry_bmfa, :bdf, :payopt, :pay, :date, :sign)"; $stmt = $conn->prepare($sql); //<<< error here $parms = array( 'fname'=>$fname, 'sname'=>$sname, 'email'=>$email, 'addr'=>$addr, 'phone'=>$phone, 'mob'=>$mob, 'bmfa_no'=>$bmfa_no, 'caa_no'=>$caa_no, 'rewd'=>$rewd, 'fam'=>$fam, 'ctry'=>$ctry, 'ctry_bmfa'=>$ctry_bmfa, 'bdf'=>$bdf, 'payopt'=>$payopt, 'pay'=>$pay, 'date'=>$date, 'sign'>$sign ); if (!$stmt->execute($parms)) $errors[] = "Insert query did not run"; else $errors[] = "Your entries have been accepted"; } } else // no inputs yet { $fname = ''; $sname = ''; $email = ''; $addr = ''; $phone = ''; $mob = ''; $bmfa_no = ''; $caa_no = ''; $rewd = ''; $fam = ''; $ctry = ''; $ctry_bmfa = ''; $bdf = ''; $pay_opt = ''; $pay = ''; $date = ''; $sign = ''; } // Done with the inputs - redisplay the form screen with the messages we produced. // // implode the errrors array to show the result message or the errors $errmsg = implode('<br>', $errors); echo " <!DOCTYPE html> <html lang='en'> <head> <style type='text/css'> #form_box { position:relative; float:left; margin:3% 1%; padding:5px; border:2px solid black; } .red{color:red;} </style> </head> <body> "; echo " <div id='form_box'> <center> <h1>SENIOR RENEWAL FORM</h1> </center> "; if(!empty($errmsg)) echo "<p class='red'>$errmsg</p>"; echo " <form method='POST'> <label><b>First Name: </b> <br> <input type='text' name='fname' size='20' maxlength='40' value='$fname' required> </label> <br> <label><b>Surname: </b> <br> <input type='text' name='sname' size='20' maxlength='40' value='$sname' required> </label> <br> <label><b>Email: </b> <br> <input type='text' name='email' size='20' maxlength='40' value='$email' required> </label> <br><br> <label><b>Address: </b> <br> <input type='textarea' name='addr' rows='4' cols='50 value='$addr' required> </label> <br> <label><b>Phone number:</br> <input type='tel' name='phone' 'min=12' max=16' value='$phone' required> </label> <br> <label> <b>Mobile number:</br> <input type='tel' name='mob' 'min=12' 'max=16' value'$mob' required> </label> <br> <label BMFA No: <input type='number' name='bmfa_no' value='$bmfa_no' required> </label> <br> <label CAA Operator No: <input type='text' name='caa_no' value='$caa_no' required><br> </label> <label Do you wish that the club obtains your BMFA membership, Insurance & CAA renewal: <select name='club_membership' id='club_membership'> <option value='Select Yes or No'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> </select> </label> <br> <label for='Ctry'>Are you a Country Member:</label> <select name='Ctry' id='Ctry'> <option value='blank'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> </select> <br> <label for='caa'>If you answered YES to the previous question,. have you a current BMFA and CAA membership:</label> <select name='caa' id='caa'> <option value='blank'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> <option value='na'>N/A</option> </select> <br> <label for='rewd'>Do you wish to purchase a BMFA Membership/Reward Card:</label> <select name='rewd' id='rewd'> <option value='blank'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> </select> <br> <label for='fam'>Are you a family member:</label> <select name='fam' id='fam'> <option value='blank'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> </select> <br> <label for='bdf'>Do you wish to join the British Drone flyers Association, instead of the BMFA:</label> <select name='bdf' id='bdf'> <option value='blank'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> </select> <p>Please note that if you join the BDF you can also fly fixed wing/ helicopters as well!</p> <br> <label for='pay_opt'>Ho do you wish to pay:</label> <select name='pay_opt' id='pay_opt'> <option value='blank'> </option> <option value='chq'>CHEQUE</option> <option value='csh'>CASH</option> <option value='bacs'>BACS</option> </select> <br> <p><b>Payment required: &#163;</b><input type='text' name='pay' size='20' maxlength='40'/></p> <br> <p style='background-color:tomato;'>I apply for membership of the 1066 Model Flying Club and agree to abide by the rules. By doing so agree to allow the club to use your details in respect of the GDPR regulations for the processing of your renewal, a copy of which can be found on the club website members page. </p> <br> <label for='date'>Date:</label> <input type='text' id='date' name='date' pattern='[0-9]{2}/[0-9]{2}/[0-9]{4}' required> <br> <label for='sign'>Sign here:</label> <input type='text' id='sign' name='sign' required> <br> <input type='submit' value='Submit'> </form> </div> "; I hope someone can help me?
  8. Thanks for that Barand! That cleared that error, but I now have a problem with the prepare statement. As this post is getting very long and the subject is different I think I will start a new thread.
  9. I will copy your code tomorrow. I did change the missing curly brackets on line 21. I may have misunderstood I thought the one on line 20 was the opening bracket for the missing one on line 21. Is this correct or not? I removed the superfluous closing bracket on line 75.
  10. Barand Changed that but still had the same errors!
  11. Ginerjm I am trying to expand my knowledge by doing a sort course via Udemy. I have just got to the bit about showing errors, so I tried putting it into my code, here is the code: $ErrorInformation=$conn->errorInfo(); print_r($ErrorInformation); When I run the code it fails with the following message: That's the same sort of error I am getting with the items in my form!
  12. Hi Ginerjm 1> Yes I do have the correct form tags, 2>The closing one also is after the submit. 3> Yes that is the line 131 I am assuming the vars are the following: if (isset ($_POST['fname'])){ $fname = htmlentities($_POST['fname'],ENT_QUOTES);} if (isset ($_POST['sname'])){ $sname = htmlentities($_POST['sname'],ENT_QUOTES);} if (isset ($_POST['email'])){ $email = htmlentities($_POST['email'],ENT_QUOTES);} if (isset ($_POST['addr'])){ $addr = htmlentities($_POST['addr'],ENT_QUOTES);} if (isset ($_POST['phone'])){ $phone = htmlentities($_POST['phone'],ENT_QUOTES);} if (isset ($_POST['mob'])){ $mob = htmlentities($_POST['mob'],ENT_QUOTES);} if (isset($_POST['bmfa_no'])){ $bmfa_no = htmlentities($_POST['bmfa_no'],ENT_QUOTES);} if (isset($_POST['caa_no'])){ $caa_no = htmlentities($_POST['caa_no'],ENT_QUOTES);} if (isset ($_POST['rewd'])){ $rewd = htmlentities($_POST['rewd'],ENT_QUOTES);} if (isset ($_POST['fam'])){ $fam = htmlentities($_POST['fam'],ENT_QUOTES);} if (isset($_POST['ctry'])){ $ctry = htmlentities($_POST['ctry'],ENT_QUOTES);} if (isset($_POST['ctry_bmfa'])){ $ctry_bmfa = htmlentities($_POST['ctry_bmfa'],ENT_QUOTES);} if (isset ($_POST['bdf'])){ $bdf = htmlentities($_POST['bdf'],ENT_QUOTES);} if (isset($_POST['payopt'])){ $payopt = htmlentities($_POST['payopt'],ENT_QUOTES);} if (isset ($_POST['payopt'])){ $pay = htmlentities($_POST['pay'],ENT_QUOTES);} if (isset ($_POST['date'])){ $date = htmlentities($_POST['date'],ENT_QUOTES);} if (isset ($_POST['sign'])){ $sign = htmlentities($_POST['sign'],ENT_QUOTES);} if($_SERVER["REQUEST_METHOD"] == "POST") As you can see that is just above the $_SERVER["REQUEST_METHOD] == "POST" is this what you mean? I tried that and I still get the same errors? Would it be because I am using htmlentities? Can't think of anything else!
  13. Ginerjm Here is the section with lines in error: <form method='POST'> <label><b>First Name: </b> <br> <input type='text' name='fname' size='20' maxlength='40' value='$fname' required> </label> <br> <label><b>Surname: </b> <br> <input type='text' name='sname' size='20' maxlength='40' value='$sname' required> </label> <br> <label><b>Email: </b> <br> <input type='text' name='email' size='20' maxlength='40' value='$email' required> </label> <br><br> <label><b>Address: </b> <br> <input type='textarea' name='addr' rows='4' cols='50 value='$addr' required> </label> <br> <label><b>Phone number:</br> <input type='tel' name='phone' 'min=12' max=16' value='$phone' required> </label> <br> <label> <b>Mobile number:</br> <input type='tel' name='mob' 'min=12' 'max=16' value'$mob' required> </label> <br> <label BMFA No: <input type='number' name='bmfa_no' value='$bmfa_no' required> </label> <br> <label CAA Operator No: <input type='text' name='caa_no' value='$caa_no' required><br> </label> See the attached picture for which lines are in error. thank you!
  14. Hi Ginerjm Here is the code: <?php session_start(); error_reporting (E_ALL); ini_set('display_errors','1'); $errors = array(); require "conn/connect_seniorform.php"; // MORE PHP CODE IF ANY if($_SERVER["REQUEST_METHOD"] == "POST") { // read the inputs if (isset ($_POST['fname'])){ $fname = htmlentities($_POST['fname'],ENT_QUOTES);} if (isset ($_POST['sname'])){ $sname = htmlentities($_POST['sname'],ENT_QUOTES);} if (isset ($_POST['email'])){ $email = htmlentities($_POST['email'],ENT_QUOTES);} if (isset ($_POST['addr'])){ $addr = htmlentities($_POST['addr'],ENT_QUOTES);} if (isset ($_POST['phone'])){ $phone = htmlentities($_POST['phone'],ENT_QUOTES);} if (isset ($_POST['mob'])){ $mob = htmlentities($_POST['mob'],ENT_QUOTES); if (isset($_POST['bmfa_no'])){ $bmfa_no = htmlentities($_POST['bmfa_no'],ENT_QUOTES);} if (isset($_POST['caa_no'])){ $caa_no = htmlentities($_POST['caa_no'],ENT_QUOTES);} if (isset ($_POST['rewd'])){ $rewd = htmlentities($_POST['rewd'],ENT_QUOTES);} if (isset ($_POST['fam'])){ $fam = htmlentities($_POST['fam'],ENT_QUOTES);} if (isset($_POST['ctry'])){ $ctry = htmlentities($_POST['ctry'],ENT_QUOTES);} if (isset($_POST['ctry_bmfa'])){ $ctry_bmfa = htmlentities($_POST['ctry_bmfa'],ENT_QUOTES);} if (isset ($_POST['bdf'])){ $bdf = htmlentities($_POST['bdf'],ENT_QUOTES);} if (isset($_POST['payopt'])){ $payopt = htmlentities($_POST['payopt'],ENT_QUOTES);} if (isset ($_POST['payopt'])){ $pay = htmlentities($_POST['pay'],ENT_QUOTES);} if (isset ($_POST['date'])){ $date = htmlentities($_POST['date'],ENT_QUOTES);} if (isset ($_POST['sign'])){ $sign = htmlentities($_POST['sign'],ENT_QUOTES);} // process the data now if (count($errors) == 0) { $sql = "INSERT INTO senior_dat(fname,sname,email,dob,addr,phone,mob,bmfa_no,caa_no,rewd,fam,ctry,ctry_bmfa,bdf,payopt,pay,date,sign) VALUES (:fname, :sname, :email,:dob, :addr, :phone, :mob, :bmfa_no, :caa_no, :rewd, :fam, :ctry, :ctry_bmfa, :bdf, :payopt, :pay, :date, :sign)"; $stmt = $pdo->prepare($sql); $parms = array( 'fname'=>$fname, 'sname'=>$sname, 'email'=>$email, 'addr'=>$addr, 'phone'=>$phone, 'mob'=>$mob, 'bmfa_no'=>$bmfa_no, 'caa_no'=>$caa_no, 'rewd'=>$rewd, 'fam'=>$fam, 'ctry'=>$ctry, 'ctry_bmfa'=>$ctry_bmfa, 'bdf'=>$bdf, 'payopt'=>$payopt, 'pay'=>$pay, 'date'=>$date, 'sign'>$sign ); if (!$stmt->execute($parms)) $errors[] = "Insert query did not run"; else $errors[] = "Your entries have been accepted"; } } else // no inputs yet { $fname = ''; $sname = ''; $email = ''; $addr = ''; $phone = ''; $mob = ''; $bmfa_no = ''; $caa_no = ''; $rewd = ''; $fam = ''; $ctry = ''; $ctry_bmfa = ''; $bdf = ''; $pay_opt = ''; $pay = ''; $date = ''; $sign = ''; } } // Done with the inputs - redisplay the form screen with the messages we produced. // // implode the errrors array to show the result message or the errors $errmsg = implode('<br>', $errors); echo " <!DOCTYPE html> <html lang='en'> <head> <style type='text/css'> #form_box { position:relative; float:left; margin:3% 1%; padding:5px; border:2px solid black; } .red{color:red;} </style> </head> <body> "; echo " <div id='form_box'> <center> <h1>SENIOR RENEWAL FORM</h1> </center> "; if(!empty($errmsg)) echo "<p class='red'>$errmsg</p>"; echo " <form method='POST'> <label><b>First Name: </b> <br> <input type='text' name='fname' size='20' maxlength='40' value='$fname' required> </label> <br> <label><b>Surname: </b> <br> <input type='text' name='sname' size='20' maxlength='40' value='$sname' required> </label> <br> <label><b>Email: </b> <br> <input type='text' name='email' size='20' maxlength='40' value='$email' required> </label> <br><br> <label><b>Address: </b> <br> <input type='textarea' name='addr' rows='4' cols='50 value='$addr' required> </label> <br> <label><b>Phone number:</br> <input type='tel' name='phone' 'min=12' max=16' value='$phone' required> </label> <br> <label> <b>Mobile number:</br> <input type='tel' name='mob' 'min=12' 'max=16' value'$mob' required> </label> <br> <label BMFA No: <input type='number' name='bmfa_no' value='$bmfa_no' required> </label> <br> <label CAA Operator No: <input type='text' name='caa_no' value='$caa_no' required><br> </label> <label Do you wish that the club obtains your BMFA membership, Insurance & CAA renewal: <select name='club_membership' id='club_membership'> <option value='Select Yes or No'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> </select> </label> <br> <label for='Ctry'>Are you a Country Member:</label> <select name='Ctry' id='Ctry'> <option value='blank'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> </select> <br> <label for='caa'>If you answered YES to the previous question,. have you a current BMFA and CAA membership:</label> <select name='caa' id='caa'> <option value='blank'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> <option value='na'>N/A</option> </select> <br> <label for='rewd'>Do you wish to purchase a BMFA Membership/Reward Card:</label> <select name='rewd' id='rewd'> <option value='blank'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> </select> <br> <label for='fam'>Are you a family member:</label> <select name='fam' id='fam'> <option value='blank'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> </select> <br> <label for='bdf'>Do you wish to join the British Drone flyers Association, instead of the BMFA:</label> <select name='bdf' id='bdf'> <option value='blank'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> </select> <p>Please note that if you join the BDF you can also fly fixed wing/ helicopters as well!</p> <br> <label for='pay_opt'>Ho do you wish to pay:</label> <select name='pay_opt' id='pay_opt'> <option value='blank'> </option> <option value='chq'>CHEQUE</option> <option value='csh'>CASH</option> <option value='bacs'>BACS</option> </select> <br> <p><b>Payment required: &#163;</b><input type='text' name='pay' size='20' maxlength='40'/></p> <br> <p style='background-color:tomato;'>I apply for membership of the 1066 Model Flying Club and agree to abide by the rules. By doing so agree to allow the club to use your details in respect of the GDPR regulations for the processing of your renewal, a copy of which can be found on the club website members page. </p> <br> <label for='date'>Date:</label> <input type='text' id='date' name='date' pattern='[0-9]{2}/[0-9]{2}/[0-9]{4}' required> <br> <label for='sign'>Sign here:</label> <input type='text' id='sign' name='sign' required> <br> <input type='submit' value='Submit'> </form> </div> "; exit(); Thank for your help!
  15. What DON'T understand is the fact that I thought I had mitigated the errors in the script lines 10 -31 Viz: $fname = htmlentities($_POST['fname'],ENT_QUOTES); to $sign = htmlentities............ Where I had undefined variables I added an isset statement, but why am I getting errors in the form script now with some of the variables that I have used the isset statement previously in the lines 10-31? I have now added the isset to ALL the fields in that set of code. What I don't understand the connection between the variables in the post section and those in the form. Surely if I had set the variable with isset it surely would be true for the variables set in the form? Regarding this going on so long, perhaps I should have started a new post for each different problem that I encountered as I have bee working through this project? The only difference to the script I posted in my last post is the if(isset.. line for each variable.
×
×
  • 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.