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
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??

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.