Retrieval issue
16 posts by 2 authors in: Forums > CMS Builder
Last Post: May 12, 2010 (RSS)
By northernpenguin - May 11, 2010 - edited: May 11, 2010
I have a website which provides case studies (pdf) for purchase. Clients search for them, add them to a cart and purchase them. The only information returned to my website is the title of the case study.
How can I use the returned title to get the appropriate filename from cmsb?
Each record in my section editor has both the case study title and its filename.
Any assistance would be appreciated!
Thanx
(Here is the code I am using to retrieve the title from InternetSecure)
<?php
$Products = $_POST['Products'];
$counter = 1;
$prodArray = explode("|",$Products);
foreach ($prodArray as $p)
{
if($counter>1)
{
$element = explode("::",$p);
$description = $element[3];
//print "$description<br />";
}
$counter++;
$prod[$counter]=$description;
print "$description<br>";
}
?>
northernpenguin
Northern Penguin Technologies
"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke
Re: [northernpenguin] Retrieval issue
By Jason - May 11, 2010
So, at the end of your code, is $prod an array of titles, or descriptions?
Are you trying to retrieve all of the file names from CMSB that match that array of titles?
Let me know and we'll figure out a solution.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Retrieval issue
$Products is a string whose content is similar to the following:
Price::Qty::Code::Description::Flags|25.00::1::CD001::Closing the Baldwin Hospital::{GST}{TEST}|15.00::1::CD001::Formulating a Provincial Budget, revised::{GST}{TEST}
My script isolates the "Description" field and creates an array, $prod, which is the title of the case studies .
Based on the purchased titles, I want to retrieve the filenames from cmsb.
If you wish, you can try it out on the site (not yet in production, so don't worry about being charged anything! Use 4545454545454545 for the credit card.)
http://www.ipac.ca/casestudies
Search for a case study, add it to the cart, view the cart and checkout. The output of the script will be sent to your web page.
northernpenguin
Northern Penguin Technologies
"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke
Re: [northernpenguin] Retrieval issue
By Jason - May 11, 2010
Okay, what we can do is use the information in $prod to create a list that we can search the database with:
First, we use this code:
$list="(";
foreach($prod as $p){
if($list=="("){
$list.="'".mysql_escape($p)."'";
}
else{
$list.=",'".mysql_escape($p)."'";
}
}
$list.=")";
This will produce a string that would look something like this for example:
('Administrative In-Basket Exercise','The Commissioner\'s Dilemma')
Once we have this, we can use it to do a search in the database. The getRecords would look something like this:
list($records,$metadata)=getRecords(array(
'tableName'=>'listings',
'allowSearch'=>false,
'where'=>"title IN ".$list,
));
Obviously you'd have to change names in order to make it match what you have in your database.
Give that a try and let me know if that does what you're looking for.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Retrieval issue
Fatal error: Call to undefined function: mysql_escape() in /var/www/vhosts/ipac.ca/httpdocs/casestudies/includes/success.php on line 25
I have attached the script, as it might be easier to see it from there.
northernpenguin
Northern Penguin Technologies
"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke
Re: [northernpenguin] Retrieval issue
By Jason - May 11, 2010
You may have an old version of the database functions library. But it's okay, just replace the first bit of code I gave you with this:
$list="(";
foreach($prod as $p){
if($list=="("){
$list.="'".mysql_real_escape_string($p)."'";
}
else{
$list.=",'".mysql_real_escape_string($p)."'";
}
}
$list.=")";
Give that a try and let me know if it works for you.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Retrieval issue
By northernpenguin - May 11, 2010 - edited: May 11, 2010
I get the following error msgs:
Warning: mysql_real_escape_string(): Access denied for user 'apache'@'localhost' (using password: NO) in /var/www/vhosts/ipac.ca/httpdocs/casestudies/includes/success.php on line 25
Warning: mysql_real_escape_string(): A link to the server could not be established in /var/www/vhosts/ipac.ca/httpdocs/casestudies/includes/success.php on line 25
Warning: mysql_real_escape_string(): Access denied for user 'apache'@'localhost' (using password: NO) in /var/www/vhosts/ipac.ca/httpdocs/casestudies/includes/success.php on line 28
Warning: mysql_real_escape_string(): A link to the server could not be established in /var/www/vhosts/ipac.ca/httpdocs/casestudies/includes/success.php on line 28
Warning: mysql_real_escape_string(): Access denied for user 'apache'@'localhost' (using password: NO) in /var/www/vhosts/ipac.ca/httpdocs/casestudies/includes/success.php on line 28
Warning: mysql_real_escape_string(): A link to the server could not be established in /var/www/vhosts/ipac.ca/httpdocs/casestudies/includes/success.php on line 28
Fatal error: Call to undefined function: getrecords() in /var/www/vhosts/ipac.ca/httpdocs/casestudies/includes/success.php on line 35
northernpenguin
Northern Penguin Technologies
"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke
Re: [northernpenguin] Retrieval issue
By Jason - May 11, 2010
Could you attach the file you're working with so I can take a closer look.
Thanks.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Retrieval issue
The errors I am now getting are:
Notice: Undefined variable: list in /var/www/vhosts/ipac.ca/httpdocs/casestudies/includes/success.php on line 12
MySQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ORDER BY dragSortOrder DESC' at line 3
northernpenguin
Northern Penguin Technologies
"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke
Re: [Jason] Retrieval issue
Notice: Undefined variable: description in /var/www/vhosts/ipac.ca/httpdocs/casestudies/includes/success.php on line 23
Notice: Undefined variable: description in /var/www/vhosts/ipac.ca/httpdocs/casestudies/includes/success.php on line 24
Closing the Baldwin Hospital
Formulating a Provincial Budget, revised
northernpenguin
Northern Penguin Technologies
"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke