programmer stoped work..HELP on dbconnect.php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gilbert1989
Forum Newbie
Posts: 1
Joined: Sun Dec 06, 2009 9:34 pm

programmer stoped work..HELP on dbconnect.php

Post by gilbert1989 »

pretty much had a guy write a script to load data into a database, using Wampserver, from a website. Paid him and then went to use it and it hasnt been configured for my database, name,host, password etc, and of course he wont help now for free.
anyone that can help?
(code) <?php

function opendb(){

$hostname = "localhost";

$dbh = mysql_connect($hostname, "root", "emileb7_")

or die("Unable to connect to MySQL");

mysql_select_db("test",$dbh)

or die("Could not open database!");

return;

}//end function

function cleaninput($userinput){
$newinput = mysql_real_escape_string(strip_tags(htmlentities($userinput)));
return $newinput;
}//end function

function croak($errorstring){
echo 'A database error occurred. The error is:<br> '.$errorstring;
// echo 'An error has occured, most likely while interacting with our database. Please try your request again. If this error persists, please notify the webmaster.';

$errstring='the following error occured: '.$errorstring;
// logtofile('generrors.log', $errstring);
}//end function

function logtofile($filename, $msg){
$mybase = "/home/rgrentr5/logs/";
$fd = fopen($mybase.$filename, "a");
// append date/time to message
$str = "[" . date("Y/m/d h:i:s", mktime()) . "] " . $msg;
fwrite($fd, $str . "\n");
fclose($fd);
}//end function
?>
(code)
AliJ
Forum Commoner
Posts: 32
Joined: Sun Dec 06, 2009 8:03 pm

Re: programmer stoped work..HELP on dbconnect.php

Post by AliJ »

What do you mean?
Don't you know server name, username, ect...
Is that the problem, or do you just not know where to put that information?
User avatar
Weiry
Forum Contributor
Posts: 323
Joined: Wed Sep 09, 2009 5:55 am
Location: Australia

Re: programmer stoped work..HELP on dbconnect.php

Post by Weiry »

gilbert1989 wrote:it hasnt been configured for my database, name,host, password
you will need to modify the lines:

Code: Select all

$dbh = mysql_connect($hostname, "xxxxx", "xxxxxx");
mysql_select_db("test",$dbh);
to something like this

Code: Select all

$dbh = mysql_connect($hostname, "YOUR_DB_USERNAME_HERE", "YOUR_DB_PASSWORD_HERE");
mysql_select_db("YOUR_DATABASE_NAME_HERE",$dbh);
Post Reply