Hi all,
I’ve been trying to get this sql query to work from php, but i cannot seem to get it to. I am hoping that someone else has experienced this and knows a solution or can point out my mistakes.
I have a table in my sql db titled Parent_Child, and as you may imagine is just two IDs associating the two together. The two fields are Parent and Child.
I want to run a query like this:
[php]SELECT * FROM Parent_Child WHERE Child =‘8C8FDBCB-0984-49D8-BE14-1942E26600C4’[/php]
It works when I perform it in phpMyAdmin, but does not when I attempt to run the query using mysql_query.
[php]
//$g is the ID of the current child.
$sql= “SELECT * FROM Parent_Child WHERE Child =’”.$g."’";
$result= mysql_query($sql);
while ($row = mysql_fetch_array($result))
{
echo $row[‘Parent’];
}
[/php]
It’s weird because when i echo $sql, it outputs the query, and when I paste that directly into phpMyAdmin query, it works… If I passed $g as 8C8FDBCB-0984-49D8-BE14-1942E26600C4, it would give me my desired output in the variable $sql as: SELECT * FROM Parent_Child WHERE Child =‘8C8FDBCB-0984-49D8-BE14-1942E26600C4’
note: I have the mysql_connect stuff also but that isn’t the focus of the problem. I know it connects to the DB it just doesn’t execute the query properly.
Any thoughts?