2013-11-01 4 views
-2

В значительной степени это не вставляет ничего в базу данных, и это действительно получается, я должен быть, но это не так. Есть идеи? Я не могу понять, что я удалил запятую после последней переменной! Я не понимаю. Я не могу быть лучшим с php или mysqli, но я могу справиться с собой довольно хорошо, и это не будет хорошо.База данных не установлена ​​

<?php 

// <!- Session Check -!> \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 
    require("common.php"); 
                 // 
                 // 
    if(empty($_SESSION['user'])) 
    { 
                 // 
     header("Location: index.html"); 
                 // 
     die("Redirecting to index.html"); 
    } 
                 // 
// <!- Session Check End -!> ///////////////////////////// 


// <!- Sanatizing Steps Begin -!> \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 
                       // 
                       //                 
// Function to turn single quotes and forward slashes to html characters \\ 
function quote2entities($string,$entities_type='number') 
{ 
    $search      = array("\"","'"); 
    $replace_by_entities_name = array("&quot;","&apos;"); 
    $replace_by_entities_number = array("&#34;","&#39;"); 
    $do = null; 
    if ($entities_type == 'number') 
    { 
     $do = str_replace($search,$replace_by_entities_number,$string);   // 
    } 
    else if ($entities_type == 'name') 
    { 
     $do = str_replace($search,$replace_by_entities_name,$string); 
    } 
    else 
    { 
     $do = addslashes($string); 
    } 
    return $do; 
} 
                       //  
                       // 
                       // 
                       // 
// Declaring Modifying values \\ 
$url = $_POST['url']; 
$c = $_POST['company']; 
    $cp = $_POST['companyproduct']; 
    $curl = $_POST['curl']; 
    $mem = $_POST['mem']; 
    $model = $_POST['model']; 
     $serial = $_POST['serialalgo']; 
     $method = $_POST['meth']; 
     $warn = $_POST['warn']; 
//                    //  
// Declaring original Values for the 3rd Sanatization Step \\ 
$ourl = $_POST['url']; 
$oc = $_POST['company']; 
    $ocp = $_POST['companyproduct']; 
    $ocurl = $_POST['curl']; 
    $omem = $_POST['mem']; 
    $omodel = $_POST['model']; 
     $oserial = $_POST['serialalgo']; 
     $omethod = $_POST['meth']; 
     $owarn = $_POST['warn']; 

                       // 
                       // 
                       // 
                       // 
                       // 
      // Input Sanatize 1 of 3 \\ 
    filter_input(INPUT_GET, $c, FILTER_SANITIZE_URL); 
    filter_input(INPUT_GET, $mem, FILTER_SANITIZE_URL); 
    filter_input(INPUT_GET, $url, FILTER_SANITIZE_URL); 
    filter_input(INPUT_GET, $cp, FILTER_SANITIZE_URL); 
    filter_input(INPUT_GET, $curl, FILTER_SANITIZE_URL); 
    filter_input(INPUT_GET, $model, FILTER_SANITIZE_URL); 
    filter_input(INPUT_GET, $serial, FILTER_SANITIZE_URL); 
    filter_input(INPUT_GET, $warn, FILTER_SANITIZE_URL); 
    filter_input(INPUT_GET, $method, FILTER_SANITIZE_URL); 
                       // 
                       // 
                       // 
                       // 
                       // 
// Input Sanatize 2 of 3 \\ 
//if($oc != $c | $omem != $mem | $ocp != $cp) 
//{                    // 
// Echo "Banning Account."; 
//header(location: "http://cuntusa.com/"); 
//Die(); 
//} 
                       // 
                       // 
// Input Sanatize Final of 3 \\ 
$c = quote2entities($c); 
$mem = quote2entities($mem); 
$cp = quote2entities($cp); 
$curl = quote2entities($curl); 
$warn = quote2entities($warn); 
$method = quote2entities($method); 
$url = quote2entities($url); 
$model = quote2entities($model); 
$serial = quote2entities($serial); 
$date = date("Y-m-d H:i:s"); 
$postedby = $_SESSION['user']['username']; 
     echo $warn; 
     echo $serial; 
                       // 
                       // 
                       // 
///////// <!- Santizing Ends -!> ////////////////////////////////////////////////// 




////////////<!- SQLi Begin -!> \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 
//                            //// 
//                            //// 
//                            //// 
// Declaring Resource connection Attributes \\ 
$username = "="; 
$password = "m="; 
$host = "=rce.com"; 
$dbname = "="; 
//                            //// 
//                            //// 
// Declaring a connection Varible for faster call downs. \\ 
$con=mysqli_connect($host,$username,$password,$dbname) or die('Error->' .mysqli_error($con)); 
//                            //// 
//                            //// 
// Checking for any errors \\ 
echo mysqli_error($con); 
//                            //// 
//                            //// 
// Loading into the database \\ 
echo $date; 
echo $c ; 
$query = "INSERT INTO project (company,published,user,contacturl,model,serialalgo,members,method,warn) VALUES (
    '".$c."', 
    '".$date."', 
    '".$postedby."', 
    '".$curl."', 
    '".$model."', 
    '".$serial."', 
    '".$mem."', 
    '".$method."', 
    '".$warn."', 
    )"; 
mysqli_query($con, $query); 
//                            //// 
//                            //// 
// Closing the connection \\ 
mysqli_close($con); 
//                            //// 
//                            //// 
// <!- End SQLi -!> /////////////////////////////////////////////////////////////////////////////////////////////// 



?> 
<!---<html> 
<body> 
<meta http-equiv="refresh" content="0; url=ht=php"> 
</body> 

</html> 
+0

Чувак, эта стена кода * страшно *. Неудивительно, что это не сработает. Я много прокрутил, но не смог получить какой-либо разумный код. –

+0

Вы должны сделать себе одолжение и перейти на подготовленные заявления. – jeroen

+0

Полностью непонятно. –

ответ

1

Здесь вы найдете исчерпывающий код. Вставка переменных может не отражать фактические данные - я не удосужился исследовать, но только чтобы показать вам, что вам не нужно назначать и повторно назначать, а затем повторно назначать свои входные переменные пять раз подряд. Все, что происходит прямо из браузера, может быть связано как есть.

// setting error reporting for php and mysqli 
// on a live site display errors have to be set to 0 
ini_set('display_errors',1); 
error_reporting(E_ALL); 
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); 

//connect 
$username = "="; 
$password = "m="; 
$host = "=rce.com"; 
$dbname = "="; 
$con = mysqli_connect($host,$username,$password,$dbname); 

//insert 
$query = "INSERT INTO project 
      (company,published,user,contacturl,model,serialalgo,members,method,warn) 
      VALUES (?,?,?,?,?,?,?,?,?)"; 
$stmt = $con->prepare($query); 
$stmt->bind_param("sssssssss", 
    $_POST['company'], 
    $_POST['companyproduct'], 
    $_POST['curl'], 
    $_POST['mem'], 
    $_POST['model'], 
    $_POST['serialalgo'], 
    $_POST['meth'], 
    $_POST['warn'] 
); 
$stmt->execute(); 
Смежные вопросы