-1

I am trying to print list of articles from MYSQL but i keep getting error.

while($row  = mysql_fetch_assoc($query)){
    echo "<article class='post'>
                <h2><a style='color:#43484d' href='' " .$row['url']. ";</a></h2>
                    <ul class='meta'>
                        <li><span>level :</span> <span style='color:red'>" .$row['Level']. " </span></li>
                        <li><span>Negative votes by visitors :</span> " .$row['negativeVotes']. "</li>
                        <li><span>Positive votes by visitors :</span>" .$row['positiveVotes']. "</li>
                        <li><span  style='color:#000; cursor:pointer' class='fa fa-thumbs-o-up'></span></li>
                        <li><span  style='color:#000; cursor:pointer' class='fa fa-thumbs-o-down'></span></li>
                    </ul>
              </article>"
          }

    ?>

I am getting this

Parse error: syntax error, unexpected '}', expecting ',' or ';'.

What i have done wrong? Thank a lot!

Qirel
  • 25,449
  • 7
  • 45
  • 62
  • Add a semicolon `;` after `"` – Qirel Dec 09 '16 at 16:39
  • 3
    If you're writing new code, **_please_ don't use the `mysql_*` functions**. They are old and broken, were deprecated in PHP 5.5 (which is so old it no longer even receives security updates), and completely removed in PHP 7. Use [`PDO`](https://secure.php.net/manual/en/book.pdo.php) or [`mysqli_*`](https://secure.php.net/manual/en/book.mysqli.php) with _prepared statements_ and _parameter binding_ instead. See http://stackoverflow.com/q/12859942/354577 for details. – ChrisGPT was on strike Dec 09 '16 at 16:40
  • please share $query variable, it might be that the sql is not correctly written which is causing parsing errors. – Zeeshan Arif Dec 09 '16 at 16:44
  • This is the query: $query=mysql_query("SELECT * FROM webs "); $row=mysql_fetch_array($query); – Jessica Hoamster Dec 09 '16 at 17:12

1 Answers1

0

You missed a semi colon.

while($row  = mysql_fetch_assoc($query)){
    echo "<article class='post'>
                <h2><a style='color:#43484d' href='' " .$row['url']. ";</a></h2>
                    <ul class='meta'>
                        <li><span>level :</span> <span style='color:red'>" .$row['Level']. " </span></li>
                        <li><span>Negative votes by visitors :</span> " .$row['negativeVotes']. "</li>
                        <li><span>Positive votes by visitors :</span>" .$row['positiveVotes']. "</li>
                        <li><span  style='color:#000; cursor:pointer' class='fa fa-thumbs-o-up'></span></li>
                        <li><span  style='color:#000; cursor:pointer' class='fa fa-thumbs-o-down'></span></li>
                    </ul>
              </article>";
          }

    ?>
scottevans93
  • 1,119
  • 1
  • 9
  • 25