Believe it or not my host does not have MySql support so I need to go outside my domain to get a MySql database. I have gone to http://www.freesql.org/ to aquire my database. my question is this how do I configure my script to connect to data base. I continue to get the following error when I load script
Parse error: parse error, expecting `')'' at line 5
NOTE: the following is the variables
$dbname=exitexchange
$username=taylorj37
$password=michael
$host=www.mysql.com
I named the database exitexchange but it will not connect unless I put the $dbname as the url
I also changed the localhost to the IP address of mysql.com
Below is the original code
<?php
connectToDB();
function connectToDB()
{
global $dbname;
global $user_name;
global $password;
global $HTTP_HOST;
global $link;
if($HTTP_HOST!='160.1.51.6')
$link = mysql_pconnect("localhost","$user_name","$password");
else
$link = mysql_pconnect("localhost","root","");
if (! $link)
die("Couldn't connect to Database");
if($HTTP_HOST!='160.1.51.6')
mysql_select_db("$dbname",$link) or die ("Couldn't open database : ".mysql_error);
else
mysql_select_db("pop",$link) or die ("Couldn't open database : ".mysql_error);
}
function LoginUser($cUser, $cPass)
{
$result=mysql_query("SELECT * FROM tbluser where user='$cUser' and pass='$cPass'");
if (! $result) die("getRow fatal error here: ".mysql_error());
return mysql_fetch_array($result);
}
function UserExists($user)
{
$row=getrow("tbluser", "user" ,$user);
if($row) return true;
else return false;
}
function getRow($table, $fieldname, $fval)
{
global $link;
$result=mysql_query("SELECT * FROM $table where $fieldname='$fval'");
if (! $result)
die("getRow fatal error here: ".mysql_error());
return mysql_fetch_array($result);
}
function SaveNewUser($cName,$cEmail,$cCountry,$cTitle,$cURL,$category1,$category2,$category3,$cUser,$cPass, $refid)
{
if($refid==0) $refid=1;
//print "$cName,$cEmail,$cCountry,$cTitle,$cURL,$category1,$category2,$category3,$cUser,$cPass, $refid";
$result=mysql_query("INSERT INTO tbluser ( name, email, country, sitetitle, popurl, cate1, cate2, cate3, user, pass ,referid, datereg)
VALUES('$cName','$cEmail','$cCountry','$cTitle','$cURL',$category1,$category2,$category3,'$cUser','$cPass', $refid, '".date("Y-m-d")."')");
if(!$result) die("New User error: ".mysql_error());
return mysql_insert_id();
}
function UpdateNewUser($cName,$cEmail,$cCountry,$cTitle,$cURL,$category1,$category2,$category3,$cUser,$cPass, $nStatus, $id)
{
$result=mysql_query("UPDATE tbluser SET name='$cName', email='$cEmail', country='$cCountry', sitetitle='$cTitle', popurl='$cURL', cate1=$category1, cate2=$category2, cate3=$category3, pass='$cPass', status=$nStatus
WHERE userid=$id
");
if(!$result) die("Update User error: ".mysql_error());
}