CanMan2004 Posted February 8, 2007 Share Posted February 8, 2007 Hi all I am using a very simple php script which i've uploaded to a server, but I get no result not do I get any errors, this is the same with any code im trying to use where it pulls content from a MySQL datababase. Can anyone give me any idea what it might be? Im battling with it to get anything to come up. <? $db_name ="****"; $server = "localhost"; $dbusername = "****"; $dbpassword = "****"; $connection = mysql_connect($server, $dbusername, $dbpassword) or die(mysql_error()); $db = mysql_select_db($db_name,$connection)or die(mysql_error()); $sql = mysql_query("SELECT * FROM documents ORDER BY value ASC")or die(mysql_error()); while($row = mysql_fetch_array($sql)) { print "".$row['id']."<br><br>"; } ?> Any help at all would be great. Thanks Ed Quote Link to comment https://forums.phpfreaks.com/topic/37599-php-problems/ Share on other sites More sharing options...
CanMan2004 Posted February 8, 2007 Author Share Posted February 8, 2007 Is there another way I should write the code? we have to connect to the database through a SSH client if that helps in anyway Quote Link to comment https://forums.phpfreaks.com/topic/37599-php-problems/#findComment-179765 Share on other sites More sharing options...
JasonLewis Posted February 8, 2007 Share Posted February 8, 2007 change this: while($row = mysql_fetch_array($sql)) { print "".$row['id']."<br><br>"; } to this: $i = 0; while($row = mysql_fetch_array($sql)){ echo $row['id']." - I = {$i}<br><br>"; $i++; } and see if it outputs any numbers. should output 0, 1, 2 or however much results are in the database. Quote Link to comment https://forums.phpfreaks.com/topic/37599-php-problems/#findComment-179768 Share on other sites More sharing options...
CanMan2004 Posted February 8, 2007 Author Share Posted February 8, 2007 I still get nothing displayed on the page Quote Link to comment https://forums.phpfreaks.com/topic/37599-php-problems/#findComment-179771 Share on other sites More sharing options...
JasonLewis Posted February 8, 2007 Share Posted February 8, 2007 do you have anything in your database? put this above your while loop: echo "Rows: ".mysql_num_rows($sql)."<br>"; make sure its below your $sql line though. tell me how much rows it displays. Quote Link to comment https://forums.phpfreaks.com/topic/37599-php-problems/#findComment-179773 Share on other sites More sharing options...
CanMan2004 Posted February 8, 2007 Author Share Posted February 8, 2007 Hi That doesnt seem to work, nor does it print anything. What's strange, is that if I place <? print "testing"; ?> and put it right at the top of my php page, above all the db connection details, then it prints "testing" without a problem, but if I place <? print "testing"; ?> and put this anywhere under the db connection details, then it wont print anything. Does that make sense? Why would that happen? Thanks Ed Quote Link to comment https://forums.phpfreaks.com/topic/37599-php-problems/#findComment-179779 Share on other sites More sharing options...
CanMan2004 Posted February 8, 2007 Author Share Posted February 8, 2007 Can anyone help me on this? Getting no result despite what I do Quote Link to comment https://forums.phpfreaks.com/topic/37599-php-problems/#findComment-179786 Share on other sites More sharing options...
fiddy Posted February 8, 2007 Share Posted February 8, 2007 If you are getting a blank page. then there should be problem with the DB connection i guess. It might not show you errors if error reporting is off in your php.ini. Just a Thought... Quote Link to comment https://forums.phpfreaks.com/topic/37599-php-problems/#findComment-179787 Share on other sites More sharing options...
CanMan2004 Posted February 8, 2007 Author Share Posted February 8, 2007 Is there a default port number that is used as my port number maybe different, could this be the reason? Quote Link to comment https://forums.phpfreaks.com/topic/37599-php-problems/#findComment-179788 Share on other sites More sharing options...
Tyche Posted February 8, 2007 Share Posted February 8, 2007 It sounds like your are generating a mysql_error but the die statement is not closing off your html so no error is visible in your browser Try replacing the 3 occurances of die(mysql_error()) with die(mysql_error()."</body></html>") Quote Link to comment https://forums.phpfreaks.com/topic/37599-php-problems/#findComment-179791 Share on other sites More sharing options...
CanMan2004 Posted February 8, 2007 Author Share Posted February 8, 2007 I've just tried <?php $link = mysql_connect('localhost', 'xxx', 'xxx'); print "hello"; if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_close($link); ?> Anything test page text you put above that code displays on the page, but anything that is added under that code, does not work. Strange, totally confused it wont even tell me it cant connect Quote Link to comment https://forums.phpfreaks.com/topic/37599-php-problems/#findComment-179792 Share on other sites More sharing options...
CanMan2004 Posted February 8, 2007 Author Share Posted February 8, 2007 Thanks Tyche, but it still doesnt show anything Quote Link to comment https://forums.phpfreaks.com/topic/37599-php-problems/#findComment-179793 Share on other sites More sharing options...
CanMan2004 Posted February 8, 2007 Author Share Posted February 8, 2007 What should I check in the php.ini file? Or would that not be causing the issue Quote Link to comment https://forums.phpfreaks.com/topic/37599-php-problems/#findComment-179807 Share on other sites More sharing options...
trq Posted February 8, 2007 Share Posted February 8, 2007 You may need to tun on error reporting. Put this at the top of your script. <?php error_reporting(E_ALL); ini_set('display_errors','1'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/37599-php-problems/#findComment-179846 Share on other sites More sharing options...
CanMan2004 Posted February 8, 2007 Author Share Posted February 8, 2007 Thanks, I get the error Call to undefined function mysql_connect() Do I need to enable something? Quote Link to comment https://forums.phpfreaks.com/topic/37599-php-problems/#findComment-179885 Share on other sites More sharing options...
sayedsohail Posted February 8, 2007 Share Posted February 8, 2007 is your application on webserver or localwebserver? if you change the location than your sql connect variable need to be changed. Quote Link to comment https://forums.phpfreaks.com/topic/37599-php-problems/#findComment-180011 Share on other sites More sharing options...
wildteen88 Posted February 8, 2007 Share Posted February 8, 2007 Thanks, I get the error Call to undefined function mysql_connect() Do I need to enable something? In that case please read the FAQ thread on this problem - CLICKY. Quote Link to comment https://forums.phpfreaks.com/topic/37599-php-problems/#findComment-180060 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.