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 Quote 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) Quote 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 Quote 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 Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.