php - MySQL returning blank rows that contain HTML -
i'm working on website , has table in mysql contains html couple of rows. every time try pull data table, returns "" rows containing html. other rows, ones without html, return correct data. escaped double , single quotes, , entire row on single line (no line breaks). i've been trying solve problem while now, , can't figure out. ideas?
<?php $con = mysqli_connect('localhost', 'exampleuser', 'examplepass', 'exampledb'); if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } $query = "select * publications;"; $result = mysqli_query($con, $query); while ($row = mysqli_fetch_row($result)) { echo "\n<br>\"" . $row['publications'] . "\"\n<br>"; } ?> the html i'm putting in long ill paste first section. remember, no line breaks in html. put them in easier read.
<p class="msotitle"><span style="font-size: 12pt;">publications</span><span style="font- size: 12pt; font-weight: normal;"></span></p><p class="msonormal"><strong> <span> </span></strong></p><p class="msonormal" style="margin-left: 0.25in; text-indent: -0.25in;">1. <strong><span style="font-weight: normal;">c. v. krishnan , m. garnett, electrochemical behavior of super antioxidant, α-</span></strong></p><p class="msonormal" style="margin-left: 0.25in; text-indent: -0.25in;"><strong><span style="font-weight: and what's returned:
""
as per comments exchanged between , i. (to close question)
notice: undefined index: publications in /home/garnett/public_html/test.php on line 14
this stems column being named publications , not publications.
$row['publications'] , $row['publications'] two different animals altogether.
the column name case-sensitive, , why not getting data outputted.
using error reporting @ top of files, reveal potential errors, if ever found in code, have suggestive comment.
error_reporting(e_all); ini_set('display_errors', 1); http://php.net/manual/en/function.error-reporting.php
as
or die(mysqli_error($con))mysqli_query()
edit:
as noted e-rock in comment:
"mysqli_fetch_row() returns enumerated array of row data. want mysqli_fetch_assoc() if you're expecting associative array". e-rock.
Comments
Post a Comment