mysqli_query返回false

时间:2015-06-22 15:49:14

标签: php mysql

我只是想输出'cat_find'表来检查我的insert语句是否正确但是mysqli_query是否返回false。另外,如果我的插入语句错误,我也希望得到一些帮助:

<?php

$asin = $_POST['asin'];

include("aws_signed_request.php");

echo "You have entered: " . $asin;

$servername = "servername";
$username = "username";
$password = "password";
$database = "database";


$conn = mysqli_connect($servername, $username, $password, $database);

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 

else{
echo "<br/>";
echo "CONNECTION SUCCESSFUL!";
echo "<br/>";
}

/*$sql = "CREATE TABLE cat_find (
id INT(100) NOT NULL AUTO_INCREMENT PRIMARY KEY,
amazon TEXT(100) NOT NULL, 
new_egg TEXT(100) NOT NULL,
ebay TEXT(100) NOT NULL
)";*/



$excel = file_get_contents("skufile.csv");

$explode = explode(',', $excel);


    /*for($i = 0; $i<count($explode); $i = $i+3){
        //echo $explode[$i];
        //echo $explode[$j];
        //echo $explode[$k];
        $j = $i+1;
        $k = $i + 2;
        $insert = "INSERT INTO cat_find (amazon, new_egg, ebay) VALUES ('$explode[$i]','$explode[$j]','$explode[$k]')";
    }*/

    $strSQL = "SELECT * FROM cat_find";
    $rs = mysqli_query($conn,$strSQL);
    while($row = mysqli_fetch_array($rs)){
        echo $row['amazon'] . "<br />";
        echo $row['new_egg'] . "<br />";
        echo $row['ebay'] . "<br />";
    }

//  echo $value[0];

$public_key = "PUBLIC-KEY";
$private_key = "PRIVATE-KEY";
$associate_tag = "ASSOC-TAG";


$request = aws_signed_request('com', array('Operation' => 'ItemLookup','ItemId' => $asin, 'ResponseGroup' => 'Large'), $public_key,
$private_key, $associate_tag);

                        $response = @file_get_contents($request);

                        if ($response === FALSE) {
                                echo "Request failed.<br>";
                        }

                        else {
                        // parse XML
                        echo '<pre>';
                                $pxml = simplexml_load_string($response);
                        //var_dump($pxml);
                       echo $pxml;

                          echo "<h3>Category/Product Group:</h3> ";
                       echo $pxml -> Items -> Item -> ItemAttributes -> ProductGroup;
                        echo "<br/><br/>";
                        $asin_cat = $pxml -> Items -> Item -> ItemAttributes -> ProductGroup;
                        }
                $sel = "SELECT * FROM cat_find WHERE amazon = '$asin_cat'";

                $run = mysqli_query($conn,$sel);

                if($run){
                    echo "Your ASIN has matched an Amazon asin. Here are the Amazon, New Egg and Ebay categories.";
                    echo "Amazon Category: " . $run[0] . "<br/> <br/>";
                    echo "New Egg Category: " . $run[1] . "<br/> <br/>";
                    echo "ebay Category: " . $run[2] . "<br/> <br/>";
                    }
                else{
                    echo "Your ASIN did not match any ASIN in the Amazon library. try again.";
                }




?>

帮助将不胜感激

0 个答案:

没有答案