473,396 Members | 1,840 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,396 software developers and data experts.

CMS Errors + Query Failed

5
Hi,

first of all, ******, I just wrote this text, got redirected in order to log in (I was already logged in, and all the text was gone. |: bah.)

Anway, I digress...

First problem: When I try editing our CMS (content management system I think), basically adding a new column at one of our projects, after I rewrote the php file in order to actually give me a new column, it doesn't "stick". I can write in the newly created column, but when I click on Update it doesn't work. The page just refreshes and the information I provided the column just disappears.

I've done a little sketch/pic to show you what I mean, as I don't think I'm being exceptionally clear. :p

Here's the code that I added/edited in order to get the DOWNLOAD section to show up:

Main.php of the admin section (Only added code where I edited/added something):

Expand|Select|Wrap|Line Numbers
  1. class main{
  2.     function showList(){
  3.         global $module,$panel,$modul_main;
  4.         $f             = new AGFunctionsLib();
  5.  
  6.         $strDefLangCode = $f->getDefaultLanguage();
  7.         $currentLang = $_GET['clang'];
  8.         if ($currentLang == '')
  9.         {
  10.         $currentLang    = $strDefLangCode;
  11.         }
  12.  
  13.         switch($_GET['f']){
  14.             case '1' : $foldername = "Active";break;
  15.             case '2' : $foldername = "New";break;
  16.             case '3' : $foldername = "Trashed";break;
  17.         }
  18.         $fields_arr = array("pr_date|Date|1","pr_name|Project name|1","pr_location|Location|1","pr_team|Team|1","pr_download|Download|1");
formstruct.php (Once again I only copied out the bits where I added something):

Expand|Select|Wrap|Line Numbers
  1. $formstruct = array(
  2.  
  3.     array(
  4.         "name" =>    "pr_download",
  5.         "label" => "Download",
  6.         "objtype" => "HTMLEDITOR",
  7.         "datatype" => "STRING",
  8.         "dim" => "90,30",
  9.         "showImagePallete"=>1,
  10.         "dbfield" => "pr_download"
  11.     ),
  12.  
  13. $formstructAdd = array(
  14.  
  15.     array(
  16.         "name" =>    "pr_download",
  17.         "label" => "Download",
  18.         "objtype" => "HTMLEDITOR",
  19.         "datatype" => "STRING",
  20.         "dim" => "90,30",
  21.         "showImagePallete"=>1,
  22.         "dbfield" => "pr_download"
  23.     ),
If you guys need the full php file in order to help me, do tell and I will provide you with it.

Next, in the AGFunctionsLib.class (I'm guessing it's the main functions library ;p) I rewrote/added stuff in order to make it show up on the website:

Expand|Select|Wrap|Line Numbers
  1. function prepareProjectPage($id='',$sub='',$loc=''){
  2.     global $conf,$layout,$lang;
  3.         $f = new AGFunctionsLib;
  4.         $project = new AGProject();
  5.  
  6.         if($_GET['displaymode']=='print'){
  7.             $strDisp = 'print';
  8.         }else{
  9.             $strDisp = 'full';
  10.         }
  11.  
  12. ---- Lines and lines of code -----
  13.  
  14.         /*--content banner--*/
  15.         $strBannerFile = $f->getGeneralContent('c_pic','PROJECTS',197);
  16.         $strBanner = "<img src='/gallery".$strBannerFile."'>";
  17.         $layout->AddComponent('contentBanner',$strBanner);
  18.  
  19.         //$strContent = $project->getProjectList($id);
  20.         if ($loc=='')
  21.         {
  22.         if ($sub=='')
  23.         {
  24.         $strContent = $f->getProjectContent('pr_desc',$id);
  25.         }
  26.         elseif ($sub=='1')
  27.         {
  28.         $strContent = $f->getProjectContent('pr_desc',$id);
  29.         }
  30.         elseif ($sub=='2')
  31.         {
  32.         $strContent = $f->getProjectContent('pr_team',$id);
  33.         }
  34.         elseif ($sub=='4')
  35.         {
  36.         $strContent = $f->getProjectContent('pr_download',$id);
  37.         }
  38.         elseif ($sub=='3')
  39.         {
  40.         $strContent = $f->getProjectContent('pr_contact',$id);
  41.         }
  42.         else
  43.         {
  44.         $strContent = $f->getProjectContent('pr_desc',$id);
  45.         }
  46.  
  47. ------ lines and lines of code ------
  48.  
  49. function getProjectSearchResult($strFieldName){
  50.             global $conf;
  51.             $db = new AGDBConnection();
  52.             $rs = new AGDBRecordset();
  53.             $f = new AGFunctionsLib();
  54.             $dbo = $db->init($conf['dsn']);
  55.  
  56.  
  57.                 $sql = "select * from projects where pr_status=1 AND (pr_name like '%$strFieldName%' OR pr_location like '%$strFieldName%' OR pr_desc like '%$strFieldName%' OR pr_team like '%$strFieldName%' OR pr_contact like '%$strFieldName%' OR pr_download like '%$strFieldName%') order by pr_ID DESC";
Now here's the rub, whenever I try to use the search function, I get this:

Query Failed: Unknown column 'pr_download' in 'where clause'
select * from projects where pr_status=1 AND (pr_name like '%decentralisation%' OR pr_location like '%decentralisation%' OR pr_desc like '%decentralisation%' OR pr_team like '%decentralisation%' OR pr_contact like '%decentralisation%' OR pr_download like '%decentralisation%') order by pr_ID DESC

That error also appears whenever I try to click on the Download link (the one I added) on the project pages.

So, yeah, help me please. :p I'll happily provide you with any kind of code/file that you need, just ask. If I haven't been clear enough on something, do tell.

Thank you very much in advance,

Lorien
Jun 12 '09 #1
5 2769
Atli
5,058 Expert 4TB
Hi.

The error you posted at the bottom tell us that you are trying to use a column that doesn't exist. A pr_download column in the projects table.

I would start by fixing that error. Make sure the column exists, and that it is spelled correctly in the query. (Assume it is case sensitive.)

If the problem persists after that, please show us the exact structure of the table.
(The result of SHOW CREATE TABLE is best)

The code where the INSERT or UPDATE queries for you update functionality are executed would be helpful to.
Jun 12 '09 #2
sydd
5
@Atli
Sorry for the late reply.

I'm guessing you mean this?

Expand|Select|Wrap|Line Numbers
  1.     function processUpdate($postData){
  2.             global $dbo,$module;
  3.             $cm = new AGDBCommand();
  4.             //updating services
  5.             $memberID = $_POST['pr_ID'];
  6.             $selectedServiceArr = preg_split("/,/",$_POST['serviceSelected']);
  7.             $provarr = preg_split('//', $_POST['serviceSelected'], -1, PREG_SPLIT_NO_EMPTY);
  8.             $hurufpertama=$provarr[0];
  9.             if ($hurufpertama <> ',')
  10.             {
  11.             $location=",".$_POST['serviceSelected'];
  12.             }
  13.             else
  14.             {
  15.             $location=$_POST['serviceSelected'];
  16.             }
  17.             //$location=$_POST['serviceSelected'];
  18.                     $insSql = "UPDATE projects SET pr_location = '$location' WHERE pr_ID = $memberID";
  19.                     $cm->exec($insSql,$dbo);
  20.                 $f = new AGFunctionsLib();
  21.  
  22.                 $dataEdit = new AGDBForm2DB;
  23.                 $dataEdit->table = $module->table;
  24.                 $dataEdit->condition = $module->pkey." = " . $_GET['id'];
  25.                 $strSerial = date("Ymdhis");
  26.                 $dataEdit->dataUpdate();
  27.     }
  28.  
  29.     function processInsert(){
  30.             global $dbo,$module;
  31.             $f = new AGFunctionsLib();
  32.             $curr_date = date("Y-m-d");
  33.             $curr_time = date("h:i:s");
  34.             $dataAdd = new AGDBForm2DB;
  35.             $strSerial = date("Ymdhis");
  36.             $dataAdd->table = $module->table;
  37.             $dataAdd->dataSave();
  38.  
  39.             $lastRecord = $f->getLastRecord("projects");
  40.             $prID = $lastRecord[0]['pr_ID'];
  41.  
  42.             $cm = new AGDBCommand();
  43.             $selectedService = $_POST['serviceSelected'];
  44.                     $insSql = "UPDATE projects SET pr_location='$selectedService' WHERE pr_ID = $prID";
  45.                     $cm->exec($insSql,$dbo);
  46.  
  47.             //add empty data for other languages
  48.  
  49.         $langQ = "select * from lang where lang_status=1 and lang_default <> 1";
  50.         $langRS = new AGDBRecordset();
  51.         $langRS->querynfetch($langQ,$dbo);
  52.         foreach($langRS->arrRowResult as $rows){
  53.             $pr_lang = $rows['lang_code'];
  54.             $pr_code = $_POST['pr_code'];
  55.             $pr_name = $_POST['pr_name'];
  56.             $pr_download = $_POST['pr_download'];
  57.             //$pr_description = $_POST['pr_description'];
  58.             $langIns = "insert into projects(pr_lang,pr_code,pr_name,pr_status) values('$pr_lang','$pr_code','$pr_name',1)";
  59.             $q = new AGDBCommand();
  60.             $q->exec($langIns,$dbo);
  61.         }
  62.         $langRS->freeResult();
  63.  
  64.     }
I know that the error means that there's a missing column, but the problem is that the column IS in the CMS and on the website. I just can't edit it on the CMS or enter any data into that specific column. The problem is that the website and the CMS was designed by a company (which doesn't exist anymore) via an outside contractor, who so far hasn't replied to any of our E-Mails. So we have nobody who's familiar with the CMS. My only options are to either rewrite the CMS or completely start from scratch and make one myself. As I don't have the time for the latter, I think I'll stick to rewriting it. So far there haven't been any problems, but now... well, yeah.

Furthermore, the SHOW CREATE TABLE - to be honest I have no idea what you want me to do. I figure it's a MySQL command? If so, how do I enter it and where? Download mysql (client) and fiddle around? I have close to nil experience with MySQL programming. Sorry if I'm not being of much help.
Jun 15 '09 #3
Atli
5,058 Expert 4TB
Ok.

The fact that this is in the CMS doesn't really tell us much.
The error, however, does tell us the field doesn't exist in the table.

Perhaps this is something whoever originally designed this was intending to implement but left it out for some reason.

In any case, we need to see the table structure to be sure what's going on.

You need to find the MySQL username, password and database name (probably in some configuration file in your CMS), put it into the following code, put the code into a new PHP file, and execute it.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // We don't need HTML for this
  3. header("Content-Type: text/plain");
  4. ini_set("html_errors", false);
  5.  
  6. // Connect to MySQL
  7. $dbLink = mysql_connect("localhost", "mysqlUser", "mysqlPassword")
  8.     or die("Failed to connect to MySQL! \n". mysql_error());
  9. mysql_select_db('mysqlDatabase', $dbLink)
  10.     or die("Failed to select a table!\n". mysql_error());
  11.  
  12. // Execute the query
  13. $sql = "SHOW CREATE TABLE `User`";
  14. $result = mysql_query($sql, $dbLink)
  15.     or die("Query failed!\n{$sql}\n". mysql_error($dbLink));
  16.  
  17. // Show the output
  18. $row = mysql_fetch_row($result);
  19. echo $row[1];
  20.  
  21. // Free resources
  22. mysql_free_result($result);
  23. mysql_close($dbLink);
  24. ?>
That should print the exact structure of your table.
Jun 15 '09 #4
sydd
5
Okay I think I fixed it.

Edited the config.php (had the wrong username/password/database for phpMyAdmin) and now I'm able to log into the MySQL databases. You were right, pr_download wasn't in the table where it was supposed to be, now that I've edited it works fine.

Thanks for the help anyway!
Jun 16 '09 #5
sydd
5
GNAH!

I wish for once these things do what I want them to do.

Okay I've fixed what I wanted to fix, but some old problem I never thought of in my previous posts suddenly reappeared:


When - in the CMS - I click on New (Add New Data), basically creating a new project (not the columns, they're part of the project) everything is fine until I try click on "Edit Data". Then the _content_ of one of the trashed projects suddenly appears in the columns. I don't think I'm being very clear again so here's a picture:

Step by step picture of what's wrong.

My Paint skills are amazing. :p

So here you have it, I hope I explained it properly. On a sidenote, whenever I try to DELETE the trashed items, they disappear completely (all of them) and reappear whenever I trash something else. Going crazy here.

Sorry for the spam.
Jun 16 '09 #6

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

Similar topics

11
by: mikey_boy | last post by:
Hello! Curious if anyone could give me a hand. I wrote this PHP script with makes a simple connection to a mysql database called firstdb and just pulls back the results and displays on the...
4
by: Morgan Leppink | last post by:
Hey all - We are running SQL 2000 with ALL available service packs, etc. applied. We just built a brand new database server, which has dual 2Ghz XEONs, 2GB memory, and the following disk...
3
by: lkrubner | last post by:
I'm getting this error: <b>Warning</b>:...
4
by: Sean C. | last post by:
Helpful folks, I've just migrated our test server from V7.2 -FP11 to V8.1.3, on WinNT 4.0. Everything went pretty darn smoothly, however I get the following errors when using the Control Center:...
1
by: VBSponge | last post by:
Hi all. Need help here as I cant see whats wrong... I have a querydef in Access 2k which execs a stored proc in a SQL Server 2k db. I keep getting the following error, and cant stop it for the...
1
by: Joseph S. | last post by:
Hi all, (1) The "standard method" for handling errors when executing queries to a mysql database, which is shown in most tutorials and books is: mysql($query) or die("select/insert/update/delete...
1
by: alvinstraight38 | last post by:
I have a client who has been receiving hundreds of SQL timeout error messages in their error logs. Specifically, the message looks like this: MESSAGE :...
0
by: wmihelpme | last post by:
Hi All, I have written a WMI Program which changes the network settings like ip address, subnet mask, gateway and dns addresses for given adapter number. when I call that function for adapter...
15
by: Lawrence Krubner | last post by:
Does anything about this script look expensive, in terms of resources or execution time? This script dies after processing about 20 or 25 numbers, yet it leaves no errors in the error logs. This is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.