PHP and MySQL not working

Here you can share scripts and discuss how to build and design websites.

PHP and MySQL not working

Postby das7002 on Mon Oct 20, 2008 2:18 am

function addhash($hash,$crypto){
$con = mysql_connect("localhost","root","pass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("crypto", $con);
$sql1 = "SELECT * FROM hash";
if(mysql_query($sql1,$con) == "NULL"){
$sql="INSERT INTO hash (hash, string, hashtype) VALUES ('$hash','$_POST[str]','$crypto')";

if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "Hash added to database";

mysql_close($con);
} else {
echo 'already in database';
}
}

If you know anything about coding you see what I want that to do please help me fix it
User avatar
das7002
Registered Member
 
Posts: 4
Joined: Sat Aug 23, 2008 7:00 am

Re: PHP and MySQL not working

Postby themcman1 on Thu Oct 23, 2008 8:10 pm

Will have a look at the weekend.
User avatar
themcman1
V.I.P
 
Posts: 12
Joined: Thu Oct 23, 2008 7:39 pm

Re: PHP and MySQL not working

Postby das7002 on Thu Oct 23, 2008 9:45 pm

A SQL unique index fixed it
User avatar
das7002
Registered Member
 
Posts: 4
Joined: Sat Aug 23, 2008 7:00 am

Re: PHP and MySQL not working

Postby Daniel on Fri Nov 07, 2008 11:19 pm

Since this problem has been resolved I will close it.

*Topic Closed*
-Daniel

Image
User avatar
Daniel
Site Admin
 
Posts: 474
Joined: Wed Dec 05, 2007 4:59 pm
Location: United Kingdom


Return to Website Development

Who is online

Users browsing this forum: No registered users and 0 guests