Arama butonu
Bu konudaki kullanıcılar: 1 misafir
5
Cevap
853
Tıklama
0
Öne Çıkarma
PHP Tabloya Veri Ekleme Hakkında Yardım [Çözüldü]
T
8 yıl
Yüzbaşı
Konu Sahibi

Merhaba arkadaşlar,

Oyun geliştiricisiyim,MySQL ve PHP hakkında hiç bilgim yok.Bir Skor tablosu oluşturmaya çalışıyorum.Tabloya yeni skor girmek istediğimde Query false oluyor ve hata mesajını alıyorum,yeni sütun girmiyor.Free serverda denediğimde oluyor ama kendi serverımda denediğimde olmuyor.

Php dosyamın içindeki kod şu şekilde;

<?php


$db = "DATABASE İSMİM";//Your database name
$dbu = "DATABASE USERNAME'İM";//Your database username
$dbp = "DATABASE ŞİFREM";//Your database users' password
$host = "localhost";//MySQL server - usually localhost

$dblink = mysql_connect($host,$dbu,$dbp);
$seldb = mysql_select_db($db);

if(isset($_GET['name']) && isset($_GET['score'])){

//Lightly sanitize the GET's to prevent SQL injections and possible XSS attacks
$name = strip_tags(mysql_real_escape_string($_GET['name']));
$score = strip_tags(mysql_real_escape_string($_GET['score']));
$sql = mysql_query("INSERT INTO `$db`.`scores` (`id`,`name`,`score`) VALUES ('','$name','$score');");

if($sql){

//The query returned true - now do whatever you like here.
echo 'Your score was saved. Congrats!';

}else{

//The query returned false - you might want to put some sort of error reporting here. Even logging the error to a text file is fine.
echo 'There was a problem saving your score. Please try again later.';

}

}else{
echo 'Your name or score wasnt passed in the request. Make sure you add ?name=NAME_HERE&score=1337 to the tags.';
}

mysql_close($dblink);//Close off the MySQL connection to save resources.
?>


Database'imde "Scores" adında tablo açık.Tabloyu şu kodla SQL olarak oluşturdum.Ü

CREATE TABLE `scores` (
`name` VARCHAR( 100 ) NOT NULL ,
`score` INT( 11 ) NOT NULL ,
PRIMARY KEY ( `score` )
) ENGINE = InnoDB;




Yardımcı olabilecek varsa çok sevinirim.Çok önemli bi proje çünkü.





< Bu mesaj bu kişi tarafından değiştirildi takamoto -- 19 Ağustos 2017; 8:1:39 >