插入到mySQL数据库抛出PHP元素而不复制它们
我正在使用Unity3D开发一个小型项目,并且希望在mySQL数据库播放器名称和分数上发布。 PHP脚本从一些C#中获取值。 我不能让它具有每个名称只有一个数据库上的行。 该脚本现在发布,但只是喜欢这个名称得分
我真正想要的只是
maku 20
尝试{$ dbh = new PDO('mysql:host ='。$ hostname。'; dbname ='。$ database,$ username,$ password); } catch(PDOException $ e){echo'
发生错误。
', $e->getMessage() ,'“; } $ del = $ dbh-> prepare(“SELECT * FROM scores WHERE name =:name”);
if($del->rowCount()>0)
{
$sth = $dbh->prepare("UPDATE scores SET score=:score WHERE name=:name");
}else
if($del->rowCount()==0)
{
$sth = $dbh->prepare("INSERT INTO scores VALUES (null, :name, :score)");
}
try {
$sth->execute($_GET);
} catch(Exception $e) {
echo '<h1>An error has ocurred.</h1><pre>', $e->getMessage() ,'</pre>';
}
可能吗?
链接地址: http://www.djcxy.com/p/69175.html上一篇: Insert into mySQL Database throw PHP elements without duplicating them