I am new at php. I trying to debug my code. So, I am trying to print out
my sql statement to a file to make sure the syntax is correct. I trying to
find a way to print out to a message box or something. I guess php does not
have that capability or I cannot find the function that will help me do
that. Anyway, if someone could let me know what is wrong with the code
below or help in any other way, I would greatly appreciated it.
function write_to_file($filename, $stringtowrite, $writetype)
{
$filesession = fopen($filename,$writetype);
fwrite($filesession,"$stringtowrite");
fclose($filesession);
}
function companiesByBusiness_ZipCode_BusinessOrContactName( $ctgyno,
$zipcode, $businessandcontactname ) {
$sql = "select company_no, name, contact, business_phone, mobile_phone,
services_desc, brief_bio, pager, address, city, state, zipcode,
picture_file, case ifnull(picture_file, 'No Picture') when 'No Picture' then
'b' else 'a' end pic_ind from company";
if( $ctgyno != "ALL") {
$sql .= " where business_ctgy_no = $ctgyno";
if( $zipcode != "" ) {
$sql .= " and (zipcode like '".substr( $zipcode, 0, 3 )."%' and zipcode
!= '$zipcode')";
}
if( $businessandcontactname != "" ) {
$sql .= " and name = gil";
$sql .= " or contact = gil";
}
$sql .= " order by pic_ind, name, company_no";
}
write_to_file("developement/indexcode/query.log",$sql,"aw");
$fp=fopen("developement/indexcode/query.log","aw");
fwrite($fp,$sql);
fclose($fp);
$query = mysql_query( $sql ) or die( $sql."<p>".mysql_error() );
//$numrows = mysql_num_rows( $query );
while( $assoc = mysql_fetch_assoc( $query ) ) {
$rows[] = $assoc;
}
return $rows;
}
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php