muffin100 Posted October 18, 2006 Share Posted October 18, 2006 I have a script like this:[code]<?phpmysql_connect('10.0.35.4','testuser','test');mysql_select_db('helpdesk');$result="SELECT * FROM login";$row=mysql_fetch_array($result);// display the 8 columns of results in a table by// looping through the array of results, $result, print "<body bgcolor='ffeecc'>"; echo "<table>"; do { echo "<tr>"; echo "<td>".$row[0]."</td><td>".$row[1]."</td><td>".$row[2]; echo "</td><td>".$row[3]."</td>"; echo "</tr>";} while ($row= mysql_fetch_array($result)); print "</table></body>";?>[/code]but the problem is that nothing shows on the page, it should show the all the data in the login database and now it's only showing a background colour and not even a table. I have no problem using:SELECT * from login;on the mysql prompt on the server with the testuser. Here is the Mysql info of the phpinfo page:mysqlMySQL Support enabledActive Persistent Links 0Active Links 0Client API version 3.23.49MYSQL_MODULE_TYPE builtinMYSQL_SOCKET /tmp/mysql.sockMYSQL_INCLUDE no valueMYSQL_LIBS no valueDirective Local Value Master Valuemysql.allow_persistent On Onmysql.connect_timeout 60 60mysql.default_host no value no valuemysql.default_password no value no valuemysql.default_port no value no valuemysql.default_socket no value no valuemysql.default_user no value no valuemysql.max_links Unlimited Unlimitedmysql.max_persistent Unlimited Unlimitedmysql.trace_mode Off OffIs there anything wrong with the installation?By the way is there another ways of testing for PHP connection to Mysql? Quote Link to comment https://forums.phpfreaks.com/topic/24293-php-and-mysql-connection-problem/ Share on other sites More sharing options...
HuggieBear Posted October 18, 2006 Share Posted October 18, 2006 You need to query the database first. Try this:[code]<?phpmysql_connect('10.0.35.4','testuser','test');mysql_select_db('helpdesk');$sql="SELECT * FROM login";$result = mysql_query($sql); // This was what you were missing$row = mysql_fetch_array($result)[/code]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/24293-php-and-mysql-connection-problem/#findComment-110440 Share on other sites More sharing options...
muffin100 Posted October 18, 2006 Author Share Posted October 18, 2006 I changed the code to the one you provided but the page is still blank.I reckon it's a connection problem through PHP and Mysql.You have other suggestions?Thanks anyway Quote Link to comment https://forums.phpfreaks.com/topic/24293-php-and-mysql-connection-problem/#findComment-110908 Share on other sites More sharing options...
ruano84 Posted October 18, 2006 Share Posted October 18, 2006 Hi,I suggest to write this line of code after each function of mysql:echo mysql_error();Bye Quote Link to comment https://forums.phpfreaks.com/topic/24293-php-and-mysql-connection-problem/#findComment-110910 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.