blink359 Posted November 9, 2010 Share Posted November 9, 2010 Hi, Im getting this error with my script that im using to try and echo content for my website: Parse error: syntax error, unexpected T_ECHO in /home/a9855336/public_html/test.php on line 16 my php code is <?php $host="mysql12.000webhost.com"; // Host name $username="a9855336_root"; // Mysql username $password="n4th4n%"; // Mysql password $db_name="a9855336_mail"; // Database name // Connect to server and select databse. mysql_connect($host, $username, $password); mysql_select_db($db_name); $query = "SELECT title, content, FROM members where ID = 1"; $result = mysql_query($query); $row = mysql_fetch_array($result) echo $row['title']; ?> html stuff <?php echo $row['content']; ?> If anyone can help me fix this problem or sugguest a dfiferent way to go about this it would be greatly appriciated. Thanks, Blink359 Link to comment https://forums.phpfreaks.com/topic/218188-echoing-data-from-a-mysql-database-error/ Share on other sites More sharing options...
revraz Posted November 9, 2010 Share Posted November 9, 2010 Missing semi colon $row = mysql_fetch_array($result) Link to comment https://forums.phpfreaks.com/topic/218188-echoing-data-from-a-mysql-database-error/#findComment-1132194 Share on other sites More sharing options...
blink359 Posted November 9, 2010 Author Share Posted November 9, 2010 <?php $host="mysql12.000webhost.com"; // Host name $username="a9855336_root"; // Mysql username $password="n4th4n%"; // Mysql password $db_name="a9855336_mail"; // Database name // Connect to server and select databse. mysql_connect($host, $username, $password); mysql_select_db($db_name); $query = "SELECT title, content, FROM members WHERE id = '1'"; $result = mysql_query($query); $row = mysql_fetch_array($result); echo $row['title']; echo $row['content']; ?> Its now got the semi colon but Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/a9855336/public_html/test.php on line 14 Its this i was initially wanting to get fixed i obviously took the semi colon out by axedent before post Link to comment https://forums.phpfreaks.com/topic/218188-echoing-data-from-a-mysql-database-error/#findComment-1132215 Share on other sites More sharing options...
revraz Posted November 9, 2010 Share Posted November 9, 2010 Means your query is failing. mysql_error is good to use to find query errors $query = "SELECT title, content, FROM members WHERE id = '1'"; Remove the comma after content Link to comment https://forums.phpfreaks.com/topic/218188-echoing-data-from-a-mysql-database-error/#findComment-1132230 Share on other sites More sharing options...
blink359 Posted November 9, 2010 Author Share Posted November 9, 2010 Thanks very much using mysql_error(); i found my problem Thanks, Blink359 Link to comment https://forums.phpfreaks.com/topic/218188-echoing-data-from-a-mysql-database-error/#findComment-1132249 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.