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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.