Reputation: 1617
I almost an hour trying to understand what i doing wrong here. The is no output.
The connection is Ok, The array is full of data
<?php header('Content-Type: text/html; charset=utf-8');
// Here's the argument from the client.
$domain = $_GET['string'];
$quest=$_GET['quest'];
$event=$_GET['event'];
$con = mysql_connect('localhost', '******', '********');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("vocabulary", $con);
$sql="SELECT * FROM `0` WHERE event_name = '".$event."' AND quest_id = '".$quest."'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$key = array_search($domain, $row);
echo $key;
mysql_close($con);
?>
Any ideas?? Thanks
Upvotes: 0
Views: 50
Reputation: 568
i think your issue is that you're not creating an associative array http://php.net/manual/en/function.array-search.php
your mysql_fetch_array is returning an array that has values but not keys, and so there is nothing to be stored in $key. try this instead:
$row = mysql_fetch_array($result, MYSQL_ASSOC)
also, obligatory "you should avoid using mysql_ functions entirely, and move to mysqli or PDO because mysql_ has been deprecated"
Upvotes: 0
Reputation: 82028
A few things.
0
. I don't think you should be doing that.0
exists, my guess is that you have an error at mysql_fecth_array
. Try putting error_reporting(E_ALL);
at the start of your script.array_search
returns False
if it doesn't find anything. Try var_dump($key);
instead.Upvotes: 3