php-general Digest 15 Mar 2003 09:30:16 -0000 Issue 1939
Topics (messages 139763 through 139790):
Re: OT? Dynamic Page Setup in IE please help
139763 by: David T-G
inserting parameters into URLs dynamically
139764 by: Maureen Roihl
139766 by: Ernest E Vogelsinger
139777 by: Tom Rogers
139784 by: Hugh Danaher
General Information About Porting a Monolithic Perl CGI Script to PHP
139765 by: Richard Ward
139768 by: Ernest E Vogelsinger
Re: inserting parameters into URLs dynamically]
139767 by: Pete James
Re: Apache 2.0 and PHP
139769 by: Ernest E Vogelsinger
Re: form/text area input problem
139770 by: Boaz Yahav
Convert Date to MySQL format
139771 by: Vernon
My PHP mysql Command
139772 by: Philip J. Newman
mysql_connect issue
139773 by: Steve Shead
139774 by: Philip J. Newman
Header order
139775 by: John Taylor-Johnston
Re: php file writting ?
139776 by: Tom Rogers
str_replace
139778 by: Sebastian
139779 by: John Gray
139781 by: Sebastian
139782 by: Hugh Danaher
139785 by: Hugh Danaher
139790 by: Ernest E Vogelsinger
Feasability of Serial functions and constantly running progrms
139780 by: Jason Young
Re: Newbie MySQL INSERT Q
139783 by: Uttam
Re: checking $_POST variables
139786 by: Justin French
Re: Checking for a Valid Email String.
139787 by: Justin French
Re: Crypting Passwords for storage.
139788 by: Justin French
Re: Dynamic titles.
139789 by: Justin French
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 ---
Anthony --
Your question is pure browser. Good luck, especially considering the
browser you have to target :-)
You might be able to change the setting with some javascript. You might
also be able to define the print format with a style sheet (doubtful).
In either case, you need to get into IE internals to see what it is that
you want to set.
I don't think you'll be able to do this for "only this page", though you
could perhaps put the settings back (hey, store 'em in a cookie; it can't
get much worse!) after the job has printed.
HTH & Good luck & HAND
:-D
--
David T-G * There is too much animal courage in
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED] -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!
pgp00000.pgp
Description: PGP signature
--- End Message ---
--- Begin Message ---
We are looking for a way to set several key/value pairs (which will differ
across users) such that they will persist during the user's session and
be logged in the weblogs for every request that user makes. Some
potential ways of doing this that occurred to us:
- implement functionality to programmatically append these parameters to
the querystring of all urls displayed across our site (far too cumbersome,
we don't consider this a viable option)
- find a way for PHP to automatically tack the parameters onto the ends
of url querystrings, the same way it can do with PHPSESSIONID (we haven't
found, in our initial research, a way to do this)
Our primary goal is to get these parameters logged in the weblogs, without
having to programmatically/physically modify every link on our site. For
example, if we wanted to track parameters called x and y, the link on the
page would just point to:
/index.php
but the weblog would show something like the following hit:
/index.php?x=foo&y=bar
The parameter values would need to get set once at the beginning of a user's
session, and then would not change over the course of that session (but
they'd need to get tracked with every request they made). We're planning to
implement persistent sessions across our servers as well.
====================================
Maureen Roihl
Senior Web Developer
Smarter Living
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
At 22:31 14.03.2003, Maureen Roihl said:
--------------------[snip]--------------------
>- find a way for PHP to automatically tack the parameters onto the ends
>of url querystrings, the same way it can do with PHPSESSIONID (we haven't
>found, in our initial research, a way to do this)
>
>Our primary goal is to get these parameters logged in the weblogs, without
>having to programmatically/physically modify every link on our site. For
>example, if we wanted to track parameters called x and y, the link on the
>page would just point to:
>
>/index.php
>
>but the weblog would show something like the following hit:
>
>/index.php?x=foo&y=bar
>
>The parameter values would need to get set once at the beginning of a user's
>session, and then would not change over the course of that session (but
>they'd need to get tracked with every request they made). We're planning to
>implement persistent sessions across our servers as well.
--------------------[snip]--------------------
PHP implements href rewriting in the final stage of output. You could
easily hook in here using output buffering.
ob_start('weblogize_links');
function weblogize_links($buffer)
{
// parse the output $buffer and modify all links
}
A special gotcha may come in here: take care to only rewrite links that
point to your own site.
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/
--- End Message ---
--- Begin Message ---
Hi,
Saturday, March 15, 2003, 7:31:52 AM, you wrote:
MR> We are looking for a way to set several key/value pairs (which will differ
MR> across users) such that they will persist during the user's session and
MR> be logged in the weblogs for every request that user makes. Some
MR> potential ways of doing this that occurred to us:
MR> - implement functionality to programmatically append these parameters to
MR> the querystring of all urls displayed across our site (far too cumbersome,
MR> we don't consider this a viable option)
MR> - find a way for PHP to automatically tack the parameters onto the ends
MR> of url querystrings, the same way it can do with PHPSESSIONID (we haven't
MR> found, in our initial research, a way to do this)
MR> Our primary goal is to get these parameters logged in the weblogs, without
MR> having to programmatically/physically modify every link on our site. For
MR> example, if we wanted to track parameters called x and y, the link on the
MR> page would just point to:
MR> /index.php
MR> but the weblog would show something like the following hit:
MR> /index.php?x=foo&y=bar
MR> The parameter values would need to get set once at the beginning of a user's
MR> session, and then would not change over the course of that session (but
MR> they'd need to get tracked with every request they made). We're planning to
MR> implement persistent sessions across our servers as well.
MR> ====================================
MR> Maureen Roihl
MR> Senior Web Developer
MR> Smarter Living
MR> [EMAIL PROTECTED]
You could use something like this
<?php apache_note('PHP_TITLE','Home Page')?>
Then the log formatter line needs \"%{PHP_TITLE}n\" adding
--
regards,
Tom
--- End Message ---
--- Begin Message ---
Mo,
"(we haven't found, in our initial research, a way to do this)"
You could format your variables before they're needed in the link
something like:
if(isset($x)) $x_link="&x=$x";
if(isset($y)) $y_link="&y=$y";
etc.
then your link would look like the following
<a href=someplace.com?slug=1$x_link$y_link....>someplace.com</a>
"slug=1" is used so that none of the preformatted variables need to start
with a ? instead of an &. if one, or several of the preformatted variables
are empty, the line just slides to the left and fills any vacancies. If all
your pages start with the same if(isset()) table, then the variables will be
passed around as long as the user stays at your site. No cookies or
sessions required.
Hope this helps,
Hugh
----- Original Message -----
From: "Maureen Roihl" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, March 14, 2003 1:31 PM
Subject: [PHP] inserting parameters into URLs dynamically
> We are looking for a way to set several key/value pairs (which will differ
> across users) such that they will persist during the user's session
and
> be logged in the weblogs for every request that user makes. Some
> potential ways of doing this that occurred to us:
>
> - implement functionality to programmatically append these parameters to
> the querystring of all urls displayed across our site (far too
cumbersome,
> we don't consider this a viable option)
>
> - find a way for PHP to automatically tack the parameters onto the
ends
> of url querystrings, the same way it can do with PHPSESSIONID (we haven't
> found, in our initial research, a way to do this)
>
> Our primary goal is to get these parameters logged in the weblogs, without
> having to programmatically/physically modify every link on our site. For
> example, if we wanted to track parameters called x and y, the link on the
> page would just point to:
>
> /index.php
>
> but the weblog would show something like the following hit:
>
> /index.php?x=foo&y=bar
>
> The parameter values would need to get set once at the beginning of a
user's
> session, and then would not change over the course of that session (but
> they'd need to get tracked with every request they made). We're planning
to
> implement persistent sessions across our servers as well.
>
> ====================================
> Maureen Roihl
> Senior Web Developer
> Smarter Living
> [EMAIL PROTECTED]
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
Hello,
I have a ~5500 line monolithic Perl script that I distribute with my
commercial application for processing forms on any Web server that supports
CGI and Perl. Perl has been a wonderful platform because of its portability.
However, people are now suggesting that my program also support PHP, so I
began reading about PHP at http://www.php.net.
I have also searched the archives in this list for tips and suggestions when
porting Perl to PHP, but haven't found much so far. Can someone point me to
references that may be useful for porting Perl to PHP? I'd like to hear
about the experiences of others who have done this.
Also, from my reading, it sounds like some of the features I might need in
PHP are considered extensions. For example, my Perl script makes heavy use
of searching and replacing using regular expressions. I've read on the PHP
web site that Perl-like regular expression support is now part of the
typical installation of PHP (maybe I got this wrong). My concern is, well,
that means there are probably many installations of PHP out there that don't
have this support, so I would need to tell people that if they were to use
my PHP script, they'll need to install a few things like support for regular
expressions. In my case, the less installation required, the better.
I am not using any Perl modules, so this shouldn't be a concern, although
I've been considering using the Perl DBI module for generic database
support. I have not yet found a DBI equivalent for PHP.
Any comments or suggestions would be greatly appreciated.
Richard
--- End Message ---
--- Begin Message ---
At 22:26 14.03.2003, Richard Ward said:
--------------------[snip]--------------------
>Also, from my reading, it sounds like some of the features I might need in
>PHP are considered extensions. For example, my Perl script makes heavy use
>of searching and replacing using regular expressions. I've read on the PHP
>web site that Perl-like regular expression support is now part of the
>typical installation of PHP (maybe I got this wrong). My concern is, well,
I haven't come across an installation of PHP that doesn't have
Perl-compatible regex (the preg_xxx functions) enabled.
>I am not using any Perl modules, so this shouldn't be a concern, although
>I've been considering using the Perl DBI module for generic database
>support. I have not yet found a DBI equivalent for PHP.
Have a look at ADODB (http://php.weblogs.com/). This is an attempt to
create a database-independent layer for PHP - it works with most major
databases (including ODBC) and keeps you off the hassles of implementing
database-specific code. (Disclaimer - this is not, and cannot be, valid for
non-standard SQL extensions offered by any particular database, if you're
using them).
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/
--- End Message ---
--- Begin Message ---
You could use output buffering to do the rewriting for you.
IF you use ob_start('my_function'); at the top of your page, where
my_function is the name of a callback function
This function might look like this:
function my_function($buffer)
{
return $buffer . '?x=foo&y=bar';
}
That's it... well, almost. There are obviously considerations for doing
this in forms and when urls already contain vars.
If you want, I've got a pre-built class that does exactly what you
want. Mail me offline.
P.
Maureen Roihl wrote:
>
> We are looking for a way to set several key/value pairs (which will differ
> across users) such that they will persist during the user's session and
> be logged in the weblogs for every request that user makes. Some
> potential ways of doing this that occurred to us:
>
> - implement functionality to programmatically append these parameters to
> the querystring of all urls displayed across our site (far too cumbersome,
> we don't consider this a viable option)
>
> - find a way for PHP to automatically tack the parameters onto the ends
> of url querystrings, the same way it can do with PHPSESSIONID (we haven't
> found, in our initial research, a way to do this)
>
> Our primary goal is to get these parameters logged in the weblogs, without
> having to programmatically/physically modify every link on our site. For
> example, if we wanted to track parameters called x and y, the link on the
> page would just point to:
>
> /index.php
>
> but the weblog would show something like the following hit:
>
> /index.php?x=foo&y=bar
>
> The parameter values would need to get set once at the beginning of a user's
> session, and then would not change over the course of that session (but
> they'd need to get tracked with every request they made). We're planning to
> implement persistent sessions across our servers as well.
>
> ====================================
> Maureen Roihl
> Senior Web Developer
> Smarter Living
> [EMAIL PROTECTED]
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
At 19:37 14.03.2003, Michael Aaron said:
--------------------[snip]--------------------
>Sorry if this has been answered before but I can not find it anywhere:
>
>Why does the PHP docs. state:
> "Do not use Apache 2.0 and PHP in a production environment neither on
>Unix nor on Windows. "
>
>What is the reason for this Warning?
--------------------[snip]--------------------
Apache 2.0 implements multithreading, while the 1.x versions were forking
processes. While this might increase the overall speed of the webserver,
all (and I mean ALL) used extensions, end extensions for these extensions,
must be written in a thread-safe way.
While the PHP core group as to my knowledge has already implemented PHP
(4.3.0 that is) in a thread-safe way, most of PHP extension modules are not
(yet?) thread safe.
Might get you into a core dump I suppose...
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/
--- End Message ---
--- Begin Message ---
Did you play with
<TEXTAREA WRAP="HARD"></TEXTAREA>
or
<TEXTAREA WRAP="VIRTUAL"></TEXTAREA>
Sincerely
berber
Visit http://www.weberdev.com/ Today!!!
To see where PHP might take you tomorrow.
-----Original Message-----
From: Poon, Kelvin (Infomart) [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 13, 2003 6:25 PM
To: '- Edwin'
Cc: '[EMAIL PROTECTED]'
Subject: RE: [PHP] form/text area input problem
THanks guys, I think I will use wordwarp()
-----Original Message-----
From: - Edwin [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 13, 2003 11:07 AM
To: Poon, Kelvin (Infomart); '[EMAIL PROTECTED]'
Subject: Re: [PHP] form/text area input problem
"Poon, Kelvin (Infomart)" <[EMAIL PROTECTED]> wrote:
[snip]
> the problem is when I display it it would be a one lined paragraph.
> THe page's format is ruin since this is one long line and the user
> will have to scroll across to read the paragraph which look pretty
bad.
>
> I hope you know what i am trying to say.
[/snip]
Hmm, I guess I know what you're trying to say but *that* is NOT the
normal behaviour (if I may say). Putting one long paragraph inside
<p></p> tags "should" automagically wrap it... If not, you can probably
use CSS to limit the width of your <p></p>'s (paragraphs) so it wouldn't
destroy the "format" of your page.
- E
__________________________________________________
Do You Yahoo!?
Yahoo! BB is Broadband by Yahoo! http://bb.yahoo.co.jp/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
I've had to convert times in a MySQL field to a normal date, but never in
reverse. How to I convert a date in this format, 03/14/2003, to MySQL format
so it can be posted to a date field?
Thanks
--- End Message ---
--- Begin Message ---
Assuming that gAccessLevel = eather one of level-1, level-2, level-3 ...
if (!$gStart) { $gStart=0; }
$sql = "SELECT * FROM gallerys WHERE gMode = '$mode' AND ";
if ($siteAccessLevel == "level-1") {
// LEVEL-1 VIEWING ONLY.
$sql .= "WHERE (gAccessLevel = 'level-1')";
} else if ($siteAccessLevel == "level-2") {
// LEVEL-2 AND LEVEL-1 VIEWING ONLY.
$sql .= "WHERE (gAccessLevel = 'level-1' OR gAccessLevel = 'level-2')";
} else if ($siteAccessLevel == "level-3") {
// PAYING, ACCESS ALL IMAGES!
$sql .= "WHERE (gAccessLevel = 'level-1' OR gAccessLevel = 'level-2' OR
gAccessLevel = 'level-3')";
} else {
// IF ERROR SHOW LEVEL ONE.
$sql .= "WHERE (gAccessLevel = 'level-1')";
}
$sql .= " ORDER BY gId DESC LIMIT $gStart, 10";
echo $sql;
$sql_result = mysql_query($sql, $connection) or die (mysql_error());
MY ERROR MESSAGE IS ...
10You have an error in your SQL syntax near 'WHERE (gAccessLevel = 'level-1'
OR gAccessLevel = 'level-2' OR gAccessLevel = 'l' at line 1
as gAccessLevel = level-3 ...
Any Ideas why this is weong?
------
Philip J. Newman.
Head Developer
[EMAIL PROTECTED]
+64 (9) 576 9491
+64 021-048-3999
------
Friends are like stars
You can't allways see them,
but they are always there.
------
Websites:
PhilipNZ.com - Design.
http://www.philipnz.com/
[EMAIL PROTECTED]
Philip's Domain // Internet Project.
http://www.philipsdomain.com/
[EMAIL PROTECTED]
Vital Kiwi / NEWMAN.NET.NZ.
http://www.newman.net.nz/
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
I'm trying to get a small PHP based log reader to run but get this error every time:
Fatal error: Call to undefined function: mysql_connect() in
/var/www/html/weblog/weblog.php on line 58
Here is the PHP I'm using ... does anyone know what is happening here?
<?php
/*
Simple syslog web viewer
by NDG Tech team - www.ndgtech.ro.
version: 0.5.1
Authors: Adrian Badea <adi [at] ndgtech.ro>
Radu Solea <radu [at] ndgtech.ro>
Contributor: Hannes Gruber <hannes [at] usw.at>
Tested with:
Apache 2.0.36
PHP 4.3.0
MySQL 3.23.51
Slackware Linux 8.1
kernel version 2.4.20
on an AthlonXP 1800+ 512 MB SDRAM
*/
error_reporting(E_ERROR+E_WARNING);
$configuration=parse_ini_file('weblog.ini');
function htmlerror()
{
echo "<html><head><title>Error page</title></head>";
echo "<body><br><br><br><br><font size=4><b>WebLog error<br></b><hr size=1 width=62%
align=left>";
echo "This program has performed an illegal operation. Software police has been
notified.</hr><br><br>";
echo "</font></body></html>";
exit;
}
if (($_POST["user"]!=NULL) && ($_POST["pass"]!=NULL))
{
setcookie("user",$_POST["user"],time()+3600);
setcookie("pass",$_POST["pass"],time()+3600);
$username=$_POST["user"];
$password=$_POST["pass"];
}
elseif (($_COOKIE["user"]!=NULL) && ($_COOKIE["pass"]!=NULL))
{
$username=$_COOKIE["user"];
$password=$_COOKIE["pass"];
}
else
{
htmlerror();
};
function getmicrotime(){ // code from the PHP manual
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
$time_start = getmicrotime();
mysql_connect("loghost:3306",$username,$password);
if (mysql_errno()!=0)
{
echo "Mysql error: ";
$error=mysql_error();
echo $error;
exit;
}
mysql_select_db("system"); // previously created database
$create_query="create temporary table filenames (name varchar(255) unique, sep
varchar(255))";
$p1=mysql_query($create_query);
$load_query="load data infile '".$configuration['config_file']."' into table filenames
fields terminated by '\t';";
$p2=mysql_query($load_query);
if ($_POST["lo"]==NULL)
{
$file_get="select * from filenames limit 1";
$result=mysql_query($file_get);
$row=mysql_fetch_array($result);
$filename=$row["name"];
$separator=$row["sep"];
}
else
if ($_POST["load"]==NULL)
{
$filename=$_POST["fn"];
$file_get="select sep from filenames where name='$filename'";
$result=mysql_query($file_get);
$row=mysql_fetch_array($result);
$separator=$row["sep"];
}
if ($_POST["load"]!=NULL)
{
$filename=$_POST["files"];
$file_get="select sep from filenames where name='$filename'";
$result=mysql_query($file_get);
$row=mysql_fetch_array($result);
$separator=$row["sep"];
$lo_val=0;
$hi_val=15;
$esearch=NULL;
$vsearch=NULL;
}
/**
$filepath=dirname($filename)."/";
$file=basename($filename);
exec("find $filepath -name '$file*' -type f -print0 | xargs -ifile -0 cat 'file' >>
/tmp/mesaje");
*/
exec("cp $filename /tmp/mesaje");
exec("chmod 444 /tmp/mesaje");
$hostname=exec('echo ${HOSTNAME%%.*}');
mysql_query("create temporary table syslog (date varchar(16), message varchar(255))");
$query="load data infile '/tmp/mesaje' into table syslog fields terminated by '
$separator '";
mysql_query($query);
if (($_POST["vsearch"]!=NULL) || ($_POST["search"]!=NULL))
{
$pula=$_POST["vsearch"];
$query="select COUNT(*) from syslog where message like '%$pula%'";
}
else
{
$query="select COUNT(*) from syslog";
}
$res=mysql_query($query);
$maximum=mysql_fetch_row($res);
$maximum=$maximum[0];
echo "<head><title>Syslogd web viewer</title></head>";
echo "<center>";
echo "<body text=\"#000000\" bgcolor=\"#F2EAEA\"><b><font size=12>";
echo "<table border=0 align=center cellpadding=5>";
echo "<tr bgcolor=\"#9db3cc\" align=center width=60% height=10><td><font
size=5><b>WebLog - Syslogd Web Viewer</b></font></td></tr>";
echo "</table>";
echo "</font><br></center></body></b>";
echo "<body bgcolor=\"C0C0C0\">";
if ($_POST["lo"]==NULL)
{
$lo_val=0;
$hi_val=15;
}
elseif ($_POST["hi"]==NULL)
{
$lo_val=0;
$hi_val=15;
}
else if ($_POST["next"]!=NULL)
{
$lo_val=$_POST["hi"];
$hi_val=2*$_POST["hi"]-$_POST["lo"];
}
else if($_POST["prev"]!=NULL)
{
$lo_val=2*$_POST["lo"]-$_POST["hi"];
$hi_val=$_POST["lo"];
}
else if($_POST["go"]!=NULL)
{
$lo_val=$_POST["lo"];
$hi_val=$_POST["hi"];
}
else if($_POST["rst"]!=NULL)
{
$lo_val=0;
$hi_val=15;
$esearch=NULL;
$vsearch=NULL;
}
else if($_POST["bsearch"]!=NULL)
{
$lo_val=0;
$hi_val=15;
}
else if($_POST["esearch"]!=NULL)
{
$lo_val=0;
$hi_val=15;
}
if (($_POST["bsearch"]!=NULL) && ($_POST["search"]!=NULL))
{
$esearch=1;
$vsearch=$_POST["search"];
}
elseif ($_POST["esearch"]!=NULL)
{
$esearch=$_POST["esearch"];
$vsearch=$_POST["vsearch"];
}
else
{
$esearch=NULL;
$vsearch=NULL;
}
if ($_POST["load"]!=NULL)
{
$esearch=NULL;
$vsearch=NULL;
}
if ($lo_val>$hi_val)
{
$temp=$hi_val;
$hi_val=$lo_val;
$lo_val=$temp;
}
if ($hi_val>$maximum)
{
if ($lo_val>=$maximum)
{
$lo_val=0;
$hi_val=15;
}
else
{
$hi_val=$maximum;
}
}
if ($lo_val<0)
{
if ($hi_val<=0)
{
$lo_val=$maximum-15;
$hi_val=$maximum;
}
else
{
$lo_val=0;
}
}
echo "<form action=\"weblog.php\" method=\"post\">";
echo " Browse database: ";
echo "<input type=\"submit\" value=\"Prev\" name=prev>";
echo " ";
echo "<input type=\"submit\" value=\"Next\" name=next>";
echo " ";
echo "<input type=\"submit\" value=\"Reset\" name=rst>";
echo " <b>OR</b> ";
echo "Show lines from <input type=\"text\" name=lo value=$lo_val
size=10> ";
echo "to <input type=\"text\" name=hi value=$hi_val
size=10> ";
echo "<input type=\"submit\" value=\"Show\" name=go ><br>";
$get_query="select name from filenames";
$p3=mysql_query($get_query);
echo " Load file: ";
echo "<select name=files>";
$nofiles=mysql_num_rows($p3);
echo $nofiles;
for ($ii=0; $ii<$nofiles; $ii++)
{
$r=mysql_fetch_array($p3);
echo "<option".(($r["name"]==$files)?' selected':'').">";
echo ($r["name"]);
echo "</option>";
}
echo "</select>";
echo " ";
echo "<input type=\"submit\" name=load value=\"Load\">";
echo "<input type=\"hidden\" name=fn value=$filename>";
echo " Search for a string ";
echo "<input type=\"text\" name=search size=26 value=$vsearch> ";
echo "<input type=\"submit\" name=bsearch value=\"Search!\">";
if (!($reverse || $fn)) $reverse=TRUE;
echo " reverse order: <input type='checkbox' name='reverse'".(($reverse)?'
checked':'').">";
$sortOrder=($reverse)?'ORDER BY date DESC':'';
if ($esearch!=NULL)
{
$query="select * from syslog where message like '%$vsearch%'
$sortOrder limit $lo_val, $hi_val";
}
else
{
$query="select * from syslog $sortOrder limit $lo_val,$hi_val";
}
echo "<br>";
echo "<input type=\"hidden\" name=esearch value=$esearch>";
echo "<input type=\"hidden\" name=vsearch value=$vsearch>";
echo "</form>";
$result=mysql_query($query);
$n=$hi_val-$lo_val;
if ($n==0)
{htmlerror();exit;};
echo " Stats generated for <b>";
echo $hostname;
echo "</b> on <b>";
echo date("F d, Y");
$time_end = getmicrotime();
$time = $time_end - $time_start;
echo "</b>, in <b>$time</b> seconds. (total rows available: $maximum)";
mysql_data_seek($result,0);
echo "<body bgcolor=\"F2EAEA\">";
echo "<table border=0 align=left cellspacing=1 cellpadding=5>";
for ($i=0; $i<$n; $i++)
{
$row=mysql_fetch_array($result);
if (($i%2)==0)
{
echo "<tr align=\"left\"><td align=center bgcolor=\"C0C0C0\"
width=13%>";
}
else
{
echo "<tr align=\"left\"><td align=center bgcolor=\"9db3cc\"
width=13%>";
};
echo ($row["date"]);
echo "</td>";
if (($i%2)==0)
{
echo "<td align=\"left\"><td align=left bgcolor=\"C0C0C0\"
width=88%>";
}
else
{
echo "<td align=\"left\"><td align=left bgcolor=\"9db3cc\"
width=88%>";
};
echo ($row["message"]);
echo "</td></tr>";
}
echo "<tr border=0 cellspacing=0 align=\"left\">";
echo "<td bgcolor=\"F2EAEA\" colspan=3>";
echo "</form>";
echo "<form action=\"index.php\" method=\"POST\"><font size=3>";
echo " <input type=\"submit\" value=\"Logout\" name=exit>";echo "</table>";
echo "</form>";
$clear=unlink("/tmp/mesaje");
?>
Thanks
~Steve
--- End Message ---
--- Begin Message ---
try
mysql_connect("loghost:3306","$username","$password");
----- Original Message -----
From: "Steve Shead" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, March 15, 2003 12:14 PM
Subject: [PHP] mysql_connect issue
> I'm trying to get a small PHP based log reader to run but get this error
every time:
>
> Fatal error: Call to undefined function: mysql_connect() in
/var/www/html/weblog/weblog.php on line 58
>
> Here is the PHP I'm using ... does anyone know what is happening here?
>
> <?php
> /*
> Simple syslog web viewer
> by NDG Tech team - www.ndgtech.ro.
>
> version: 0.5.1
>
> Authors: Adrian Badea <adi [at] ndgtech.ro>
> Radu Solea <radu [at] ndgtech.ro>
> Contributor: Hannes Gruber <hannes [at] usw.at>
>
> Tested with:
> Apache 2.0.36
> PHP 4.3.0
> MySQL 3.23.51
> Slackware Linux 8.1
> kernel version 2.4.20
> on an AthlonXP 1800+ 512 MB SDRAM
> */
>
> error_reporting(E_ERROR+E_WARNING);
> $configuration=parse_ini_file('weblog.ini');
>
> function htmlerror()
> {
> echo "<html><head><title>Error page</title></head>";
> echo "<body><br><br><br><br><font size=4><b>WebLog error<br></b><hr size=1
width=62% align=left>";
> echo "This program has performed an illegal operation. Software police has
been notified.</hr><br><br>";
> echo "</font></body></html>";
> exit;
> }
>
>
> if (($_POST["user"]!=NULL) && ($_POST["pass"]!=NULL))
> {
> setcookie("user",$_POST["user"],time()+3600);
> setcookie("pass",$_POST["pass"],time()+3600);
> $username=$_POST["user"];
> $password=$_POST["pass"];
> }
> elseif (($_COOKIE["user"]!=NULL) && ($_COOKIE["pass"]!=NULL))
> {
> $username=$_COOKIE["user"];
> $password=$_COOKIE["pass"];
> }
> else
> {
> htmlerror();
> };
>
>
> function getmicrotime(){ // code from the PHP manual
> list($usec, $sec) = explode(" ",microtime());
> return ((float)$usec + (float)$sec);
> }
> $time_start = getmicrotime();
>
> mysql_connect("loghost:3306",$username,$password);
>
> if (mysql_errno()!=0)
> {
> echo "Mysql error: ";
> $error=mysql_error();
> echo $error;
> exit;
> }
>
> mysql_select_db("system"); // previously created database
>
> $create_query="create temporary table filenames (name varchar(255) unique,
sep varchar(255))";
> $p1=mysql_query($create_query);
>
> $load_query="load data infile '".$configuration['config_file']."' into
table filenames fields terminated by '\t';";
> $p2=mysql_query($load_query);
>
> if ($_POST["lo"]==NULL)
> {
> $file_get="select * from filenames limit 1";
> $result=mysql_query($file_get);
> $row=mysql_fetch_array($result);
> $filename=$row["name"];
> $separator=$row["sep"];
> }
> else
> if ($_POST["load"]==NULL)
> {
> $filename=$_POST["fn"];
> $file_get="select sep from filenames where name='$filename'";
> $result=mysql_query($file_get);
> $row=mysql_fetch_array($result);
> $separator=$row["sep"];
> }
> if ($_POST["load"]!=NULL)
> {
> $filename=$_POST["files"];
> $file_get="select sep from filenames where name='$filename'";
> $result=mysql_query($file_get);
> $row=mysql_fetch_array($result);
> $separator=$row["sep"];
> $lo_val=0;
> $hi_val=15;
> $esearch=NULL;
> $vsearch=NULL;
> }
>
>
> /**
> $filepath=dirname($filename)."/";
> $file=basename($filename);
> exec("find $filepath -name '$file*' -type f -print0 | xargs -ifile -0 cat
'file' >> /tmp/mesaje");
> */
> exec("cp $filename /tmp/mesaje");
> exec("chmod 444 /tmp/mesaje");
>
> $hostname=exec('echo ${HOSTNAME%%.*}');
>
> mysql_query("create temporary table syslog (date varchar(16), message
varchar(255))");
> $query="load data infile '/tmp/mesaje' into table syslog fields terminated
by ' $separator '";
>
> mysql_query($query);
>
> if (($_POST["vsearch"]!=NULL) || ($_POST["search"]!=NULL))
> {
> $pula=$_POST["vsearch"];
> $query="select COUNT(*) from syslog where message like '%$pula%'";
> }
> else
> {
> $query="select COUNT(*) from syslog";
> }
>
> $res=mysql_query($query);
> $maximum=mysql_fetch_row($res);
> $maximum=$maximum[0];
>
> echo "<head><title>Syslogd web viewer</title></head>";
>
> echo "<center>";
> echo "<body text=\"#000000\" bgcolor=\"#F2EAEA\"><b><font size=12>";
>
> echo "<table border=0 align=center cellpadding=5>";
> echo "<tr bgcolor=\"#9db3cc\" align=center width=60% height=10><td><font
size=5><b>WebLog - Syslogd Web Viewer</b></font></td></tr>";
> echo "</table>";
> echo "</font><br></center></body></b>";
> echo "<body bgcolor=\"C0C0C0\">";
>
> if ($_POST["lo"]==NULL)
> {
> $lo_val=0;
> $hi_val=15;
> }
> elseif ($_POST["hi"]==NULL)
> {
> $lo_val=0;
> $hi_val=15;
> }
> else if ($_POST["next"]!=NULL)
> {
> $lo_val=$_POST["hi"];
> $hi_val=2*$_POST["hi"]-$_POST["lo"];
> }
> else if($_POST["prev"]!=NULL)
> {
> $lo_val=2*$_POST["lo"]-$_POST["hi"];
> $hi_val=$_POST["lo"];
> }
> else if($_POST["go"]!=NULL)
> {
> $lo_val=$_POST["lo"];
> $hi_val=$_POST["hi"];
> }
> else if($_POST["rst"]!=NULL)
> {
> $lo_val=0;
> $hi_val=15;
> $esearch=NULL;
> $vsearch=NULL;
> }
> else if($_POST["bsearch"]!=NULL)
> {
> $lo_val=0;
> $hi_val=15;
> }
> else if($_POST["esearch"]!=NULL)
> {
> $lo_val=0;
> $hi_val=15;
> }
>
> if (($_POST["bsearch"]!=NULL) && ($_POST["search"]!=NULL))
> {
> $esearch=1;
> $vsearch=$_POST["search"];
> }
> elseif ($_POST["esearch"]!=NULL)
> {
> $esearch=$_POST["esearch"];
> $vsearch=$_POST["vsearch"];
> }
> else
> {
> $esearch=NULL;
> $vsearch=NULL;
> }
>
> if ($_POST["load"]!=NULL)
> {
> $esearch=NULL;
> $vsearch=NULL;
> }
>
> if ($lo_val>$hi_val)
> {
> $temp=$hi_val;
> $hi_val=$lo_val;
> $lo_val=$temp;
> }
>
> if ($hi_val>$maximum)
> {
> if ($lo_val>=$maximum)
> {
> $lo_val=0;
> $hi_val=15;
> }
> else
> {
> $hi_val=$maximum;
> }
> }
>
> if ($lo_val<0)
> {
> if ($hi_val<=0)
> {
> $lo_val=$maximum-15;
> $hi_val=$maximum;
> }
> else
> {
> $lo_val=0;
> }
> }
>
>
>
> echo "<form action=\"weblog.php\" method=\"post\">";
>
> echo " Browse database: ";
> echo "<input type=\"submit\" value=\"Prev\" name=prev>";
> echo " ";
> echo "<input type=\"submit\" value=\"Next\" name=next>";
> echo " ";
> echo "<input type=\"submit\" value=\"Reset\" name=rst>";
> echo " <b>OR</b> ";
> echo "Show lines from <input type=\"text\" name=lo value=$lo_val
size=10> ";
> echo "to <input type=\"text\" name=hi value=$hi_val
size=10> ";
> echo "<input type=\"submit\" value=\"Show\" name=go ><br>";
>
> $get_query="select name from filenames";
> $p3=mysql_query($get_query);
>
> echo " Load file: ";
> echo "<select name=files>";
> $nofiles=mysql_num_rows($p3);
> echo $nofiles;
> for ($ii=0; $ii<$nofiles; $ii++)
> {
> $r=mysql_fetch_array($p3);
> echo "<option".(($r["name"]==$files)?' selected':'').">";
> echo ($r["name"]);
> echo "</option>";
> }
> echo "</select>";
> echo " ";
> echo "<input type=\"submit\" name=load value=\"Load\">";
> echo "<input type=\"hidden\" name=fn value=$filename>";
>
> echo " Search for a string ";
> echo "<input type=\"text\" name=search size=26
value=$vsearch> ";
> echo "<input type=\"submit\" name=bsearch value=\"Search!\">";
>
> if (!($reverse || $fn)) $reverse=TRUE;
> echo " reverse order: <input type='checkbox'
name='reverse'".(($reverse)?' checked':'').">";
> $sortOrder=($reverse)?'ORDER BY date DESC':'';
>
> if ($esearch!=NULL)
> {
> $query="select * from syslog where message like '%$vsearch%' $sortOrder
limit $lo_val, $hi_val";
> }
> else
> {
> $query="select * from syslog $sortOrder limit $lo_val,$hi_val";
> }
> echo "<br>";
> echo "<input type=\"hidden\" name=esearch value=$esearch>";
> echo "<input type=\"hidden\" name=vsearch value=$vsearch>";
> echo "</form>";
>
> $result=mysql_query($query);
>
> $n=$hi_val-$lo_val;
>
> if ($n==0)
> {htmlerror();exit;};
> echo " Stats generated for <b>";
> echo $hostname;
> echo "</b> on <b>";
> echo date("F d, Y");
> $time_end = getmicrotime();
> $time = $time_end - $time_start;
>
> echo "</b>, in <b>$time</b> seconds. (total rows available:
$maximum)";
>
> mysql_data_seek($result,0);
> echo "<body bgcolor=\"F2EAEA\">";
> echo "<table border=0 align=left cellspacing=1 cellpadding=5>";
>
> for ($i=0; $i<$n; $i++)
> {
> $row=mysql_fetch_array($result);
> if (($i%2)==0)
> {
> echo "<tr align=\"left\"><td align=center bgcolor=\"C0C0C0\"
width=13%>";
> }
> else
> {
> echo "<tr align=\"left\"><td align=center bgcolor=\"9db3cc\"
width=13%>";
> };
> echo ($row["date"]);
> echo "</td>";
> if (($i%2)==0)
> {
> echo "<td align=\"left\"><td align=left bgcolor=\"C0C0C0\"
width=88%>";
> }
> else
> {
> echo "<td align=\"left\"><td align=left bgcolor=\"9db3cc\"
width=88%>";
> };
> echo ($row["message"]);
> echo "</td></tr>";
> }
> echo "<tr border=0 cellspacing=0 align=\"left\">";
> echo "<td bgcolor=\"F2EAEA\" colspan=3>";
>
>
> echo "</form>";
>
> echo "<form action=\"index.php\" method=\"POST\"><font size=3>";
> echo " <input type=\"submit\" value=\"Logout\" name=exit>";echo
"</table>";
> echo "</form>";
>
>
> $clear=unlink("/tmp/mesaje");
>
> ?>
>
>
> Thanks
>
> ~Steve
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
For the record, am I declaring these in the correct order?
Thanks,
John
<?php
header("Content-type: text/notabene");
header("Content-Disposition: attachment; filename=".$dbtable.".nb");
ob_start("ob_gzhandler");
set_time_limit(150);
--- End Message ---
--- Begin Message ---
Hi,
Saturday, March 15, 2003, 4:53:44 AM, you wrote:
RP> Yes I did.
RP> Here is the code, maybe I am just missing something (this is the part
RP> where it writes and then opens again...
RP> $h6 = fopen("/etc/group.backup","a");
RP> for($i = 0; $i < count($users); $i++)
RP> {
RP> for($k = 0; $k < count($grouplines);$k++)
RP> {
RP> $groupline = explode(":", $grouplines[$k]);
RP> if($groupline[0] == $users[$i])
RP> continue 2;
RP> }
RP> $line = $users[$i] . ":x:" . ($user_ids[$i]+1000) .
RP> ":\n";
RP> fwrite($h6, $line);
RP> }
RP> fclose($h6);
RP> //have to re read the group file since we just modified it
RP> $h7 = fopen("/etc/group.backup","r");
RP> $groupcontent = fread($h7,filesize("/etc/group.backup"));
RP> fclose($h7);
RP> If I output the filesize("/etc/group.backup") after h6 is closed it is 0
RP> even though it is not.
RP> Ron
RP> On Fri, 2003-03-14 at 12:15, Chris Hayes wrote:
>> At 18:53 14-3-2003, you wrote:
>> >I open a file, modify it, save it out to disk. The VERY next line, i
>> >open it, and the size is zero. I look at the file and it is fine (not
>> >zero).
>> >
>> >I think there is a timing issue with php on file read/writes. I tried
>> >sleep(1), but all that did was slow the script down (didn't help).
>> >
>> un-educated guess:
>> did you try fclose then fopen again?
>>
>>
You could try clearstatcache() after the fclose.
Although the fopen,close is not listed in the affected files you never know...
--
regards,
Tom
--- End Message ---
--- Begin Message ---
This may seem weird:
How do I str_replace an include function?
I want to replace this line: include("$header");
with nothing ..
something like this:
$footer = str_replace(" '. include("$header"); .' ", "", $footer);
I get errors, any ideas?
cheers,
- Sebastian
--- End Message ---
--- Begin Message ---
$footer = str_replace('include("$header");', '', $footer);
The way you have it now, you're telling PHP to first include the file
named by the variable $header, then do an str_replace on the result; but
the parser is going to fail on that first semi-colon, and that's not
what you want to do anyway (as I understand it). Put the line you want
to replace inside single quotes (as above) and PHP won't attempt to
parse it, it'll just treat it as a string literal. Hope this helps, hope
it makes sense.
- john
Sebastian wrote:
This may seem weird:
How do I str_replace an include function?
I want to replace this line: include("$header");
with nothing ..
something like this:
$footer = str_replace(" '. include("$header"); .' ", "", $footer);
I get errors, any ideas?
cheers,
- Sebastian
--- End Message ---
--- Begin Message ---
doesn't work but also doesn't give any errors, I will try to explain what I
am trying to do:
I am trying to remove the header and footer to create a "printer friendly
page" with just the content, here's what my pages look like, I need to
remove header and footer when they visit: file.php?action=print
<?php
include("../config.php");
if($_GET[action] == "print")
{
$header = str_replace('include("$header");', '', $header);
$footer = str_replace('include("$footer");', '', $footer);
}
include("$header");
?>
// html
<?php include("$footer"); ?>
cheers,
- Sebastian
----- Original Message -----
From: "John Gray" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, March 15, 2003 12:31 AM
Subject: [PHP] Re: str_replace
| $footer = str_replace('include("$header");', '', $footer);
|
| The way you have it now, you're telling PHP to first include the file
| named by the variable $header, then do an str_replace on the result; but
| the parser is going to fail on that first semi-colon, and that's not
| what you want to do anyway (as I understand it). Put the line you want
| to replace inside single quotes (as above) and PHP won't attempt to
| parse it, it'll just treat it as a string literal. Hope this helps, hope
| it makes sense.
|
| - john
|
| Sebastian wrote:
| > This may seem weird:
| >
| > How do I str_replace an include function?
| >
| > I want to replace this line: include("$header");
| >
| > with nothing ..
| >
| > something like this:
| >
| > $footer = str_replace(" '. include("$header"); .' ", "", $footer);
| >
| > I get errors, any ideas?
| >
| > cheers,
| > - Sebastian
--- End Message ---
--- Begin Message ---
if the header and footer info come from your config.php file, then you have
to get to that file before it's parsed by the server. Perhaps, splitting
config.php into three files (header.php, config.php and footer.php), then
when you want to print just call the middle file.
if(isset($_GET['print'])) include("config.php"); // printer version
if(!isset($_GET['print'])) // regular page view
{
include("header.php");
include("config.php");
include("footer.php");
}
Hope this helps.
Hugh
----- Original Message -----
From: "Sebastian" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, March 14, 2003 10:23 PM
Subject: Re: [PHP] Re: str_replace
> doesn't work but also doesn't give any errors, I will try to explain what
I
> am trying to do:
>
> I am trying to remove the header and footer to create a "printer friendly
> page" with just the content, here's what my pages look like, I need to
> remove header and footer when they visit: file.php?action=print
>
> <?php
> include("../config.php");
>
> if($_GET[action] == "print")
> {
> $header = str_replace('include("$header");', '', $header);
> $footer = str_replace('include("$footer");', '', $footer);
> }
>
> include("$header");
> ?>
>
> // html
>
> <?php include("$footer"); ?>
>
> cheers,
> - Sebastian
>
> ----- Original Message -----
> From: "John Gray" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Saturday, March 15, 2003 12:31 AM
> Subject: [PHP] Re: str_replace
>
>
> | $footer = str_replace('include("$header");', '', $footer);
> |
> | The way you have it now, you're telling PHP to first include the file
> | named by the variable $header, then do an str_replace on the result; but
> | the parser is going to fail on that first semi-colon, and that's not
> | what you want to do anyway (as I understand it). Put the line you want
> | to replace inside single quotes (as above) and PHP won't attempt to
> | parse it, it'll just treat it as a string literal. Hope this helps, hope
> | it makes sense.
> |
> | - john
> |
> | Sebastian wrote:
> | > This may seem weird:
> | >
> | > How do I str_replace an include function?
> | >
> | > I want to replace this line: include("$header");
> | >
> | > with nothing ..
> | >
> | > something like this:
> | >
> | > $footer = str_replace(" '. include("$header"); .' ", "", $footer);
> | >
> | > I get errors, any ideas?
> | >
> | > cheers,
> | > - Sebastian
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
----- Original Message -----
From: "Hugh Danaher" <[EMAIL PROTECTED]>
To: "Sebastian" <[EMAIL PROTECTED]>
Sent: Friday, March 14, 2003 11:37 PM
Subject: Re: [PHP] str_replace
> I just though up a better idea,
> put your conditional statements in your included files not in the calling
> file. That way, the parsing of the page will pick up the conditions and
> execute them properly.
> Really hope this helps.
> Hugh
> ----- Original Message -----
> From: "Sebastian" <[EMAIL PROTECTED]>
> To: "php list" <[EMAIL PROTECTED]>
> Sent: Friday, March 14, 2003 9:15 PM
> Subject: [PHP] str_replace
>
>
> > This may seem weird:
> >
> > How do I str_replace an include function?
> >
> > I want to replace this line: include("$header");
> >
> > with nothing ..
> >
> > something like this:
> >
> > $footer = str_replace(" '. include("$header"); .' ", "", $footer);
> >
> > I get errors, any ideas?
> >
> > cheers,
> > - Sebastian
> >
>
--- End Message ---
--- Begin Message ---
At 07:23 15.03.2003, Sebastian said:
--------------------[snip]--------------------
>doesn't work but also doesn't give any errors, I will try to explain what I
>am trying to do:
>
>I am trying to remove the header and footer to create a "printer friendly
>page" with just the content, here's what my pages look like, I need to
>remove header and footer when they visit: file.php?action=print
>
><?php
>include("../config.php");
>
>if($_GET[action] == "print")
>{
> $header = str_replace('include("$header");', '', $header);
> $footer = str_replace('include("$footer");', '', $footer);
>}
>
>include("$header");
>?>
>
>// html
>
><?php include("$footer"); ?>
--------------------[snip]--------------------
Hmm - can't work because the variable "$header" doesn't include the string
"include("$header");".
Try it this way:
<?php
include("../config.php");
if($_GET[action] == "print") {
$header = null;
$footer = null;
}
if ($header) include($header);
?>
// html
<?php if ($footer) include($footer); ?>
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/
--- End Message ---
--- Begin Message ---
After upgrading to RedHat 8.0 and effectively breaking some python
caller-id script that I have no clue how to fix.. I'm curious of whether
or not PHP would be able to get caller-id data from a modem.. I imagine
it could, and probably won't be too difficult to overcome... but I am
posing that question just to get any feedback of any problems..
What the real question is about... is there any solid way of keeping a
PHP script running (to latch onto the modem and constantly monitor it,
of course...) and have it run without it crying about too much memory
being used or being run too long.
Any ideas, insight, etc?
--Jason
--- End Message ---
--- Begin Message ---
PHP does not allow ';' character in query strings so you'll have to break
these.
regds,
-----Original Message-----
From: Charles Kline [mailto:[EMAIL PROTECTED]
Sent: Friday, March 14, 2003 20:34
To: [EMAIL PROTECTED]
Subject: Newbie MySQL INSERT Q
Can I have a single SQL string do INSERTS into multiple tables?
Like:
sql="INSERT INTO tbl_1 (id,
email_address_1)
VALUES ($v_personid,
'$v_email');
INSERT INTO tbl_2 (person_id,
interest_id)
VALUES ($v_personid,
$v_int1);";
Or do I need to break them up and use two of these?
$result = $db->query($sql)
Thanks
Charles
--- End Message ---
--- Begin Message ---
As explained already, not a good idea :)
Also, if someone makes a copy of your form and excludes one of the fields,
then it won't be set in POST at all.
Keep an array of the fields you have in the form. I choose to set the field
as the key, and then for the value either 1 (required) or 0 (not required):
<?
// formPostArray.php
$formPostElements = array(
'first' => 1,
'last' => 0,
'email' => 1',
'age' => 0,
'sex' => 0
);
?>
Then include it where needed:
<?
include('formPostArray.php');
?>
Then use the array to check POST values are set, or better still, not empty:
<?
$error = 0;
foreach($formPostElements as $key => $val)
{
if($val)
{
if(empty($_POST[$key]) // could also be if(!isset($_POST[$key]))
{
$error = 3;
}
}
}
if($error)
{
header("Location: signup.php?error={$error}");
exit();
}
?>
In your case, street2 could be set to 0, and the rest set to 1.
You may also find that you can use the same array to write all your form
code as well, with a little work!!
Justin
on 15/03/03 6:26 AM, drparker ([EMAIL PROTECTED]) wrote:
> I'm running this script to make sure all fields are filled in on a form:
>
> foreach($_POST as $p)
> {
> if(!$p)
> {
> header("Location: signup.php?error=3");
> exit();
> }
> }
>
> But I need to exclude one field on the form from being checked -
> Street2. How could I do this?
>
>
--- End Message ---
--- Begin Message ---
on 14/03/03 2:09 AM, -{ Rene Brehmer }- ([EMAIL PROTECTED]) wrote:
> Jumping in...
Jumping in also:
http://www.killersoft.com/downloads/pafiledb.php?action=file&id=4
This is a PHP port of a well respected Perl script which CHECKS THE FORMAT
OF THE EMAIL ADDRESS AGAINST THE RCF SPEC.
I use it EVERYWHERE :)
Justin
--- End Message ---
--- Begin Message ---
Commonly, you don't need to encrypt it.
just md5() the password before inserting it, so you only store the md5'd
password.
then, to check on login, md5() the password they enter into a form... if
they match, then they are the same.
heaps less code, no need to mycrypt libraries to be installed, etc etc.
the only catch is that if the user forgets the password, you need to reset
it, because md5 is one-way, and isn't technically encryption :)
justin
on 14/03/03 1:31 PM, Philip J. Newman ([EMAIL PROTECTED]) wrote:
> I have a user admin for a site, how ever passwords are stored in plane text.
> Is there away to crypt and then read the crypt when verifying that string vs
> the plane text in the password box?
>
> ------
> Philip J. Newman.
> Head Developer
> [EMAIL PROTECTED]
>
>
--- End Message ---
--- Begin Message ---
You can split $_SERVER['REQUEST_URI'] on the /'s to get the directories, eg:
http://site.com/info/your_pet/dogs/page.html would result in
/dir/anotherdir/page.php
So, (untested code):
<?
$title = 'Name of My Site';
$urlBits = explode('/',$_SERVER['REQUEST_URI']);
$i = 0;
foreach($urlBits as $bit)
{
$i++;
if($i < count($urlBits) && !empty($bit))
{
$bit = str_replace('_', ' ', $bit);
$bit = ucwords($bit);
$title .= " / {$bit} ";
}
}
echo $title;
?>
Should echo something like:
'Name of My Site / Info / Your Pets / Dogs'
All you need to to do is echo $title in the title tag, and season to taste
:)
Justin
on 14/03/03 4:44 AM, Sebastian ([EMAIL PROTECTED]) wrote:
> Hello.
>
> I have many pages, and was thinking of a way to generate dynamic page
> titles, very similar to a breadcrumb where it uses the directory structure
> to make the page title.
>
> Anyone have something like this, and is willing to give a hand?
>
> warm regards,
> Sebastian - [BBR] Gaming Clan
> http://www.broadbandreports.com
>
--- End Message ---