Hello;
I using the following sql to get information from two tables --through join;
/
/ this join works in sql, but can
$res = "select ad.firstname, ad.lastname, ad.address, ad.city, ad.state, ad.zipcode, ad.dhtmlgoodies_category, ad.dhtmlgoodies_subcategory, ad.caryear, ad.customerid, ad.servicedesc, aj.email, aj.areacode, aj.phoneprefix, ad.clientID,
aj.phonesufix, aj.cellareacode, aj.cellprefix, aj.cellsufix, aj.commentonclient from additional_cars as ad, ajax_client as aj where ad.clientID='$clientId' group by ad.clientID";
it works fine when tested in phpmyadmin, but fail we incorporated with the following which passes the value to another form using "formObj". here is the entire code:
function toSafeString($string) {
$string = str_replace('<br/>', "\n", $string);
$string = preg_replace('/[\r\n]/s', '\\n', $string);
$string = str_replace(array('<br />','<br/>'),"\n",$string);
return $string;
}
if(isset($_GET['getClientId'])){
$clientId = preg_replace("/[^0-9|a-z|A-Z]/si", "", $_GET['getClientId']);
$res = "select ad.firstname, ad.lastname, ad.address, ad.city, ad.state, ad.zipcode, ad.dhtmlgoodies_category, ad.dhtmlgoodies_subcategory, ad.caryear, ad.customerid, ad.servicedesc, aj.email, aj.areacode, aj.phoneprefix, ad.clientID,
aj.phonesufix, aj.cellareacode, aj.cellprefix, aj.cellsufix, aj.commentonclient from additional_cars as ad, ajax_client as aj where ad.clientID='$clientId' group by ad.clientID";
if($inf = mysql_fetch_array($res)){
echo "formObj.firstname.value = '".toSafeString($inf["firstname"])."';\n";
echo "formObj.lastname.value = '".toSafeString($inf["lastname"])."';\n";
echo "formObj.lastname1.value = '".toSafeString($inf["lastname"])."';\n";
echo "formObj.address.value = '".toSafeString($inf["address"])."';\n";
echo "formObj.zipcode.value = '".toSafeString($inf["zipcode"])."';\n";
echo "formObj.city.value = '".toSafeString($inf["city"])."';\n";
echo "formObj.state.value = '".toSafeString($inf["state"])."';\n";
echo "formObj.dhtmlgoodies_category.value = '".toSafeString($inf["dhtmlgoodies_category"])."';\n";
echo "formObj.dhtmlgoodies_subcategory.value = '".toSafeString($inf["dhtmlgoodies_subcategory"])."';\n";
echo "formObj.caryear.value = '".toSafeString($inf["caryear"])."';\n";
echo "formObj.servicedesc.value = '".toSafeString($inf["servicedesc"])."';\n";
//echo "formObj.theDate.value = '".toSafeString($inf["theDate"])."';\n";
//echo "formObj.areacode.value = '".toSafeString($inf["areacode"])."';\n";
//echo "formObj.phoneprefix.value = '".toSafeString($inf["phoneprefix"])."';\n";
//echo "formObj.phonesufix.value = '".toSafeString($inf["phonesufix"])."';\n";
echo "formObj.email.value = '".toSafeString($inf["email"])."';\n";
//echo "formObj.cellareacode.value = '".toSafeString($inf["cellareacode"])."';\n";
//echo "formObj.cellprefix.value = '".toSafeString($inf["cellprefix"])."';\n";
//echo "formObj.cellsufix.value = '".toSafeString($inf["cellsufix"])."';\n";
echo "formObj.currentmileage.value = '".toSafeString($inf["currentmileage"])."';\n";
//echo "formObj.Balancedue.value ='".toSafeString($inf["Balancedue"])."';\n";
// echo "formObj.uploadedfile.value = '".$uploaddir.$inf["uploadedfile"]."';\n";//this includes directory and filename
echo "formObj.servicearea.value = '".toSafeString($inf["servicearea"])."';\n";
//echo "formObj.commentonclient.value = '".toSafeString($inf["commentonclient"])."';\n";
echo "formObj.drivenmileage.value = '".toSafeString($inf["drivenmileage"])."';\n";
echo "formObj.clientid.value = '".toSafeString($inf["clientID"])."';\n";
//echo "formObj.clientid2.value = '".toSafeString($inf["clientID"])."';\n";
echo "formObj.clientid3.value = '".toSafeString($inf["clientID"])."';\n";
echo "formObj.displayname.value = '".toSafeString($inf["lastname"]).",".toSafeString($inf["firstname"])."';\n";
echo "formObj.returnedClientId.value = '".toSafeString($inf["clientID"])."';\n";
}
else
{
echo "formObj.firstname.value = '';\n";
echo "formObj.lastname.value = '';\n";
echo "formObj.lastname1.value = '';\n";
echo "formObj.address.value = '';\n";
echo "formObj.zipcode.value = '';\n";
echo "formObj.city.value = '';\n";
echo "formObj.state.value = '';\n";
echo "formObj.dhtmlgoodies_category.value = '';\n";
echo "formObj.dhtmlgoodies_subcategory.value = '';\n";
echo "formObj.caryear.value = '';\n";
echo "formObj.servicedesc.value = '';\n";
//echo "formObj.theDate.value = '';\n";
//echo "formObj.areacode.value = '';\n";
//echo "formObj.phoneprefix.value = '';\n";
//echo "formObj.phonesufix.value = '';\n";
echo "formObj.email.value = '';\n";
//echo "formObj.cellareacode.value = '';\n";
//echo "formObj.cellprefix.value = '';\n";
//echo "formObj.cellsufix.value = '';\n";
echo "formObj.currentmileage.value = '';\n";
//echo "formObj.Balancedue.value = '';\n";
echo "formObj.servicearea.value = '';\n";
//echo "formObj.commentonclient.value = '';\n";
echo "formObj.drivenmileage.value = '';\n";
echo "formObj.clientid.value = '';\n";
//echo "formObj.clientid2.value = '';\n";
echo "formObj.clientid3.value = '';\n";
echo "formObj.displayname.value = '';\n";
echo "formObj.returnedClientId.value = '';\n";
}
}
works fine if I'm querying one table, but problem comes about when joining the tables. any thoughts as to why?
Thanks