I been trying to connecto to this database just to add content into a website but i can't connect to the database can anyone please help me here..
- PHP: Select all
<?
$host ="localhost";
$username ="silvapro_franknu";
$password ="abc123";
$database ="silvapro_prueba";
// artist..
$artist_name = addslashes($artist_name);
$artist_release= addslashes($artist_release);
$artist_bio = addslashes($artist_bio);
$artist_news= addslashes($artist_news);
$artist_extra= addslashes($artist_extra);
$artist_picture= addslashes($artist_picture);
$dbh=mysql_connect ("localhost", "Silvapro_franknu ", "abc123") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("silvapro_prueba");
if(!$db)
{
echo " Error: could not connect to database.";
}
//business owner
$sql="INSERT INTO `artist`(`artist_name`,`artist_release`,`artist_bio`,`artist_news`,`artist_extra`, `artist_picture`)
VALUES ('".$artist_name."','".$artist_release."','".$artist_news."','".$artist_extra."')";
$result = mysql_query($sql);
echo mysql_error();
if($result)
{
echo mysql_affected_rows()." .artist information Inserted. <br>";
}
?>
<?php
echo "<br>";
print(htmlspecialchars(dirname(__FILE__))."<br>");
// In PHP earlier then 4.1.0, $HTTP_POST_FILES should be used instead of $_FILES.
if(!empty($_FILES["picture1"]))
{
$uploaddir = realpath("/home/silvapro/public_html");
var_dump($uploaddir);
var_dump($_FILES);
var_dump($_FILES["picture1"]["error"]);
if (move_uploaded_file($_FILES["picture1"]["tmp_name"], $uploaddir . $_FILES["picture1"]["name"])) {
echo("file uploaded");
} else {
echo ("error!");
}
}
?>
the error message that i am getting is
Error: could not connect to database can anyone please tell me what is the deal here