arcset Posted July 11, 2008 Share Posted July 11, 2008 I am having a problem with the following code. It will not show the post from the mysql database. I havent had this problem before when i have done this so maybe my tired eyes are missing a mistake in the code. CS.php (Connection String) <?php $host="000.000.000.000"; // Host name $username="username"; // Mysql username $password="password"; // Mysql password $db_name="database"; // Database name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); ?> test.php (page i want to display contents of mysql query) <?php include("CS.php"); $sql = "SELECT post FROM indexphp WHERE locate = '1'";//I belive its right did the query in phpMyAdmin and it returned the results $rows = mysql_query($sql);//run the query $row = 0; while($row < mysql_num_rows($rows)) { //grab the rows from the sql array $post = mysql_result($rows, $row, 0); echo = $post; $row = $row + 1; } ?> Link to comment https://forums.phpfreaks.com/topic/114329-having-problem-with-a-include-connection-string/ Share on other sites More sharing options...
discomatt Posted July 11, 2008 Share Posted July 11, 2008 Are you getting any errors at all? Try this <?php include("CS.php"); $sql = "SELECT post FROM indexphp WHERE locate = '1'";//I belive its right did the query in phpMyAdmin and it returned the results if ( ($result = mysql_query($sql)) === FALSE ) exit( 'Error with query syntax' ); if ( mysql_num_rows($result) < 1 ) exit( 'Now rows found!' ); while( $row = mysql_fetch_assoc($result) ) echo $row['post']; ?> Link to comment https://forums.phpfreaks.com/topic/114329-having-problem-with-a-include-connection-string/#findComment-587908 Share on other sites More sharing options...
arcset Posted July 11, 2008 Author Share Posted July 11, 2008 Figured it out it was 1 simple coding error lol Tired eyes. It was echo ="" shouldve been just echo "" Link to comment https://forums.phpfreaks.com/topic/114329-having-problem-with-a-include-connection-string/#findComment-587919 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.