Jump to content

Localhost does what I want but my webhost?


redgunner

Recommended Posts

Hi,

 

I am using wamp server with phpmyadmin and my entries get added no problem using localhost method..

 

I move to my server online and it doesn't add an entry?

 

$username="monstert_admin"; $password="admin"; $database="monstert_admin";
$connection = mysql_connect("localhost", $username, $password) 
or die("Connection Failure to Database");
// Select Database
mysql_select_db($database, $connection) or die ($database . "No Database" . $username);

//Select everything from the the table
$MyQuery = "SELECT * FROM photos";
$retrieve = mysql_query($MyQuery) or die(mysql_error());
if(mysql_num_rows($retrieve) != 0):
	$row = mysql_fetch_assoc($retrieve);
else:
	echo '';
endif;

if(isset($_POST['Submit']) && !$errors)
{
$url = $newname;

   include('img.php');
   $image = new SimpleImage();
   $image->load($url);
   $image->resize(500,315);
   $image->save($newname);

mysql_query("INSERT INTO photos (url) VALUES ('$url')");
mysql_query("INSERT INTO photos (id, url) VALUES ('1', 'images/xx.jpg'");

echo "File Uploaded Successfully as <i> ";
echo $newname;
echo "</i>";
}

Most often, a hosted account will use use an IP address, or actual hostname (sqlsrv_04.somedomain.com) rather than 'localhost' for the MySQL server's hostname. Check your hosting company's FAQs to see if that may be the case.

I know this sounds obvious, but it's easy to make a mistake (as the hedgehog said getting off the toilet brush) - just check that when you set up the database on the server, you typed in the user name and password correctly and didn't inadvertently put in any typos.  In those password boxes where the characters come up as asterisks, its easy to put a typo in and not realise. 

 

Also check that the server has not "helpfully" appended any suffixes automatically to the username (one of mine does !).  Sorry if this sounds obvious, but I've done it myself ....

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.