Jump to content

Connection to MYSQL problems


englishcodemonkey

Recommended Posts

Ok first off I’m using MySQL 4.1 on www.godaddy.com.  I am trying to just connect to the database and pull out some information into a floating frame on my website.  The error I am getting is “Oops Page not found”.  I think the actual connection to MySQL is the problem but I am an absolute PHP beginner and so I could be making a stupid obvious mistake!

 

This is the code I am using, I have blanked out the password for obvious reasons.  I have tried several different ways of writing the line starting ‘$dbc’, including putting the variables values straight into the new mysqli.  I have also tried using 10.6.171.124 as the host name. 

 

<?php

$hostname="p41mysql101.secureserver.net";

$username="hosta";

$password="*****";

$dbname="hosta";

$dbc = new mysqli($hostname, $username, $password, $dbname);

if (mysql_connect_errno()) {

  printf("Connect failed: %s\n", mysqli_connect_error());

}

printf("Host information: %s\n", $dbc->host_info);

?>

 

The above code is from ‘conn.php’ and then in ‘desc.php’ which is what should load information into a frame contains the line:

 

require_once('conn.php');

 

I have had this working perfect just on ‘localhost’.

 

Thanks for all your help in advanced!!

 

Link to comment
https://forums.phpfreaks.com/topic/111190-connection-to-mysql-problems/
Share on other sites

OK so if I need to update the code to mysql instead of mysqli my 'conn.php' code would be:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

</head>

 

<body>

 

 

<?php

$dbhost = 'p41mysql101.secureserver.net';

$dbuser = 'hosta';

$dbpass = '***';

 

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die                      ('Error connecting to mysql');

 

$dbname = 'hosta';

mysql_select_db($dbname);

?>

 

 

</body>

</html>

 

Is this correct??

 

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.