Jump to content

Recommended Posts

here's my query:

 

//select the category the url belongs to

$sql = "SELECT * from ". table_stores ." where domain=". $domain;

 

$category_id = $db->get_results($sql);

 

However, when I type in a domain name on web page, this query gives me this warning message:

 

Warning: Unknown table 'circuitcity' in where clause in /public_html/libs/db.php on line 233

 

the code block in db.php is:

 

if ( $str = @mysql_error($this->dbh) )

{

$is_insert = true;

$this->register_error($str);

$this->show_errors ? trigger_error($str,E_USER_WARNING) : null; //This line is 233

return false;

}

 

circuitcity is actually not even a table in mysql database. Domain is a column in the table of stores.

 

Can someone help me figure out where is wrong?

 

thanks!

Link to comment
https://forums.phpfreaks.com/topic/90515-weird-warning-message-for-mysql-query/
Share on other sites

yes, table_stores is a constant. Now it works, but I have problem fetching values

<?php

$category_id = $db->get_results($sql);

//check if category id exists for the particular domain

$categoryid = $category_id['category_id']; // category_id is a column in the database table _stores

if (!$categoryid){

  $categoryid = 0;

  }

echo $categoryid;

 

?>

 

This code gives me $categoryid = 0 even though there are records in the table.

 

Am I missing something?

 

thanks again!

Very unsatisfactory post. You need to be very clear with your questions if you expect members on this forum to respond to you.

 

Issues with your post:

 

1) You don't show what the current query ($sql value) is.

2) We don't see where or how you're actually running the query (unless get_results() does it, but how are we supposed to know that?).

3) We don't know what get_results() does exactly. We don't know if you're using a database abstraction layer, a home grown function or what.

4) We don't know if get_results() really returns an array, resource object, or an object, or something else.

 

It's up to you to help yourself by putting debug echo's in strategic places in your code to see where things are going wrong.

 

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.