ttsprez Posted October 1, 2018 Share Posted October 1, 2018 I'm new to PHP but learning... so please bear with me. I have an HTML page that contains a link to a PHP file that is supposed to generate a pdf using an HTML template and MySQL data so that the customer gets a pre-prepared pdf document for download. I've been working on getting the code put together using NetBeans and with help from a very generous coach/angel, which has helped a lot. But I'd like to get other eyes on this for assistance in an effort to get this completed. I believe I am 90% done, just need a more trained eye to tell me what I'm doing wrong and how to get it fixed. I have put the error messages I'm receiving in the // comments and will color them in blue text for clarity. Any help I can get on this would be greatly appreciated. Also, in advance, to those nay-sayers who may happen to come along, read this and have the urge to critique without providing real help with their responses, please don't waste the time. I will not respond and if allowed, will delete it. By posting my issue, I know I'm not just looking for answers for me, but also, providing answers to those who come after me in search of the same. Quote Link to comment Share on other sites More sharing options...
Barand Posted October 1, 2018 Share Posted October 1, 2018 OK, so you have told us you have some code that doesn't work. What do you expect us to do with all that information? By the way, do you know anything about cars? Mine isn't working properly, perhaps you can you tell me what's wrong? Quote Link to comment Share on other sites More sharing options...
ginerjm Posted October 1, 2018 Share Posted October 1, 2018 As Barand has hinted - the forum is of better use when one provides the problem as well as the PERTINENT code that one thinks is causing the issue. In your post you have not provided either. PS - I'd like my car looked at too. Winter's coming! Quote Link to comment Share on other sites More sharing options...
ttsprez Posted October 1, 2018 Author Share Posted October 1, 2018 yeah, was getting to that and got sidetracked, then somehow posted the thread before I was able to add the code... think I've work out most of the problems but still getting Parse error: syntax error, unexpected end of file in /home1/thetitl1/public_html/pdforms/TX Title App.php on line 64 here goes the code. As for the car, I'd have to look at them...LOL <?php //create a connection to MySQL require 'dogs.php'; $servername = "x"; $username = "x"; $password = "x"; $dbname = "x"; $conn = mysqli_connect($servername,$username,$password,$dbname); // Create connection $db = new mysqli($servername, $username, $password, $database); // Check for errors if($db->connect_errno){ echo $db->connect_error; } //query for reference_code from 'forms' table $refcode = filter_input(INPUT_POST, 'reference_code'); // reference the Dompdf namespace require_once '/home1/thetitl1/public_html/pdforms/lib/dompdf/autoload.inc.php'; $dompdf = new Dompdf\Dompdf(); $options = new Options(); $options->set('isPhpEnabled','true'); $new_form = file_get_contents("TX_Title_App.html"); $dompdf = new Dompdf($options); $dompdf->loadHtml($new_form); // Execute query $query = mysqli_query($conn,("SELECT * FROM thetitl1_livesite754.form_data WHERE form_id IN SELECT id FROM thetitl1_livesite754.forms WHERE reference_code ='$refcode'")); //Replaces form_fields in html temp with "data" if ($result = mysqli_query($conn, $query)) { while ($row = mysqli_fetch_assoc($result)) { $new_form = str_replace($row["name"], $row["data"], $new_form); } // Always check for errors if($db->errno){ echo $db->error; } // (Optional) Setup the paper size and orientation $dompdf->setPaper(‘A4’, ‘portrait’); // Render the HTML as PDF $dompdf->render(); // Output the generated PDF to Browser $dompdf->stream(); // Save to file $output= $dompdf->output(); file_put_contents('TXTitleApp.pdf', $output); /* free result set */ mysqli_free_result($result); /* close connection */ mysqli_close($conn); ?> Quote Link to comment Share on other sites More sharing options...
Barand Posted October 1, 2018 Share Posted October 1, 2018 if ($result = mysqli_query($conn, $query)) { the "{" at the end of that line has no corresponding "}" anywhere Quote Link to comment Share on other sites More sharing options...
ttsprez Posted October 1, 2018 Author Share Posted October 1, 2018 so I put the "}" at the end... if ($result = mysqli_query($conn, $query)) { while ($row = mysqli_fetch_assoc($result)) { $new_form = str_replace($row["name"], $row["data"], $new_form); } } and got this: Fatal error: Uncaught Error: Class 'Options' not found in /home1/thetitl1/public_html/pdforms/TX Title App.php:25 Stack trace: #0 {main} thrown in /home1/thetitl1/public_html/pdforms/TX Title App.php on line 25 This is line 21 to 24 and nothing on line 25: // reference the Dompdf namespace require_once '/home1/thetitl1/public_html/pdforms/lib/dompdf/autoload.inc.php'; $dompdf = new Dompdf\Dompdf(); $options = new Options(); $options->set('isPhpEnabled','true'); Quote Link to comment Share on other sites More sharing options...
Barand Posted October 1, 2018 Share Posted October 1, 2018 Where is your "Options" class defined? Quote Link to comment Share on other sites More sharing options...
ttsprez Posted October 1, 2018 Author Share Posted October 1, 2018 (edited) isn't that what this is: $options = new Options(); $options->set('isPhpEnabled','true'); or is this what is missing: use Dompdf\Options; This is the snippet of code dealing with this: // reference the Dompdf namespace require_once '/home1/thetitl1/public_html/pdforms/lib/dompdf/autoload.inc.php'; $dompdf = new Dompdf\Dompdf(); $options = new Dompdf\Options(); $options = new Options(options); $options->set('isPhpEnabled','true'); $new_form = file_get_contents("TX_Title_App.html"); $dompdf = new Dompdf($options); $dompdf->loadHtml($new_form); Edited October 1, 2018 by ttsprez Quote Link to comment Share on other sites More sharing options...
ginerjm Posted October 2, 2018 Share Posted October 2, 2018 Barand's question was asking WHERE is the code for the class you want to use??? Usually there is an include/require statement bringing in the module that contains your actual code with all of its class properties and methods. We aren't see anything like that, just an attempt to use hence the error message telling you it is missing. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.