php-windows Digest 11 Aug 2002 13:22:47 -0000 Issue 1283
Topics (messages 15202 through 15204):
create file (simple)
15202 by: K. Lee
create a file (simple)
15203 by: K. Lee
session nightmare
15204 by: Ricky
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
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;
}
--- End Message ---
--- Begin Message ---
This is my first using php. I trying to do something by creating file to
see the sql statement I am sending to my database. I assuming php does not
have way throw up a simple message box. Anyway, if I could get this file to
create that would be great. Any help would be appreciated.
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 bryan";
}
$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);
$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;
}
--- End Message ---
--- Begin Message ---
Hello everybody I'd like to make a page in which the results shown can
be bookmarked by pressing a button.
Actually first it should check if the session is open already ... Then
if the result (that comes from a query to a MySQL table) has been
registered already, finally it registers all the variables in a
multidimensional array.
this is the code:
session_start();
if(!session_is_registered("bkmks"))
{session_register("bkmks")||die("WE GOT PROBLEMS MAN");
$bkmks = array(array(tab=>$tab, id=>$id, url=>$url, nome=>$nome,
ind=>$ind, com=>$com, pv=>$pv, tel=>$tel, chi=>$chi));
print "<html><body >Your choice has been
stored</body></html>";
}
else
{
foreach($bkmks as $v)
{
if(($v[tab]==$tab)&&($v[id]==$id)){
print "<html><body You have already chosen this item</body></html>";exit;
}
}
$bkmks[][tab]=$tab;
$bkmks[][id]=$id;
$bkmks[][url]=$url;
$bkmks[][nome]=$nome;
$bkmks[][ind]=$ind;
$bkmks[][com]=$com;
$bkmks[][pv]=$pv;
$bkmks[][tel]=$tel;
$bkmks[][chi]=$chi;
print "<html><body>Your choice has
been stored</body></html>";
}
It doesn't work! I can't figure out why.
It starts storing fine and then it seems messing up with values so it
recognises as already stored only the variables of my first choice (the
value stored at bkmks[0])... I tried to print values stored in the
array: the output is a mess I don't know why!
Thanks a lot !
Bye.
--- End Message ---