• 13-08-2018, 21:41:15
    #1
    Kimlik doğrulama veya yönetimden onay bekliyor.
    Esen ola.

    Dosya 1;
    <?php
    header('Access-Control-Allow-Origin: *');
    
    
    
    
    $host="localhost"; // Host name
    $username="username"; // Mysql username
    $password="password"; // Mysql password
    $db_name="database"; // Database name
    $tbl_name="scores"; // Table name
    
    // Connect to server and select database.
    mysql_connect("$host", "$username", "$password")or die("cannot connect");
    mysql_select_db("$db_name")or die("cannot select DB");
    
    // Retrieve data from database
    $sql="SELECT * FROM scores ORDER BY score DESC LIMIT 10";
    $result=mysql_query($sql);
    
    // Start looping rows in mysql database.
    while($rows=mysql_fetch_array($result)){
    echo $rows['name'] . "|" . $rows['score'] . "|";
    
    // close while loop
    }
    
    // close MySQL connection
    mysql_close();
    ?>
    Dosya 2
    <?php
    
    
    $db = "database";//Your database name
    $dbu = "username";//Your database username
    $dbp = "password";//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.
    ?>
    Oyunuma skor sistemi buldum ama mysql kullandığı için hata veriyor. Nasıl çözebilirim?
  • 14-08-2018, 03:07:59
    #2
    <?php
    header('Access-Control-Allow-Origin: *');
     
     
     
     
    $host="localhost"; // Host name
    $username="username"; // Mysql username
    $password="password"; // Mysql password
    $db_name="database"; // Database name
    $tbl_name="scores"; // Table name
     
    // Connect to server and select database.
    $mysqli = new mysqli("$host", "$username", "$password")or die("cannot connect");
    $mysqli->select_db("$db_name")or die("cannot select DB");
     
    // Retrieve data from database
    $sql="SELECT * FROM scores ORDER BY score DESC LIMIT 10";
    $result=$mysqli->query($sql);
     
    // Start looping rows in mysql database.
    while($rows=$result->fetch_array()){
    echo $rows['name'] . "|" . $rows['score'] . "|";
     
    // close while loop
    }
     
    // close MySQL connection
    $mysqli->close;
    ?>
    <?php
     
     
    $db = "database";//Your database name
    $dbu = "username";//Your database username
    $dbp = "password";//Your database users' password
    $host = "localhost";//MySQL server - usually localhost
     
    $dblink = new mysqli($host,$dbu,$dbp);
    $seldb = $dblink->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($dblink->real_escape_string($_GET['name']));
         $score = strip_tags($dblink->real_escape_string($_GET['score']));
         $sql = `name`->query("INSERT INTO `$db`.`scores` (`id`) 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.';
    }
     
    $dblink->close;//Close off the MySQL connection to save resources.
    ?>
  • 14-08-2018, 05:38:08
    #3
    Bu seferde;
    Warning: mysqli_select_db() expects exactly 2 parameters, 1 given in /home/rijitsuc/public_html/gamef/getscores.php on line 15
    cannot select DB
  • 14-08-2018, 16:52:17
    #4
    agg1401 adlı üyeden alıntı: mesajı görüntüle
    Bu seferde;
    Warning: mysqli_select_db() expects exactly 2 parameters, 1 given in /home/rijitsuc/public_html/gamef/getscores.php on line 15
    cannot select DB
    Kodları güncelledim , bu şekliyle dener misin ?
  • 14-08-2018, 21:02:08
    #5
    Kodları bir arkadaş ile birlikte çözdüm.

    Kodlar;
     <?php
    $servername = "localhost";
    $username = "rijitsuc_coffee";
    $password = "asd84dcpolice";
    $dbname = "rijitsuc_coffee";
    
    // Create connection
    $conn = mysqli_connect($servername, $username, $password, $dbname);
    // Check connection
    if (!$conn) {
        die("Connection failed: " . mysqli_connect_error());
    }
    
    $sql = "SELECT id, name, score FROM scores";
    $result = mysqli_query($conn, $sql);
    
    if (mysqli_num_rows($result) > 0) {
        // output data of each row
        while($row = mysqli_fetch_assoc($result)) {
            echo "" . $row["id"]. "" . $row["name"]. " " . $row["score"]. "<br>";
        }
    } else {
        echo "0 results";
    }
    
    mysqli_close($conn);
    ?>
    <?php
    
    $db = "rijitsuc_coffee";//Your database name
    $dbu = "rijitsuc_coffee";//Your database username
    $dbp = "asd84dcpolice";//Your database users' password
    $host = "localhost";//MySQL server - usually localhost
    
    $conn = mysqli_connect($host,$dbu,$dbp);
    if (!$conn) {
        die("Connection failed: " . mysqli_connect_error());
    }
     
    if(isset($_GET['name']) && isset($_GET['score'])){
     
         //Lightly sanitize the GET's to prevent SQL injections and possible XSS attacks
         $name = strip_tags(mysqli_real_escape_string($_GET['name']));
         $score = strip_tags(mysqli_real_escape_string($_GET['score']));
         $sql = mysqli_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=" & pointsend.Text & "&score=" & yuksekpuan';
    }
     
    mysqli_close($conn);
    ?>
  • 03-02-2023, 12:20:01
    #6
    Merhaba Böyle bir kodum var

    Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /var/www/vhosts/anzersu.com.tr/httpdocs/baglan.php:10 Stack trace: #0 /var/www/vhosts/anzersu.com.tr/httpdocs/index.php(3): include() #1 {main} thrown in /var/www/vhosts/anzersu.com.tr/httpdocs/baglan.php on line 10


    Bu şekilde bir hata alıyorum

    Kod Bu şekilde Yardım ederseniz sevinirim.

    <?php

    if (strstr($_SERVER['HTTP_HOST'],"localhost"))
    {
    $baglan=mysql_connect("localhost","root","") or die("mysqle bağlanılamıyor");
    mysql_select_db("anzersu_veri",$baglan) or die("veritabanı seçilemiyor");
    }
    else
    {
    $baglan=@mysql_connect("localhost","anzersuc_yeni" ,"yeni.53.")
    or die ("mysqle baglanamadim");

    @mysql_select_db("anzersuc_yeni",$baglan)
    or die ("veritabanı seçilemedi");
    }

    mysql_query("SET NAMES utf8");
    mysql_query("SET CHARACTER SET utf8");
    mysql_query("SET COLLATION_CONNECTION='utf8_general_ci'");

    ?>
  • 05-02-2023, 19:29:36
    #7
    Ücretli destek sağlayabiliriz