php-general Digest 12 Nov 2004 17:44:42 -0000 Issue 3108
Topics (messages 201814 through 201851):
keeping format of text in textbox
201814 by: Amanda Hemmerich
201815 by: Justin.Baiocchi.csiro.au
201817 by: Justin French
201820 by: David Robley
Re: adding a space every 4 chars
201816 by: Jason Wong
201818 by: Justin French
201819 by: Greg Beaver
Question for the PHP consultants out there.
201821 by: Brent Clements
201822 by: Jason Wong
parsing /'s in urls
201823 by: leehro.bellsouth.net
201833 by: Dennis Seavers
201838 by: Sebastian Mendel
Simple XML
201824 by: Octavian Rasnita
201829 by: John Holmes
Re: Session file not written, session variables messed up.
201825 by: Klaus Reimer
201848 by: Rodolfo Gonzalez
Current URL?
201826 by: Jason Paschal
201828 by: John Holmes
201843 by: Matthew Weier O'Phinney
201850 by: pete M
Creating a directory
201827 by: Danny Brow
201830 by: Pluance
201831 by: Jason Wong
201832 by: Danny Brow
201835 by: Danny Brow
Syslog Parser
201834 by: Nunners
201847 by: Greg Donald
Re: calling function from function?
201836 by: Sebastian Mendel
Re: Which PHP for MySQL 4.1
201837 by: Sebastian Mendel
Re: Database Search
201839 by: Stuart Felenstein
201842 by: Graham Cossey
201844 by: Stuart Felenstein
201845 by: Graham Cossey
PHP / LDAP with Windows logon
201840 by: Christopher.Wood.gxs.com
Unsetting vars when not needed?
201841 by: Jordi Canals
201846 by: Brent Baisley
201849 by: pete M
session.use_trans_sid
201851 by: Jon Hill
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 did a search for this in the archive but didn't find anything.
Is there a way to preserve the format of text in a textbox that is being
saved in a database and then pulled out and displayed? The people
entering the data want to keep their tabs and newlines, but right now,
that's not happening.
Thanks,
Amanda
--- End Message ---
--- Begin Message ---
I use this when submitting the data from the form (for jokes):
if ($submit)
{
$joke = nl2br($joke);
$dbcnx = @mysql_connect( "localhost", "root", "password");
mysql_select_db("movements");
$sql = "INSERT INTO jokes SET author='$author', joke='$joke', id='$id'";
mysql_query($sql);
echo "<b>Thank you, your joke has been recorded!</b>";
}
Then this when displaying the text:
if (!$link = mysql_connect("localhost","root","password"))
exit("Unable to make a connection to the database");
if (!mysql_select_db("movements", $link))
exit("Unable to select the database");
$table = 'jokes';
$check = "select * from $table ORDER BY rand() LIMIT 100";
$qry = mysql_query($check) or die ("Could not match data because
".mysql_error());
$myrow = mysql_fetch_array($qry);
$joke = str_replace("<br />","\n",$joke);
?>
<table border="1" bgcolor="#0D9BA4">
<tr>
<td width="70%"><b><?echo($myrow['joke']);
?>
</b>
</td>
<td valign="top"><b>Kindly provided by
<?echo($myrow['author']);?> </b>
</td>
</tr>
<table>
Excuse the crap code, I'm pretty new to php :)
-----Original Message-----
From: Amanda Hemmerich [mailto:[EMAIL PROTECTED]
Sent: Friday, 12 November 2004 4:05 PM
To: [EMAIL PROTECTED]
Subject: [PHP] keeping format of text in textbox
I did a search for this in the archive but didn't find anything.
Is there a way to preserve the format of text in a textbox that is being
saved in a database and then pulled out and displayed? The people
entering the data want to keep their tabs and newlines, but right now,
that's not happening.
Thanks,
Amanda
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
On 12/11/2004, at 4:05 PM, Amanda Hemmerich wrote:
I did a search for this in the archive but didn't find anything.
Is there a way to preserve the format of text in a textbox that is
being
saved in a database and then pulled out and displayed? The people
entering the data want to keep their tabs and newlines, but right now,
that's not happening.
Are you displaying the content back into a textarea, or into normal
HTML?
<textarea>'s following basically the same rules as <pre>'s -- newlines
and tabs will be respected, as long as your stylesheets don't override
that.
My first suggestion is view the HTML source in a browser first, and see
if the new lines are there in the source... If they aren't there, then
they won't be there any other way.
If not, the white space (new lines, tabs, etc) must have been stripped
out somewhere in your code on the way in or out of the database.
Inserting them into the database should not remove white space by
default, so if yours aren't there in the DB, then your code somewhere
must be stripping it out.
However, if you just want to display the content and plain text on the
HTML page, then you need to realise the following -- newlines, tabs and
multiple spaces are ignored in most cases by HTML.
To preserve all the white space, you can put the text in a <pre> block,
which respects white space formatting. You can also achieve the same
thing with CSS elements. This is pretty much the only option for tabs,
but I'd argue they aren't needed at all.
To preserve just newlines, you may consider something like nl2br(),
which adds a <br /> tag to all newlines.
But this is all pretty much a HTML discussion, not PHP :)
Justin
--- End Message ---
--- Begin Message ---
On Fri, 12 Nov 2004 15:41, Justin Baiocchi wrote:
> I use this when submitting the data from the form (for jokes):
>
> if ($submit)
> {
> $joke = nl2br($joke);
> $dbcnx = @mysql_connect( "localhost", "root", "password");
> mysql_select_db("movements");
> $sql = "INSERT INTO jokes SET author='$author', joke='$joke', id='$id'";
> mysql_query($sql);
> echo "<b>Thank you, your joke has been recorded!</b>";
> }
Here you are adding < /BR> to the data before storing it in the database.
Note that if you want to provide the stored data for editing, the embedded
HTML may confuse people who are modifying the data. Better technique is to
store the text as given (after validating it for whatever things you don't
want to allow) and simply use nl2br() when you display the data.
> Then this when displaying the text:
>
>
> if (!$link = mysql_connect("localhost","root","password"))
> exit("Unable to make a connection to the database");
> if (!mysql_select_db("movements", $link))
> exit("Unable to select the database");
> $table = 'jokes';
> $check = "select * from $table ORDER BY rand() LIMIT 100";
> $qry = mysql_query($check) or die ("Could not match data because
> ".mysql_error());
> $myrow = mysql_fetch_array($qry);
This next line doesn't seem to do anything. I'm guessing that you are trying
to replace the < /BR> that you added above with a newline; this is
redundant and if it actually worked, would add an extra newline at each
occurrence of < /BR>. Note that nl2br doesn't replace a newline, it adds
the BR before each newline.
> $joke = str_replace("<br />","\n",$joke);
> ?>
> <table border="1" bgcolor="#0D9BA4">
> <tr>
> <td width="70%"><b><?echo($myrow['joke']);
> ?>
> </b>
> </td>
> <td valign="top"><b>Kindly provided by
> <?echo($myrow['author']);?> </b>
> </td>
> </tr>
> <table>
>
> Excuse the crap code, I'm pretty new to php :)
Cheers
--
David Robley
Misspelled? Impossible. My modem is error correcting!
--- End Message ---
--- Begin Message ---
On Friday 12 November 2004 04:49, Justin French wrote:
> What's the quickest way to add a space every four characters?
>
> Eg 123456789 becomes 1234 5678 9
No idea whether it's the quickest (in terms of cpu time):
$doo = '123456789';
$dah = preg_replace('/(\d{4})/', '\\1 ', $doo);
echo $dah;
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Stupid, n.:
Losing $25 on the game and $25 on the instant replay.
*/
--- End Message ---
--- Begin Message ---
On 13/11/2004, at 12:20 AM, Jason Wong wrote:
No idea whether it's the quickest (in terms of cpu time):
$doo = '123456789';
$dah = preg_replace('/(\d{4})/', '\\1 ', $doo);
echo $dah;
Quickest for me is more about lines of code and simplicity, so, thanks!!
Justin
--- End Message ---
--- Begin Message ---
Justin French wrote:
Hi,
What's the quickest way to add a space every four characters?
Eg 123456789 becomes 1234 5678 9
<?php
$a = '123456789';
echo implode(' ', str_split($a, 4));
?>
Greg
--- End Message ---
--- Begin Message ---
What web based software project management tool do you use to keep track of
projects, project tasks, customer requests, and bug reports? I need something
that would allow a customer to keep track of his/her project basically and to
use the application to submit bug requests, feature requests, and other
similiar items.
I'm looking at replacing a home-grown solution I wrote in PHP a while back.
I've done the google thing, but everything I've tried doesn't really sit well
with me. So...now I'm turning to my peers for suggestions.
What do you guy's use and/or suggest?
Thanks,
Brent
--- End Message ---
--- Begin Message ---
On Friday 12 November 2004 06:36, Brent Clements wrote:
> I'm looking at replacing a home-grown solution I wrote in PHP a while back.
> I've done the google thing, but everything I've tried doesn't really sit
> well with me. So...now I'm turning to my peers for suggestions.
List what you tried. Summarise what you liked and disliked about them and why
you're not going to use them.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Commoner's three laws of ecology:
(1) No action is without side-effects.
(2) Nothing ever goes away.
(3) There is no free lunch.
*/
--- End Message ---
--- Begin Message ---
My host recently upgraded PHP. I had a script, download.php, that would
work like this
http://www.myhost.com/download.php/30/file.torrent
the download.php script would take the 30, look up the real filename in the
database, and readfile() it back. this was a great setup because the
browser just thought it was accessing a direct link to a file.
But now download.php/30/file.torrent results in a 404.
Is this something I can change back?
Dan
--- End Message ---
--- Begin Message ---
The link offers a CGI error, which is admittedly an uninteresting result.
I think you'll need to indicate what your previous results were and, if
different, what your desired results are.
Dennis
> [Original Message]
> From: <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Date: 11/11/2004 11:58:10 PM
> Subject: [PHP] parsing /'s in urls
>
> My host recently upgraded PHP. I had a script, download.php, that would
> work like this
>
> http://www.myhost.com/download.php/30/file.torrent
>
> the download.php script would take the 30, look up the real filename in
the
> database, and readfile() it back. this was a great setup because the
> browser just thought it was accessing a direct link to a file.
>
> But now download.php/30/file.torrent results in a 404.
>
> Is this something I can change back?
>
> Dan
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:
My host recently upgraded PHP. I had a script, download.php, that would
work like this
http://www.myhost.com/download.php/30/file.torrent
the download.php script would take the 30, look up the real filename in the
database, and readfile() it back. this was a great setup because the
browser just thought it was accessing a direct link to a file.
But now download.php/30/file.torrent results in a 404.
Is this something I can change back?
this is an apache related thing
http://httpd.apache.org/docs-2.0/mod/core.html#acceptpathinfo
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetime www.sf.net/projects/phptimesheet
--- End Message ---
--- Begin Message ---
Hi all,
Does anyone know if PHP has a library for getting the content of an XML file
like XML::Simple in perl?
In that perl library I can get the whole content of an XML file in a
reference to an array of arrays of arrays... with only 3 lines of code.
Is there such a simple method in PHP?
Thank you much.
Teddy
--- End Message ---
--- Begin Message ---
Octavian Rasnita wrote:
Does anyone know if PHP has a library for getting the content of an XML file
like XML::Simple in perl?
In that perl library I can get the whole content of an XML file in a
reference to an array of arrays of arrays... with only 3 lines of code.
Is there such a simple method in PHP?
Uhmm... SimpleXML?
http://us2.php.net/simplexml
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
Rodolfo wrote:
The weirdness comes when in one frame the script will print "Agent Smith"
while in the other frame of the same frameset the script which loads on it
will print "Thomas Anderson"...
Are both frames loaded at the same time? It's not possible to have two
concurrently running scripts access the same session at the same time
(At least when using files as backend). But normally that only means
that one script execution is delayed until the other script completes or
closes the session manually. But I never used session.auto_start, I
always use session_start() in the PHP code. Maybe the auto_start session
behaves differently. Maybe you can try disabling auto_start and start
the session manually. I don't think it make a difference, but who knows.
;-)
On the other hand: Have you checked that your disk has enough room for
more sessions? Maybe you are working on the bleeding edge of your
harddisk capacity.
--- End Message ---
--- Begin Message ---
Hi Klaus,
On Fri, 12 Nov 2004, Klaus Reimer wrote:
> > The weirdness comes when in one frame the script will print "Agent Smith"
> > while in the other frame of the same frameset the script which loads on it
> > will print "Thomas Anderson"...
>
> Are both frames loaded at the same time? It's not possible to have two
> concurrently running scripts access the same session at the same time
Yes, both are loaded at the same time, I mean, in the same frameset. I
don't use trans_sid, and I don't pass the SID constant nor the
session_name()=session_id() as a GET to the frame src's referred from the
frameset, so I relay on cookies. Both scripts also do a check against a
database to see if the session id stored on it is the same as the session
id which the login script stored in the $_SESSION array, for that
username, so it is supposed that every username logged on the scripts
would have one unique session id...
> always use session_start() in the PHP code. Maybe the auto_start session
> behaves differently. Maybe you can try disabling auto_start and start
> the session manually. I don't think it make a difference, but who knows.
I should try it anyway, indeed. Also, do you think that with using another
session handler (mm perhaps) instead of files the execution could speed up
or avoid file problems?. The load of the servers is not that high anyway.
I forgot to mention, I'm also using Turck MMCache as cache and
optimizer... I don't know if this could cause something weird (wouldn't
sound logical, but...). Turck MMCache version is 2.4.6.
> On the other hand: Have you checked that your disk has enough room for
> more sessions? Maybe you are working on the bleeding edge of your
Yes, I thought it too, but it still has some Gb of free space. I also
checked for problems with available file handlers/excesive opened files on
the OS side, but everything seems normal.
Thank you,
Rodolfo.
--- End Message ---
--- Begin Message ---
Trying to get the current viewed page's URL (query string intact).
this works, but infrequently:
$url = $_SERVER['URI'];
and this ignores the query string:
$url = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
I'm certain there's a way, that is browser-independent, to get your
script to grab the current URL (even if the script is an include).
i'm just trying to get a log of users currently online, and which page
they are viewing, and while the $_SERVER['REMOTE_ADDR'] will
invariably grab the IP, $_SERVER['URI'] is often empty.
i welcome any and all suggestions.
thank you,
~jmp
--- End Message ---
--- Begin Message ---
Jason Paschal wrote:
Trying to get the current viewed page's URL (query string intact).
this works, but infrequently:
$url = $_SERVER['URI'];
How about $_SERVER['REQUEST_URI']
and this ignores the query string:
$url = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
or you could add/check for $_SERVER['QUERY_STRING'] here.
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
* Jason Paschal <[EMAIL PROTECTED]>:
> Trying to get the current viewed page's URL (query string intact).
>
> this works, but infrequently:
>
> $url = $_SERVER['URI'];
>
> and this ignores the query string:
>
> $url = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
>
> I'm certain there's a way, that is browser-independent, to get your
> script to grab the current URL (even if the script is an include).
>
> i'm just trying to get a log of users currently online, and which page
> they are viewing, and while the $_SERVER['REMOTE_ADDR'] will
> invariably grab the IP, $_SERVER['URI'] is often empty.
Try:
$url = $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'];
--
Matthew Weier O'Phinney | mailto:[EMAIL PROTECTED]
Webmaster and IT Specialist | http://www.garden.org
National Gardening Association | http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
--- End Message ---
--- Begin Message ---
$_SERVER['REQUEST_URI'];
Matthew Weier O'Phinney wrote:
* Jason Paschal <[EMAIL PROTECTED]>:
Trying to get the current viewed page's URL (query string intact).
this works, but infrequently:
$url = $_SERVER['URI'];
and this ignores the query string:
$url = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
I'm certain there's a way, that is browser-independent, to get your
script to grab the current URL (even if the script is an include).
i'm just trying to get a log of users currently online, and which page
they are viewing, and while the $_SERVER['REMOTE_ADDR'] will
invariably grab the IP, $_SERVER['URI'] is often empty.
Try:
$url = $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'];
--- End Message ---
--- Begin Message ---
What's the best way to create a directory with PHP, I tried using:
if (array_exists('dir',$_POST)) {
$dir_name = test123;
shell_exec('mkdir $dir_name');
I don't want to have to declare a variable, I would like to do this all
on one line. Like:
shell_exec('mkdir $_POST['dir']'); // but it don't work
} else {
print "Get get some coffee!";
}
I'll be putting some error checking in later :)
Thanks,
Dan.
--- End Message ---
--- Begin Message ---
Use mkdir in PHP Functions.
See Also: http://www.php.net/manual/en/function.mkdir.php
On Fri, 12 Nov 2004 03:54:52 -0500, Danny Brow <[EMAIL PROTECTED]> wrote:
> What's the best way to create a directory with PHP, I tried using:
>
> if (array_exists('dir',$_POST)) {
> $dir_name = test123;
> shell_exec('mkdir $dir_name');
>
> I don't want to have to declare a variable, I would like to do this all
> on one line. Like:
> shell_exec('mkdir $_POST['dir']'); // but it don't work
> } else {
> print "Get get some coffee!";
> }
>
> I'll be putting some error checking in later :)
>
> Thanks,
> Dan.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
On Friday 12 November 2004 08:54, Danny Brow wrote:
> What's the best way to create a directory with PHP, I tried using:
>
> if (array_exists('dir',$_POST)) {
> $dir_name = test123;
I'm 99% sure you mean 'test123'.
> shell_exec('mkdir $dir_name');
I'm 100% sure you meant to use " instead of '.
> } else {
> print "Get get some coffee!";
I'm 50% sure that should be print "RTFM".
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
I like your SNOOPY POSTER!!
*/
--- End Message ---
--- Begin Message ---
Thanks, I should have looked that up. 4am, time for bed.
Thanks again,
Dan.
On Fri, 2004-11-12 at 18:01 +0900, Pluance wrote:
> Use mkdir in PHP Functions.
> See Also: http://www.php.net/manual/en/function.mkdir.php
>
> On Fri, 12 Nov 2004 03:54:52 -0500, Danny Brow <[EMAIL PROTECTED]> wrote:
> > What's the best way to create a directory with PHP, I tried using:
> >
> > if (array_exists('dir',$_POST)) {
> > $dir_name = test123;
> > shell_exec('mkdir $dir_name');
> >
> > I don't want to have to declare a variable, I would like to do this all
> > on one line. Like:
> > shell_exec('mkdir $_POST['dir']'); // but it don't work
> > } else {
> > print "Get get some coffee!";
> > }
> >
> > I'll be putting some error checking in later :)
> >
> > Thanks,
> > Dan.
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
--- End Message ---
--- Begin Message ---
On Fri, 2004-11-12 at 17:12 +0000, Jason Wong wrote:
> On Friday 12 November 2004 08:54, Danny Brow wrote:
> > What's the best way to create a directory with PHP, I tried using:
> >
> > if (array_exists('dir',$_POST)) {
> > $dir_name = test123;
>
> I'm 99% sure you mean 'test123'.
I meant $dir_name = $_POST['dir']; This works with out the single quote.
but all my variables have single or double quotes around them.
>
> > shell_exec('mkdir $dir_name');
>
> I'm 100% sure you meant to use " instead of '.
this is how I normally do this when declaring variables, but that maybe
the difference here.
>
> > } else {
> > print "Get get some coffee!";
>
> I'm 50% sure that should be print "RTFM".
RTFM > /dev/null :)
I'm 25-50% sure that this was a complete waste of a reply to a question.
>
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
> ------------------------------------------
> Search the list archives before you post
> http://marc.theaimsgroup.com/?l=php-general
> ------------------------------------------
> /*
> I like your SNOOPY POSTER!!
> */
>
--- End Message ---
--- Begin Message ---
Does anyone know of a good syslog parser?
I've successfully got the syslog server to write to a mysql table, but I now
want to find something that will give me graphs, breakdowns etc for the
syslog.
Cheers
James
--- End Message ---
--- Begin Message ---
On Fri, 12 Nov 2004 09:21:45 -0000, Nunners <[EMAIL PROTECTED]> wrote:
> I've successfully got the syslog server to write to a mysql table, but I now
> want to find something that will give me graphs, breakdowns etc for the
> syslog.
Perl has all kinds of log parsing modules, and you might also try freshmeat.
http://cpan.perl.org/
http://freshmeat.net/
For graphing in PHP I use JPGraph:
http://www.aditus.nu/jpgraph/index.php
--
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/
--- End Message ---
--- Begin Message ---
Jason wrote:
Rick Fletcher wrote:
function db( $host, $user, $pass, $dbnam ) {
$db = @mysql_pconnect( $host, $user, $pass )or die( mysql_error( $db
));
@mysql_select_db( $dbnam )or die( mysql_error( $db ) );
return $db;
}
function logs() {
global $defined;
db( $defined[9], $defined[1], $defined[2], $defined[3] );
... do some processing ...
}
what am i missing here? i get errors if i try to pass $db to logs.
i.e. logs( $db );
What's missing? The error message. Include it, and the offending
line(s) of code, and ask again.
--Rick
There isnt an error at all. According to the die() functions at the end
of the mysql() functions it should give it there, instead I get blank as
if the function has not successfully completed. The reason I say this
is if you try to access the mysql resource pointer ( $db, in this case )
I get nothing, a return code of 0. Example in point...
function db( $host, $user, $pass, $dbnam ) {
$db = @mysql_pconnect( $host, $user, $pass )or die( "<font
face=\"arial\"><b>phpDHCPAdmin currently not active, is under repair or
is not configured correctly.</b><br><br>Error Number: " . mysql_errno(
$db ) . "<br>Error Message: " . mysql_error( $db ) . "<br>Email
Administrator: <a href=\"mailto:$defined[5]\">$defined[5]</a></font>" );
@mysql_select_db( $dbnam )or die( "<font face=\"arial\"><b>Could
not connect to database: $defined[3]</b><br>Error Message: " .
@mysql_error( $db ) . "<br>" . "Error Number: " . @mysql_errno( $db ) .
"<br>Email Administrator: <a
href=\"mailto:$defined[5]\">$defined[5]</a></font>" );
return $db;
}
function logs() {
global $defined;
db( $defined[9], $defined[1], $defined[2], $defined[3] );
$pagecount = "1";
$tble = "logs";
$sql = @mysql_query( "SELECT * FROM $tble WHERE session =
\"$_SESSION[hash]\"", $db )
$db is not defined,
$db is not required,
at least if you want to use $db you have to ctach the return from db()
in $db:
$db = db( $defined[9], $defined[1], $defined[2], $defined[3] );
as i assume, logs() does nothing more than update one row with session
data in the DB?
if you have a primary key on `session` you can just user REPLACE instead of
"if SELECT INSERT ELSE UPDATE"
logs()
{
db( $defined[9], $defined[1], $defined[2], $defined[3] );
$sql = 'REPLACE INTO logs VALUES ( ... )';
mysql_query( $sql ) or die( '...' );
}
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetime www.sf.net/projects/phptimesheet
--- End Message ---
--- Begin Message ---
C.F. Scheidecker Antunes wrote:
Hello,
I would like to migrate my MySQL servers from 4.0 to 4.1.
As I use PHP as well as Java with these servers I wonder what PHP 4
version would be compatible with MySQL 4.1.
Has anyone used MySQL 4.1 with PHP yet?
I appreciate your thoughts.
Thanks.
i run 4.1.x for a while, without problems,
after upgrading you have to rebuild you php to use the new mysql_librarys
and you have to run mysql_fix_privilege_tables on the linux/unix shell
4.1. uses a new display-format for timestamps!
4.1. uses a new encryption method for password(), with this function are
all mysql_passwords stored in the db, thats why you have to run
mysql_fix_privilege_tables
read carefully through all 4.1. changelogs!
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetime www.sf.net/projects/phptimesheet
--- End Message ---
--- Begin Message ---
--- Sebastian Mendel <[EMAIL PROTECTED]> wrote:
>
> $where = array();
>
> if ( isset($_POST['Ind']) ) {
> $where[] = 'vendorjobs.Industry = ' . (int)
> $_POST['Ind'];
> }
> if ( isset($_POST['Days']) ) {
> $where[] = 'Date_Sub(Curdate(), interval ' .
> (int) $_POST['Days'] .
> ' day) <= PostStart';
> }
>
> $sql = '
> SELECT ...
> FROM vendorjobs
> WHERE ' . implode( ' AND ', $where );
>
Sebastian, I meant to thank you for this code the
other day.
What I'm trying to figure out is some of my elements
are arrays themselves. So for example I have this :
$Ind = "";
$Ind = $HTTP_POST_VARS['Ind'];
if (count($Ind) > 0 AND is_array($Ind)) {
$Ind = "'".implode("','", $Ind)."'";
}
So how would this code , or array get into what you
stated as:
> $where = array();
>
> if ( isset($_POST['Ind']) ) {
> $where[] = 'vendorjobs.Industry = ' . (int)
> $_POST['Ind'];
> }
I guess that is putting an array into an array ?
Not quite sure how the loop would go.
Thank you,
Stuart
--- End Message ---
--- Begin Message ---
I think you're implode example is pretty close.
<?php
$Ind = "";
$Ind = $_POST['Ind'];
if(is_array($Ind)
{
if (count($Ind) > 1)
{
$IndStr = implode("','", $Ind);
$where[] = "vendorjobs.Industry IN($IndStr)";
}else{
$where[] = "vendorjobs.Industry = {$Ind[0]}";
}else{
// Is there an error if not an array?
}
$sql = 'SELECT ...
FROM vendorjobs
WHERE ' . implode( ' AND ', $where );
?>
Not sure if you need the {} above, I think you do as it's an array reference
in a string.
This should result in:
WHERE vendorjobs.Industry IN (2,3,5)
OR
WHERE vendorjobs.Industry = 2
HTH
Graham
> -----Original Message-----
> From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
> Sent: 12 November 2004 12:42
> To: Sebastian Mendel; [EMAIL PROTECTED]
> Subject: Re: [PHP] Re: Help: Database Search
>
>
>
> --- Sebastian Mendel <[EMAIL PROTECTED]> wrote:
> >
> > $where = array();
> >
> > if ( isset($_POST['Ind']) ) {
> > $where[] = 'vendorjobs.Industry = ' . (int)
> > $_POST['Ind'];
> > }
> > if ( isset($_POST['Days']) ) {
> > $where[] = 'Date_Sub(Curdate(), interval ' .
> > (int) $_POST['Days'] .
> > ' day) <= PostStart';
> > }
> >
> > $sql = '
> > SELECT ...
> > FROM vendorjobs
> > WHERE ' . implode( ' AND ', $where );
> >
>
> Sebastian, I meant to thank you for this code the
> other day.
> What I'm trying to figure out is some of my elements
> are arrays themselves. So for example I have this :
>
> $Ind = "";
> $Ind = $HTTP_POST_VARS['Ind'];
> if (count($Ind) > 0 AND is_array($Ind)) {
> $Ind = "'".implode("','", $Ind)."'";
> }
>
> So how would this code , or array get into what you
> stated as:
>
> > $where = array();
> >
> > if ( isset($_POST['Ind']) ) {
> > $where[] = 'vendorjobs.Industry = ' . (int)
> > $_POST['Ind'];
> > }
>
> I guess that is putting an array into an array ?
> Not quite sure how the loop would go.
>
> Thank you,
> Stuart
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
--- Graham Cossey <[EMAIL PROTECTED]> wrote:
> This should result in:
>
> WHERE vendorjobs.Industry IN (2,3,5)
>
> OR
>
> WHERE vendorjobs.Industry = 2
>
> HTH
> Graham
Not sure what you mean by the above ?
Stuart
--- End Message ---
--- Begin Message ---
What I meant was that the $sql variable should contain
a where clause of "WHERE vendorjobs.Industry IN (2,3,5)"
if you had a multi-element array or "WHERE vendorjobs.Industry
= 2" if you had a single-element array.
The IN statement is easier to construct than multiple ORs and
tends to run faster as well.
Graham
> -----Original Message-----
> From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
> Sent: 12 November 2004 14:13
> To: Graham Cossey; Sebastian Mendel; [EMAIL PROTECTED]
> Subject: RE: [PHP] Re: Help: Database Search
>
>
>
> --- Graham Cossey <[EMAIL PROTECTED]> wrote:
>
> > This should result in:
> >
> > WHERE vendorjobs.Industry IN (2,3,5)
> >
> > OR
> >
> > WHERE vendorjobs.Industry = 2
> >
> > HTH
> > Graham
>
> Not sure what you mean by the above ?
>
> Stuart
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Hello, I have an issue with a PHP interface. We have many engineering users
who will be using a request ticket system developed in PHP here. We don't
know in advance who will be using the system and there may be new people in
all the time. Currently I have to create a login for each person who needs
to use the system, so I have to get a request for a login, create the login,
and fill in their contact information. Since we work with engineers on a
12-15 hour time difference, it might take a whole day or more to get the
login id request filled before they can open a ticket. Plus there's the
whole inconvenience of having to login to another website. The site is
inside our secure intranet, so we don't really need a double layer of
security.
Since we normally logon to a Windows network, what I would like to do is to
detect the user's windows login id when he accesses the PHP page, and
automatically reference his contact information from the windows LDAP
server, so the user can be authenticated by his current windows login
information, and not have to enter a separate login on the request page. Is
this possible, and what is an easy way to do this?
Thanks!
Chris
--- End Message ---
--- Begin Message ---
Hi all,
I was working now in a new site developed with PHP 5.0.2 and a wonder
came to me:
Is usefull and recommended to unset a class instance when not needed?
Specially when the class was instantiated inside a function and the
function ends. In this case, the system should automatically destroy
the instance (as it is a local var inside a function).
If we manually unset the instance at the end of the function, does
this affect the PHP performance? I mean, will PHP have to do an extra
job unsetting the var?
Also, the same question arises with database results. Is it worth to
call mysql_free_result at the end of a function that uses it? Must
take into consideration that there are lots of functions that use lots
of MySQL results.
Thanks for any comment
Jordi.
--- End Message ---
--- Begin Message ---
I use mysql_free_result when I'm done with the particular query, but I
don't really bother unsetting things unless I'm doing something that is
using a lot of memory. PHP will clear everything at the end of the run
anyway. I guess technically it's garbage collection, but PHP is wiping
everything, so it doesn't have the overhead of checking what's been
used, still in use or expired. It's just a wipe.
Unsetting is a good coding habit to get into, but I'm not sure of the
performance benefits. There are lots of others areas I would focus on
first to get better performance, like minimizing the number of
connections you need to make to mysql, optimizing your queries, output
buffering, etc.
On Nov 12, 2004, at 8:53 AM, Jordi Canals wrote:
Hi all,
I was working now in a new site developed with PHP 5.0.2 and a wonder
came to me:
Is usefull and recommended to unset a class instance when not needed?
Specially when the class was instantiated inside a function and the
function ends. In this case, the system should automatically destroy
the instance (as it is a local var inside a function).
If we manually unset the instance at the end of the function, does
this affect the PHP performance? I mean, will PHP have to do an extra
job unsetting the var?
Also, the same question arises with database results. Is it worth to
call mysql_free_result at the end of a function that uses it? Must
take into consideration that there are lots of functions that use lots
of MySQL results.
Thanks for any comment
Jordi.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
--- End Message ---
--- Begin Message ---
Unsetting class objects does take time and is really of no benefit
unless there are memory problems
as for freeing resuslts - the same applies
pete
Jordi Canals wrote:
Hi all,
I was working now in a new site developed with PHP 5.0.2 and a wonder
came to me:
Is usefull and recommended to unset a class instance when not needed?
Specially when the class was instantiated inside a function and the
function ends. In this case, the system should automatically destroy
the instance (as it is a local var inside a function).
If we manually unset the instance at the end of the function, does
this affect the PHP performance? I mean, will PHP have to do an extra
job unsetting the var?
Also, the same question arises with database results. Is it worth to
call mysql_free_result at the end of a function that uses it? Must
take into consideration that there are lots of functions that use lots
of MySQL results.
Thanks for any comment
Jordi.
--- End Message ---
--- Begin Message ---
Hello
I have a site that has session.use_trans_sid = 1.
It seems that the first time I visit a page when I open up my browser, URLs
are getting rewritten even though a cookie IS being set. If I refresh or move
on to another page, the problem goes away, i.e. no more session ids appended
to URLs.
I don't want to turn off trans_sid for this site because I want people to able
to use it without cookies being set.
For example
<?php
session_start();
?>
<html>
<head>
<body>
<a href="index.php">link</a>
</body>
</html>
The first time I request the page, a cookie gets set, AND the URL gets
rewritten. After that, no more URL rewrites.
Can anyone point to where I might be going wrong, or this just an odd
behaviour of session.use_trans_sid = 1
Cyril
--- End Message ---