Jump to content

PHP Problems


CanMan2004

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/37599-php-problems/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/37599-php-problems/#findComment-179768
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/37599-php-problems/#findComment-179779
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/37599-php-problems/#findComment-179792
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.