mysql_connect('localhost:3036', 'x', 'x');
mysql_select_db('extractor');
$baseSKUraw = mysql_query("SELECT * FROM product_category where tier_one='".$result1."' and tier_two ='".$result2."' ");
$baseSKU = mysql_fetch_array($baseSKUraw);
echo json_encode(array("error"=>0, "result1"=>$baseSKU['sku_base']));
The Json is returning {"error":0,"result1":null} but when I do a "result1"=>"texthere" it will return accordingly to my textbox.
- What went wrong here, I can't seem to display the
sku_base? - When should I use
mysql_fetch_array? because I'm returning only 1 result now?
var_dump(baseSKUraw);
resource(3) of type (mysql result)
{"error":0,"result1":null}
print_r($baseSKU);
resource(3) of type (mysql result)
Array
(
[0] => 1
[id] => 1
[1] => Tops
[tier_one] => Tops
[2] => Shortsleeve
[tier_two] => Shortsleeve
[3] => WTSS
[sku_base] => WTSS
)
javascriptnotjava?echo mysql_error();before yourjson_encodeline, and then update the question with the output.print_r($baseSKU);mysql_*functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.