mysql_escapef

3 posts by 2 authors in: Forums > CMS Builder
Last Post: June 19, 2012   (RSS)

By Toledoh - June 19, 2012

Hi Guys,

This seems to me like it should work... but it doesn't.

Please look at;http://www.fibreking.com/products_a.php?num=4 and http://www.fibreking.com/products_b.php?num=4

In products_a I have the following code;
<?php

// load record from 'items'
list($itemsRecords, $itemsMetaData) = getRecords(array(
'tableName' => 'items',
'where' => whereRecordNumberInUrl(0),
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$itemsRecord = @$itemsRecords[0]; // get first record

echo '<h3>where clause</h3>';
showme(mysql_escapef('products = ?', $itemsRecord['num']));

list($downloadsRecords, ) = getRecords(array(
'tableName' => 'downloads',
'where' => mysql_escapef('products = ?', $itemsRecord['num']),
'allowSearch' => false,
'debugSql' => true,
));
$downloadsRecord = @$downloadsRecords[0]; // get first record

?>


and in products_b;
<?php

// load record from 'items'
list($itemsRecords, $itemsMetaData) = getRecords(array(
'tableName' => 'items',
'where' => whereRecordNumberInUrl(0),
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$itemsRecord = @$itemsRecords[0]; // get first record

echo '<h3>where clause</h3>';
showme(mysql_escapef('products = ?', $itemsRecord['num']));

list($downloadsRecords, ) = getRecords(array(
'tableName' => 'downloads',
'where' => 'products = 4',
'allowSearch' => false,
'debugSql' => true,
));
$downloadsRecord = @$downloadsRecords[0]; // get first record

?>


By looking at the de-bug stuff, I think that the where search is pretty much the same. ie. Show me all downloads where products=4.... when I hard code it - it works (products_b) but not when I use the mysql_escapef...

Can you help? I've attached the complete files if it helps.
Cheers,

Tim (toledoh.com.au)
Attachments:

products_a.php 5K

products_b.php 5K

Re: [Jason] mysql_escapef

By Toledoh - June 19, 2012

That second option seems to work Jason! Thanks!
Cheers,

Tim (toledoh.com.au)