RE: [PHP-DB] What's wrong with this query?

2004-02-26 Thread Paul Fitz


You haven't done that a thousand times - the syntax is wrong :).
You are using a combo of INSERT and UPDATE syntax there.

Try 

INSERT INTO log (term, returns, time, date, ip) VALUES ('$search',
'$arrayword',CURTIME(), CURDATE(), '$ip');

Cheers,
Paul



-Original Message-
From: Axel IS Main [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 26, 2004 7:06 PM
To: PHP-DB
Subject: [PHP-DB] What's wrong with this query?


I've just tried to do something I've done a thousand times. It does not 
work. I've checked all of the syntax, made sure the field and variable 
names are correct. No matter what I do it just doesn't work. The table 
remains empty. Here's the query:

$logit = mysql_query(INSERT INTO log SET term='$search', 
returns='$arrayword', time=CURTIME(), date=CURDATE(), ip='$ip');

Now that doesn't look too difficult does it? Well, apparently it's 
impossible! I'm really hoping someone out there can see something that I

missed.

Nick

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Results with ledger stripes?

2004-01-26 Thread Paul Fitz

Hi, 

You can use the modulus operator to create alternate colour rows.
A bit simpler in code ;)
See below - 



echo tabletrtdDomain/tdtdAverage Speed/td/tr\n;

// Define count variable which is tested in loop
$count = 1;

while ($mongorow = mysql_fetch_array($mongo, MYSQL_NUM)) 
{ 
// If $count divides evenly by 2, white, if not then #efefef
$color = ($count % 2)? #ff : #e4e4e4;

echo tr
bgcolor=$colortd$mongorow[0]/tdtd$mongorow[1]/td/tr\n;
$count++;
}
echo /table;

---

// Done :)


-Original Message-
From: Ricardo Lopes [mailto:[EMAIL PROTECTED] 
Sent: Monday, January 26, 2004 7:29 PM
To: [EMAIL PROTECTED]
Cc: PHP DB
Subject: Re: [PHP-DB] Results with ledger stripes?

I dont see what is your problem, your code do almost anything. Is you
pretend to generate the output in html as you show in the example, you
just
have to add the color property in the td or tr tag, take care with
the 
in the code. ex:

$dummy_var = 0;
$dummy_array = array(#dd, #ff);
while ($mongorow = mysql_fetch_array($mongo, MYSQL_NUM))
{
echo tr bgcolor=
.$dummy_array[$dummy_var].td$mongorow[0]/tdtd$mongorow[1]/td
/tr
\n;
$dummy_var++;
}

And thats is it. You could use css or other things, thats up to you.
Hope
thats solved.

- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, January 26, 2004 1:42 AM
Subject: [PHP-DB] Results with ledger stripes?


 Hello all,

 I'm in the midst of creating an internet speed test system thingamabob
for
 my website.  It's basically finished...but ugly as sin.  What I'd like
to
do
 is have the results (an average of each domain tested) listed in a
nice
 pretty table with alternating background colors, kinda like a ledger.
How
 on earth do I do this?

 Here's what I've got thus far:

 ?php
 echo Average speeds of each domain tested:br;
 $mongo = @mysql_query (SELECT
 substring_index(name,'.',-2),ROUND(AVG(speed),1) FROM `readings` GROUP
BY
 substring_index(name,'.',-2) ORDER BY substring_index(name,'.',-2)
ASC);
 echo tabletrtdDomain/tdtdAverage Speed/td/tr\n;
 while ($mongorow = mysql_fetch_array($mongo, MYSQL_NUM)) { echo
 trtd$mongorow[0]/tdtd$mongorow[1]/td/tr\n;}
 echo /table;
 ?

 And I'd like it to spit out something along these lines:
 table
 tr bgcolor=#ddtddomain1.com/tdtd666.6 kbps/td/tr
 tr bgcolor=#fftddomain2.com/tdtd3000.0 kbps/td/tr
 repeat until done
 /table

 The gizmo is up and running at
 http://www.dibcomputers.com/bandwidthmeter/index.php if you care to
have a
 gander.
 Thanks a bunch,
 Dan









 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Using PHP to print using LP on Linux

2003-10-24 Thread Paul Fitz
 
Hi Guys,
 
I suppose this isn't a database specific question, but it is the only
PHP mailing list I am subscribed to.
 
Trying to trigger a printer in the office hooked up to a Mandrake 8 box
with PHP 4.3 to print a file remotely, using the 'lp' command.
Uses a postscript template to create the text that needs printing.
 
Opens and edits the postscript fine, the printer refuses to work using
the last section of code however.
 
Does anybody have experience using lp with PHP and Linux?
Any help appreciated.
 
Cheers.
 
My Code - 
 
 
$filename = new_user_letter.ps;
$fp = fopen($filename,r);
$fdata = fread($fp, filesize($filename));
fclose($fp);
 
//search and replace all keywords
$fdata = ereg_replace(%%full_name%%,$fullname,$fdata);
$fdata =
ereg_replace(%%street_address%%,$streetaddress,$fdata);
$fdata = ereg_replace(%%town%%,strtoupper($town),$fdata);
$fdata =
ereg_replace(%%state%%,strtoupper($state),$fdata);
$fdata =
ereg_replace(%%postcode%%,strtoupper($postcode),$fdata);
$fdata = ereg_replace(%%date%%,$long_date,$fdata);   
$fdata = ereg_replace(%%username%%,$username,$fdata);
$fdata = ereg_replace(%%email_address%%,$username .
@nor.com.au,$fdata);
$fdata = ereg_replace(%%password%%,$password,$fdata);
$fdata =
ereg_replace(%%primary_dns%%,202.147.135.10,$fdata);
$fdata =
ereg_replace(%%secondary_dns%%,202.147.135.20,$fdata);
$fdata =
ereg_replace(%%pop_location_and_ph_number%%,$location .  -  .
$dial_in_number,$fdata);
$fdata =
ereg_replace(%%domain_name%%,nor.com.au,$fdata);
$fdata =
ereg_replace(%%pop3_server%%,mail.nor.com.au,$fdata);
$fdata =
ereg_replace(%%smtp_server%%,mail.nor.com.au,$fdata);
$fdata =
ereg_replace(%%news_server%%,news.nor.com.au,$fdata);

// Open the lp command for writing and pass the postscript
to it.
//  The loop is to allow multiple copies to be printed,

   for ($copy_loop=0;$copy_loop$num_copies;$copy_loop++){
$fp = popen(/usr/bin/lp -d bw_laser_raw,w);
fputs($fp,$fdata,strlen($fdata));
pclose($fp);
echo .;
}