473,739 Members | 3,096 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unknown column 'ItemPageName' in 'where clause'

4 New Member
This appears to be the code that is giving me trouble. Can someone help
Expand|Select|Wrap|Line Numbers
  1. <?
  2.     include("common.php");
  3.     require_once("$HeaderFile");
  4.  
  5.     if(empty($_GET[Start])){
  6.         $Start = '0';
  7.     }else{
  8.         $Start = $_GET[Start];
  9.     }
  10.     $ByPage = $aset[pagina];
  11.     $query = array();
  12.     if(!empty($_GET[what])){
  13.         $query[] = " (ItemName like '%$_GET[what]%' or ItemDesc like '%$_GET[what]%') ";
  14.     }
  15.     if(!empty($_GET[pagename])){
  16.       $qcatalognum = "SELECT CategoryID FROM categories WHERE CategoryPageName = '$_GET[pagename]'";
  17.       $rcatalognum = mysql_query($qcatalognum) or die(mysql_error());
  18.       $catalognum  = mysql_fetch_array($rcatalognum);
  19.         $query[] = " ItemCategory = '$catalognum[CategoryID]' ";
  20.  
  21.         /*********************************** BEGINNING OF THE BIG IF *****************************/
  22.         if($catalognum[CategoryID]){
  23.  
  24.     if(!empty($_GET[SubcategoryID])){
  25.         $query[] = " ItemSubcategory = '$_GET[SubcategoryID]' ";
  26.     }
  27.     if(!empty($query)){
  28.         $my_query = implode(" and ", $query);
  29.         $my_query = " WHERE $my_query";
  30.     }
  31.     if(!empty($_GET[ord1])){
  32.         $order_by = " ORDER BY $_GET[ord1] ";
  33.     }else{
  34.         $order_by = " ORDER BY ItemName ";
  35.     }
  36.  
  37.   // Modified On July 11, 2005 by Patrick Mahoney for Online-Net-Business.Com - Killer SEO Website Builder System
  38.   if ($catalognum > 0) {
  39.   $sel = mysql_query("SELECT CategoryDescInfo FROM categories WHERE CategoryPageName = '$_GET[pagename]'");
  40.   if (mysql_num_rows($sel) > 0) {
  41.     while ($fet = mysql_fetch_array($sel)) {
  42. ?>
  43.         <table border='0' cellpadding='0' cellspacing='0' width='90%' align='center'>
  44.           <tr>
  45.             <td>
  46.     <p><br />
  47.     <?=$fet['CategoryDescInfo']?>
  48.     <br /></p>
  49.  
  50.             </td>
  51.           </tr>
  52.         </table>
  53. <?
  54.     }
  55.   } else echo '';
  56.   } else echo '';
  57.   // End Added Modified
  58.  
  59. //    include("pagina.php");
  60.  
  61.     // Show The Catalog Content
  62.     $q1 = "SELECT * FROM items $my_query ORDER BY ItemID LIMIT $Start, $ByPage";
  63.     $r1 = mysql_query($q1) or die(mysql_error());
  64.     if(mysql_num_rows($r1) > '0'){
  65.         $col = "#D7D7D7";
  66.         while($a1 = mysql_fetch_array($r1)){
  67.             if($col == "#ffffff"){
  68.                 $col = "#ffffff";
  69.             }else{
  70.                 $col = "#ffffff";
  71.             }                                                         // old link item.php?item=$a1[ItemID]
  72.             if($PageFolder == "Folder"){
  73.               $result_rows .= "<tr>\n\t<td cellpadding='4' width='100%' align='center'><a href='http://$_SERVER[HTTP_HOST]/$a1[ItemPageName]/'>$a1[ItemName]</a></td>\n\t\n</tr>\n\n";
  74.           }elseif($PageFolder == "Page"){
  75.             $result_rows .= "<tr>\n\t<td cellpadding='4' width='100%' align='center'><a href='http://$_SERVER[HTTP_HOST]/$a1[ItemPageName].html'>$a1[ItemName]</a></td>\n\t\n</tr>\n\n";
  76.           }else{
  77.         echo " - <b>Please Set Your Page View Preference In The Settings Area</b> - ";
  78.       }
  79.         }
  80.         $qnav = "select count(*) from items $my_query";
  81.         $rnav = mysql_query($qnav) or die(mysql_error());
  82.         $anav = mysql_fetch_array($rnav);
  83.         $rows = $anav[0];
  84.  
  85.         if($rows > $ByPage){
  86.             $NextPrev =  "<br /><table align='center' width='400'><tr>";
  87.             $NextPrev .= "<td align='center' cellpadding='4'> | ";
  88.             $pages = ceil($rows/$ByPage);
  89.             for($i = 0; $i <= ($pages); $i++){
  90.                 $PageStart = $ByPage*$i;
  91.                 $i2 = $i + 1;
  92.                 if($PageStart == $Start){
  93.                     $links[] = " $i2\n\t ";
  94.                 }elseif($PageStart < $rows){
  95.                   if($PageFolder == "Folder"){
  96.                     $links[] = "<a href=\"http://$_SERVER[HTTP_HOST]/category$PageStart/$_GET[pagename]/\">$i2</a>\n\t ";
  97.           }elseif($PageFolder == "Page"){
  98.             $links[] = "<a href=\"http://$_SERVER[HTTP_HOST]/category$PageStart/$_GET[pagename].html\">$i2</a>\n\t ";
  99.               }else{
  100.             echo " - <b>Please Set Your Page View Preference In The Settings Area</b> - ";
  101.           }
  102.         }
  103.       }
  104.        // Below Is The Original Version Before Mod Rewrite
  105.        // $links[] = "<a href=\"cat.php?Start=$PageStart&what=$_GET[what]&CategoryID=$_GET[CategoryID]&ord1=$_GET[ord1]\">$i2</a>\n\t ";
  106.        // Below Was The First Attempt Before Mod Rewrite That Worked
  107.        // $links[] = "<a href=\"http://$_SERVER[HTTP_HOST]/cat.php?Start=$PageStart&pagename=$_GET[pagename]\">$i2</a>\n\t ";
  108.  
  109.             $links2 = implode(" | ", $links);
  110.             $NextPrev .= $links2;
  111.             $NextPrev .=  "| </td>";
  112.             $NextPrev .= "</tr></table><br />\n";
  113.         }
  114.             include_once("templates/ResultsTemplate.php");
  115.     }else{
  116.         include_once("templates/NoResultsTemplate.php");
  117.     }
  118. }else{
  119.   /*******************************************************/
  120.     $q1 = "SELECT * FROM items WHERE ItemPageName = '$_GET[pagename]'";
  121.     $r1 = mysql_query($q1) or die(mysql_error());
  122.     $a1 = mysql_fetch_array($r1);
  123.  
  124.     include_once("templates/ViewItemTemplate.php");
  125. }
  126. } /********************************** END OF THE BIG IF **********************************/
  127.     require_once("$FooterFile");
  128. ?>
  129.  
Aug 9 '07 #1
3 3334
dafodil
392 Contributor
This is the part of your code that gives you the error:
Expand|Select|Wrap|Line Numbers
  1.  
  2. $q1 = "SELECT * FROM items WHERE ItemPageName = '$_GET[pagename]'";
  3.  
  4.  
Check if there is a column ItemPageName inside the items table.
Aug 9 '07 #2
saundra
4 New Member
Thank you, somehow I missed that. Now I am getting this error

Unknown column 'CategoryNum' in 'order clause'

I think this is the code giving me trouble

<?
chdir("..");
require_once("c ommon.php");
require_once("s iteadmin/access.php");
require_once("s iteadmin/AdminNavigation .php");

if(isset($_POST[s1]))
{
if(!empty($_POS T[categoryname]))
{
$CategoryPageNa me = strip_tags($_PO ST[categoryname]);
$BadChars = array("?", ">", "<", ".", ",", "'", "\"", "/", ":", ";", "}", "]", "{", "[", "+", "=",
"_", "-", ")", "(", "*", "&", "^", "%", "$", "#", "@", "!", "~", "`", "\\", "|", " ");
$CategoryPageNa me = str_replace($Ba dChars,"-",$CategoryPage Name);

// If Magic Quotes Are Turned Off, Add Slashes
if (get_magic_quot es_gpc() == 0){$_POST = array_map('adds lashes', $_POST);}

$q1 = "INSERT INTO categories SET
CategoryName = '$_POST[categoryname]',
CategoryNum = '$_POST[CategoryNum]',
CategoryPageNam e = '$CategoryPageN ame' ";
$r1 = mysql_query($q1 );

if(mysql_error( ))
{
$error = "<span class=BlackLink >The category name <font color=black>$_P OST[categoryname]</font> already exist!</span>";
}
}
else
{
$error = "<span class=BlackLink >Enter the New Category name, please!</span>";
}
}

?>

<br>
<center>

<span>Add A New Category</span>
<br><br>

<form method="post">
<table border="1" style="border-collapse: collapse" bordercolor="#D 8D8D8" align="center" cellpadding="4" >
<caption align="center"> <?=$error?></caption>
<tr>
<td align="right">N ew Category Name:</td>
<td><input type="text" name="categoryn ame" size="20"> Category Number: <input type="text" name="CategoryN um" size="1"></td>
</tr><tr>
<td colspan="2" align="center"> <input type="submit" name="s1" value="Add New Category"></td>
</tr>

</table>
</form>

<?

$q1 = "select * from categories order by CategoryNum";
$r1 = mysql_query($q1 ) or die(mysql_error ());

if(mysql_num_ro ws($r1) > '0')
{
echo "<br>";

echo "<table border=\"1\" style=\"border-collapse: collapse\" bordercolor=\"# 000000\" align=\"center\ " width=\"400\" cellpadding=\"2 \"><tr><td background=\"im ages/nav-bgcolor.gif\" align=\"center\ "><b>Positi on</b></td>\n\t\n\t<td background=\"im ages/nav-bgcolor.gif\" align=\"center\ "><b>Categories </b></td>\n\t<td background=\"im ages/nav-bgcolor.gif\" align=center><b >Action</b></td>\n</tr>\n\n";

$col = "white";

while($a1 = mysql_fetch_arr ay($r1))
{
if($col == "white")
{
$col = "dddddd";
}
else
{
$col = "white";
}

echo "<tr bgcolor=$col>\n \t<td align=\"center\ ">$a1[CategoryNum]</td>\n\t<td align=left>$a1[CategoryName]</td>\n\t<td width=100 align=center><a class=GreenLink href=\"EditCate gory.php?Catego ryID=$a1[CategoryID]\">edit</a> | <a class=BlackLink href=\"DeleteCa tegory.php?Cate goryID=$a1[CategoryID]\" onclick=\"retur n cdel('$a1[CategoryName] category');\">d elete</a></td>\n</tr>\n\n";
}

echo "</table>";
}
?>
Aug 9 '07 #3
dafodil
392 Contributor
Just the same as my first advice, check if the column exists.

Expand|Select|Wrap|Line Numbers
  1.  
  2. $q1 = "select * from categories order by CategoryNum";
  3.  
  4.  
Aug 10 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
9870
by: ndsoumah | last post by:
Hello Guys I'm trying to run this query $uneRequete = "SELECT * FROM Usager WHERE motDePasse = {$loginPassword}"; and I get this error message : Error 1054: Unknown column 'xxxx' in WHERE clause..... where 'xxxx' is the content of $loginPassword
1
4185
by: Navin | last post by:
Ado Sort -Relate, Compute By, or Sort operations cannot be done on column(s) whose key length is unknown or exceeds 10 KB. hi, guys i have asp application running on iis 5.0 windows 2000 i use the ado sort property ...... shown below.... Rs.sort="person,lower_manager,lower_ccat_id,sac_name"
6
2431
by: Steve | last post by:
I realize that this probably isn't a best practice, but I'm working with legacy code that has a query stored in one column of a table. Because the queries vary, the JSP page that selects a query and runs it cannot add any additional information (like a WHERE clause). I need to add a few more records to the the table, and would like the query to include a value from another field in the current row in a WHERE clause -- something like...
12
7536
by: yoyo | last post by:
So I'm trying to make an application that currently works with MySql, Postgre, etc... work with DB2. THe problem I have, is, the varchar column only goes to 32k. CLOB goes bigger, but at a major cost. SELECT DISTINCT, UPPER,LOWER, ORDER BY, GROUP BY, among other things don't work on CLOB columns. Without creating many resource robbing UDF's to emulate functionality, is there something I'm missing? Is there a better way to store larger...
8
3287
by: phillip.s.powell | last post by:
This query produces the following error: I'm sorry but I must have this "column" in the query, it's vital for required sorting order (you have to sort image_location_country in alphanumeric order, however, that column can also be null, BUT all NON-NULL fields MUST BE FIRST before all NULL fields!) I'm not sure what's happening, please help!
5
2529
by: Larry in Honolulu | last post by:
I'm getting an error message that makes no sense to me. I have a table with a field named 'testkey' for a list of "keys" in the form of ABC10102. I have a php variable holding a specific key number. The relevant code is - $_testkey = 'LAL10102'; $sql = "SELECT * FROM `pro_keys` WHERE `keynum`=`$_testkey`"; $result=mysql_query($sql,$db_conn); echoing the $sql gives -
4
5692
by: karthikeyanck | last post by:
I'm a newbie, I've installed PHP, Apache and MySQL on my Ubuntu system I've trouble in quering the data from MySQL when using the query function within PHP. I 've created a Database "test", Table "employee", i 've two columns "username" and "password", I've data "admin" and "admin" on both username and the password columns. $u and $p variables has "admin". <?php $query = "SELECT username and password FROM employee WHERE username = $u...
3
6449
by: benicio | last post by:
Database query failed: Unknown column 'subj' in 'where clause' What does this error mean and how should it be fix?
4
10680
tjc0ol
by: tjc0ol | last post by:
Hi guys, I'm a newbie in php and I got error in my index.php which is: 1054 - Unknown column 'p.products_id' in 'on clause' select p.products_image, pd.products_name, p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from products_description pd,...
0
8792
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9337
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9266
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9209
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4826
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3280
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.