Page 1 of 1

programmer stoped work..HELP on dbconnect.php

Posted: Sun Dec 06, 2009 9:38 pm
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)

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

Posted: Sun Dec 06, 2009 9:57 pm
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?

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

Posted: Sun Dec 06, 2009 10:12 pm
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);