FreakingOUT Posted May 17, 2014 Share Posted May 17, 2014 PHP = 5.5.14 MySQL = 5.2.17 This simple .php script works as a standalone OK: <?php require '<snip partial URL>mysqli.php'; // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $result = mysqli_query($con,"SELECT `callsign`, `qth`, `submitted` FROM `lqplogs` ORDER BY `callsign`"); echo "<table> <tr> <th><u>CALLSIGN</u></th><th><u>QTH</u></th><th><u>LOG SUBMITTED</u></th> </tr>"; while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['callsign'] . "</td>"; echo "<td>" . $row['qth'] . "</td>"; echo "<td>" . $row['submitted'] . "</td>"; echo "</tr>"; } echo "</table>"; mysqli_close($con); ?> A separate .html page with other info works by itself OK too, but when I try to embed the PHP script (with PHP start & end tags, of course) *between* these HTML tags: <table> <tr> <td> ... Full PHP Script Embedded here... </td> </tr> </table> I get this mess: "; while($row = mysqli_fetch_array($result)) { echo ""; echo ""; echo ""; echo ""; echo ""; } echo " CALLSIGN QTH LOG SUBMITTED " . $row['callsign'] . " " . $row['qth'] . " " . $row['submitted'] . " "; mysqli_close($con); ?> Any thoughts as to why are appreciated. Thanks! - FreakingOUT Quote Link to comment Share on other sites More sharing options...
FreakingOUT Posted May 17, 2014 Author Share Posted May 17, 2014 P.S. I also tried embedding the PHP script WITHOUT the other <table> structure in the .html file, and get this: CALLSIGNQTHLOG SUBMITTED "; while($row = mysqli_fetch_array($result)) { echo ""; echo "" . $row['callsign'] . ""; echo "" . $row['qth'] . ""; echo "" . $row['submitted'] . ""; echo ""; } echo ""; mysqli_close($con); ?> Ugh ;-( - FreakingOUT Quote Link to comment Share on other sites More sharing options...
Barand Posted May 17, 2014 Share Posted May 17, 2014 Have you looked at the page source to get any clues? Quote Link to comment Share on other sites More sharing options...
ignace Posted May 17, 2014 Share Posted May 17, 2014 .html is not parsed by PHP. You have to name your file with a .php for it to work. Quote Link to comment Share on other sites More sharing options...
Solution FreakingOUT Posted May 17, 2014 Author Solution Share Posted May 17, 2014 .html is not parsed by PHP. You have to name your file with a .php for it to work. Yes, I checked the page source and then thought *maybe* I needed to put the (require '<snip partial URL>mysqli.php' statement at the front starting with the PHP tags and ending the page with the PHP tags. It worked! I had mistakenly assumed that the PHP code (encapsulated in the PHP tags) inside the HTML would work. Another "Senior Moment", as now recall having done things this way in the past. My bad ;-( Thanks for the reminder as well. - FreakingOUT Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted May 17, 2014 Share Posted May 17, 2014 also, the require statement for your database connection mysqli.php file ISN'T a URL, that's a file system path. URLs (that are used by browsers to request pages on a web server) are not the same thing as file system paths (that are used by php on the server to read files.) 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.