Jump to content

A strange query problem!


fatihshen

Recommended Posts

Hi,

 

I came across a strange problem.

 

whenevery I use this query:

 

$query = "SELECT pkEmbedID,Name,fkEmbedType,EmbedUrl,Description from tblEmbed

$result = executeQuery($query);

 

it works.

 

but if I use

 

$query = "SELECT tblEmbed.pkEmbedID AS pkEmbedID,tblEmbed.Name AS Name,tblEmbed.fkEmbedType AS fkEmbedType,tblEmbed.EmbedUrl AS EmbedUrl,tblEmbed.Description AS Description FROM tblEmbed INNER JOIN tblEmbedTag ON tblEmbedTag.fkEmbedID=tblEmbed.pkEmbedID INNER JOIN tblTag ON tblTag.pkTagID=tblEmbedTag.fkTagID

$result = executeQuery($query);

 

It doesn't work. I don't get a valid result. I would appriciate for any help. Below you can find the function executeQuery() .

 

.....

function executeQuery($query)

  {

 

 

  $dbhost = ........

$dbuser = ...........

$dbpass = ...........

$dbname = ...........

$conn = mysql_connect($dbhost, $dbuser,$dbpass) or die('Error connecting to mysql');

mysql_select_db($dbname) or die(mysql_error());

 

    $result = mysql_query( $query );

     

  closeDb();

   

return $result;

  }

 

 

 

Fatih

Link to comment
https://forums.phpfreaks.com/topic/162470-a-strange-query-problem/
Share on other sites

both queries work in phpMyAdmin sql window.

 

I figured out where the problem is but cannot still solve it.

 

This is the second query:

SELECT tblEmbed.pkEmbedID AS pkEmbedID,tblEmbed.Name AS Name,tblEmbed.fkEmbedType AS fkEmbedType,tblEmbed.EmbedUrl AS EmbedUrl,tblEmbed.Description AS Description FROM tblEmbed INNER JOIN tblEmbedTag ON tblEmbedTag.fkEmbedID=tblEmbed.pkEmbedID INNER JOIN tblTag ON tblTag.pkTagID=tblEmbedTag.fkTagID WHERE tblEmbed.fkEmbedType=1 AND tblEmbedTag.fkTagID IN(24)

 

here,  AND tblEmbedTag.fkTagID IN(24) doesn't work . I don't know still the reason. It works in phpMyAdmin sql window but I cannot run using php codes.

 

Fatih

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.