Log in

View Full Version : Resolved Can't Locate Syntax Error



Kage Kazumi
10-19-2012, 08:00 PM
Dreamweaver is popping a syntax error for line 8 (below), but I'm just starting out and can't figure out what is the issue. The Code:



<?php
include ('includes/connect.php');

function getPosts()) {
$query = mysql_query("SELECT * From posts") or die (mysql_error());
while($post = mysql_fetch_assoc($query)) {
echo "<h2>" . $post['Title'] . "by" . $post['Author'] . "</h2>";
echo $post['Content'];
}
}
?>



I am following a Youtube tutorial (http://www.youtube.com/watch?v=u3ry84gg0fw) and it looks the same as in the video and it executes in the video (12:23 time frame in video).

Note: Doing this on a localhost and not a live host.

keyboard
10-19-2012, 10:05 PM
Can you tell us what the error is?
Also, which line is line 8?


Also, the mysql functions are depricated.
You can take a look at this (http://www.dynamicdrive.com/forums/showthread.php?71716-mysql_*-is-being-deprecated-!&highlight=) thread.
But a lot of people still use mysql (but mysqli has more features).

bernie1227
10-19-2012, 10:56 PM
You've got an extra round bracket, it should be:


<?php
include ('includes/connect.php');

function getPosts() {
$query = mysql_query("SELECT * From posts") or die (mysql_error());
while($post = mysql_fetch_assoc($query)) {
echo "<h2>" . $post['Title'] . "by" . $post['Author'] . "</h2>";
echo $post['Content'];
}
}
?>