Jump to content

Recommended Posts

Posted

Hello,

 

I am completely new to PHP and am trying to see if I can access any db on my site. I have tried just about every script featured on hotscripts.com but nothing will connect to any databases I have set up. Maybe I am COMPLETELY doing everything wrong but I am following the directions to the T and all I seem to get is errors or it will just display the script in the browser.

 

I am entering ("localhost", "user_user", "pass") into the script and then I just choose a database that the user is allowed to access.

 

I am just wondering if I need something else to connect to a database.

 

Sorry if this makes little sence since I have been fighting with it for 2 days now :blink:

 

Thanks for any ideas!

Posted

Hi,

 

Can you post a sample of the code here? Take out the password of course, and any other sensitive data, then we can have a look.

 

I should look something like

><?php
$host="localhost";
$db="usernm_dbname";
$user="username";
$passwd="password";

$dbh=mysql_connect ($host, $user, $passwd) or die ('I cannot connect to the database because: ' . mysql_error());

mysql_select_db ("$db");

?>

 

Andy

Posted

Hi,

 

One of the scripts that I am trying out is ez_sql. A database tool from hotscripts.com.

 

I get the following error:

 

SQL/DB Error -- [

Error establishing a database connection!

Are you sure you have the correct user/password?

Are you sure that you have typed the correct hostname?

Are you sure that the database server is running?

 

Here is a copy of the script where you make the changes for your server:

 

>CHANGE HERE

define("USER_USER", ""); 	 // <-- mysql db user
define("PASS", "");  // <-- mysql db password
define("MYDB", "mysql");  // <-- mysql db pname
define("EZSQL_DB_HOST", "localhost");	// <-- mysql server host

//

 

I leave everything just as it is except for USER_USER, PASS, and MYDB.

 

The script says that this is the only area to modify.

 

Thanks again, Thumbs Up

 

srobbins

Posted
define("MYDB", "mysql");  // <-- mysql db pname

 

I think they're looking for your database name.

 

If you username in cpanel were "insignia" and you named your database "whatever" then you'd put

 

define("MYDB", "insignia_whatever"); // <-- mysql db pname

 

When you go to Cpanel, and choose Manage Mysql, it should show you the name of your database. Also can be found in PHP myadmin.

Posted

Thanks surefire,

 

I am specifying the db like you posted. I am wondering if it's a password problem.

 

I am using

 

HOST: "localhost"

USER: "user_user" -except my actual user (the one that I set up in cpanel)

PASS: "mypass" -except my actual pass (the one that I set up in cpanel)

DB: "trial"

I usually get error:

 

1044: Access denied for user: 'user_user@localhost' to database 'trial'

 

There must be something that I am not doing right????

 

Thanks for the help so far Thumbs Up

 

I'll keep trying

 

Here is a copy of the script that I am currently playing with:

><?php



$connection = mysql_connect ("localhost", "user_user", "pass");
if ($connection == false){
 echo mysql_errno().": ".mysql_error()."<BR>";
 exit;
}   

$query = "create table email_info " .
      "(fullname varchar(255), email_address varchar(255))";
$result = mysql_db_query ("trial", $query);

if ($result)
 echo "Table 'email_info' was successfully created!";
else
 echo mysql_errno().": ".mysql_error()."<BR>";

mysql_close ();


?> 


<?php

if ($submit == "click"){
 // The submit button was clicked!
 // Get the input for fullname and email then store it in the database.
 $connection = mysql_connect ("", "", "");
 if ($connection == false){
   echo mysql_errno().": ".mysql_error()."<BR>";
   exit;
 }   

 $query = "insert into email_info values ('$fullname', '$email')";
 $result = mysql_db_query ("trial", $query);
 if ($result){
   echo "Success!";
 }
 else{
   echo mysql_errno().": ".mysql_error()."<BR>";
 }

 mysql_close ();
}
else{
 echo "
   <html><body>

   <form method=\"post\" action=\"insert.php3\">

   Enter your full name
   <input type=\"text\" name=\"fullname\"></input><br>
   Enter your email address
   <input type=\"text\" name=\"email\"></input><br>

   <input type=\"submit\" name=\"submit\" value=\"click\"></input>        

   </form>

   </body></html>
 ";
}

?>

 

 

I get a similar error no matter what script I use...

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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