473,320 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Unknown column 'ItemPageName' in 'where clause'

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 3278
dafodil
392 256MB
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
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("common.php");
require_once("siteadmin/access.php");
require_once("siteadmin/AdminNavigation.php");

if(isset($_POST[s1]))
{
if(!empty($_POST[categoryname]))
{
$CategoryPageName = strip_tags($_POST[categoryname]);
$BadChars = array("?", ">", "<", ".", ",", "'", "\"", "/", ":", ";", "}", "]", "{", "[", "+", "=",
"_", "-", ")", "(", "*", "&", "^", "%", "$", "#", "@", "!", "~", "`", "\\", "|", " ");
$CategoryPageName = str_replace($BadChars,"-",$CategoryPageName);

// If Magic Quotes Are Turned Off, Add Slashes
if (get_magic_quotes_gpc() == 0){$_POST = array_map('addslashes', $_POST);}

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

if(mysql_error())
{
$error = "<span class=BlackLink>The category name <font color=black>$_POST[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="#D8D8D8" align="center" cellpadding="4">
<caption align="center"><?=$error?></caption>
<tr>
<td align="right">New Category Name:</td>
<td><input type="text" name="categoryname" size="20"> Category Number: <input type="text" name="CategoryNum" 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_rows($r1) > '0')
{
echo "<br>";

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

$col = "white";

while($a1 = mysql_fetch_array($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=\"EditCategory.php?CategoryID=$a1[CategoryID]\">edit</a> | <a class=BlackLink href=\"DeleteCategory.php?CategoryID=$a1[CategoryID]\" onclick=\"return cdel('$a1[CategoryName] category');\">delete</a></td>\n</tr>\n\n";
}

echo "</table>";
}
?>
Aug 9 '07 #3
dafodil
392 256MB
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
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...
1
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...
6
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...
12
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...
8
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...
5
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...
4
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",...
3
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
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,...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.