php-general Digest 12 Jul 2004 15:09:27 -0000 Issue 2872
Topics (messages 190215 through 190239):
Re: usort e & � together
190215 by: John Taylor-Johnston
installing 4.3.x and 5.x
190216 by: Alex Duggan
190226 by: Thomas Seifert
Re: MySQL/PHP Tunneling
190217 by: Karam Chand
Re: search string / query format
190218 by: Jason Barnett
unset empty elements in an array
190219 by: Justin French
190225 by: Thomas Seifert
190230 by: Daniel Kullik
190231 by: Daniel Kullik
[PHP5RC3] echo " $this->db->host " not work
190220 by: Tomasen
190221 by: Michal Migurski
190222 by: Chris
Re: Running a PHP script on an automated regular schedule
190223 by: Henry Grech-Cini
Re: [Q] Why does my php file gets displayed instead of executed
190224 by: Marek Kilimajer
HTML and PHP output to PHP variable
190227 by: Maris
190228 by: Miroslav Hudak (php/ml)
190229 by: Maris
Re: Odd Refresh Error
190232 by: Scott Taylor
190234 by: Toze Araujo
addslashes vs string unescape
190233 by: Skippy
Cannot send session cookie
190235 by: Michael Purdy
190236 by: Andr� Ventura Lemos
190237 by: Michal Migurski
Echoing a value
190238 by: Ed Curtis
placing values in html teaxtarea
190239 by: Hull, Douglas D
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 ---
Sorry, doesn't work either.
http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=e
does not contain those that start with �:
http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=�
function usort_callback($a, $b) {
$a = str_replace(array('�', '�'), array('a', 'e'), strtolower($a));
$b = str_replace(array('�', '�'), array('a', 'e'), strtolower($b));
return (strcmp($a, $b));
}
usort($authors, 'usort_callback');
var_dump($authors);
I'll leave var_dump in there for verification.
<?php
if(!$ausenquiry) $ausenquiry ="a";
echo "<tr><td>
Note: A star, \"*\", indicates that the author uses a pseudonym.<br>Noter : Une
�toile, \"*\", indique que cet auteur est connu par un nom de plume.
<table border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n";
######################################################
$myconnection = mysql_connect($server,$user,$pass);
mysql_select_db($db,$myconnection);
$news = mysql_query("select id,AUS from $table");
######################################################
$authors = array();
$author_list = array();
while ($mydata = mysql_fetch_object($news))
{
$mydata->AUS = str_replace(" ;", ";", $mydata->AUS);
$mydata->AUS = str_replace("; ", ";", $mydata->AUS);
$tempauthors = explode(";", $mydata->AUS);
foreach ($tempauthors as $singleauthor)
{
if ($singleauthor <> "")
{
array_push($authors, $singleauthor);
$author_list[$singleauthor][] = $mydata->id; // use an associative array...
}
}
}
#sort($authors);
#usort($authors, create_function('$a,$b','return strcasecmp($a,$b);'));
#usort($authors, create_function('$a,$b','
# $a = str_replace(array('�', '�'), array('e', 'a'), $a);
# $b = str_replace(array('�', '�'), array('e', 'a'), $b);
# return strcasecmp($a,$b);'));
#$first = array('�', '�', '�', '�');
#$second = array('a', 'e', 'A', 'E');
#
#usort($authors, create_function('$a,$b','
# $a = str_replace($first, $second, $a);
# $b = str_replace($first, $second, $b);
# return strcasecmp($a,$b);'));
function usort_callback($a, $b) {
$a = str_replace(array('�', '�'), array('a', 'e'), strtolower($a));
$b = str_replace(array('�', '�'), array('a', 'e'), strtolower($b));
return (strcmp($a, $b));
}
usort($authors, 'usort_callback');
var_dump($authors);
foreach (array_count_values ($authors) as $author=>$count)
{
if((strtolower(substr($author, 0, 1)) == $ausenquiry))
{
echo "<tr bgcolor=\"#D3DCE3\">";
echo "<th align=\"left\" colspan=\"2\"><a
href=\"".$SCRIPT_NAME."?searchenquiry=".urlencode($author)."\">".$author."</a>
<small>[<--Search Entire Database]</small></th>";
echo "<th align=\"right\" width=\"5%\" nowrap>(".$count." ";
if($count > 1)
{echo "records found/trouv�s)";}
else{echo "record found/trouv�)";}
echo"</th></tr>\n";
echo "<tr bgcolor=\"#F5F5F5\"><td> </td>";
echo "<td align=\"left\">";
$temp = "";
foreach ($author_list[$author] as $ausid)
{
$temp .= "<a target=\"printwindow\"
href=\"print.php?id=".urlencode($ausid)."\">".$ausid."</a>, ";
}
$temp = substr("$temp", 0, -2);
echo "$temp</td>";
echo "<td> </td>";
echo "</tr>\n";
}
}
mysql_close($myconnection);
######################################################
echo "</table>
</td>
</tr>\n";
?>
--- End Message ---
--- Begin Message ---
Hello,
Is it possible to build php-4.3.x and php-5.0.0RC3 both as static
modules into apache-1.3? If so, can the two version of php be installed
in the same prefix? or should they be installed in /usr/local/php4
and /usr/local/php5?
Thanks,
Alex
--- End Message ---
--- Begin Message ---
On Sun, 11 Jul 2004 23:17:04 -0400, Alex Duggan wrote:
> Hello,
>
> Is it possible to build php-4.3.x and php-5.0.0RC3 both as static
> modules into apache-1.3? If so, can the two version of php be installed
> in the same prefix? or should they be installed in /usr/local/php4
> and /usr/local/php5?
AFAIK it can only be done with one of these as module, the other as CGI.
thomas
--- End Message ---
--- Begin Message ---
Hello,
Well, I know there are issues regarding this (security
as well as others). But tools like MySQL-Front and
DBTools are just doing that and it just happens that
the project i am working on needed something like
that, so I was just asking :)
Regards,
Karam
--- Curt Zirzow <[EMAIL PROTECTED]> wrote:
> * Thus wrote Karam Chand:
> > --- Curt Zirzow <[EMAIL PROTECTED]>
> wrote:
> >
> > Now, many of the ISPs blokc 3306 for security
> reason
> > and you cannot access MySQL from a 3rd party tool
> and
> > have to use phpMyAdmin which is able to access the
> > MySQL server as it is running on the same box.
> > Sometimes, SSH tunneling is also not the option :)
>
> There usually is a reason why the port 3306 port is
> blocked or that
> mysql simply doesn't listen to outside addresses on
> that port. By
> trying to circumstant that will probably result in a
> violation of
> their TOS.
>
> And as Jason suggested, use an ISP that either
> supports ssh
> tunneling (which is preferred and more likely to
> occur) or find a
> ISP that allows port 3336 to the open world.
>
> What you describe is more in the lines of Proxying,
> which is
> probably why I was confused. And I wouldn't suggest
> to anyone to
> do that kind of proxying, the layers between
> everything can be
> *very* unstable.
>
>
> Curt
> --
> First, let me assure you that this is not one of
> those shady pyramid schemes
> you've been hearing about. No, sir. Our model is
> the trapezoid!
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail
--- End Message ---
--- Begin Message ---
You might try checking out the Codewalkers.com previous contests. They
did one a while back that was for accessing google through PHP scripts.
I doubt any of them would have database support built-in, but it would
give you a head start on the input fields.
--- End Message ---
--- Begin Message ---
Hi,
Looking for a one-liner to delete all empty elements in an array. I
know I can do it with a foreach loop, but I'm hoping that I've missed
an existing function in the manual which may already do this, or a
simple one-liner to replace the foreach.
<?php
foreach($in as $k => $v) {
if(empty($v)) {
unset($in[$k]);
}
}
?>
---
Justin French
http://indent.com.au
--- End Message ---
--- Begin Message ---
On Mon, 12 Jul 2004 15:33:53 +1000, Justin French wrote:
> Hi,
>
> Looking for a one-liner to delete all empty elements in an array. I
> know I can do it with a foreach loop, but I'm hoping that I've missed
> an existing function in the manual which may already do this, or a
> simple one-liner to replace the foreach.
>
> <?php
> foreach($in as $k => $v) {
> if(empty($v)) {
> unset($in[$k]);
> }
> }
> ?>
Sure, a one-liner:
foreach ($in as $k => $v ) { if(empty($v)) unset($in[$k]); }
;).
Really what do you need an internal function for something simple like
that?
thomas
--- End Message ---
--- Begin Message ---
Justin French wrote:
Hi,
Looking for a one-liner to delete all empty elements in an array. I
know I can do it with a foreach loop, but I'm hoping that I've missed an
existing function in the manual which may already do this, or a simple
one-liner to replace the foreach.
<?php
foreach($in as $k => $v) {
if(empty($v)) {
unset($in[$k]);
}
}
?>
---
Justin French
http://indent.com.au
Though it's not really a one-liner:
[code]
while ($key = array_search('', $in)) unset($in[$key]);
[/code]
For more infos on array_seach(): http://www.php.net/array_search
Daniel
--
WWE e-commerce IT GmbH
Eiffestrasse 462, D-20537 Hamburg
Tel.: +49-40-2530659-0, Fax: +49-40-2530659-50
--- End Message ---
--- Begin Message ---
Daniel Kullik wrote:
Justin French wrote:
Hi,
Looking for a one-liner to delete all empty elements in an array. I
know I can do it with a foreach loop, but I'm hoping that I've missed
an existing function in the manual which may already do this, or a
simple one-liner to replace the foreach.
<?php
foreach($in as $k => $v) {
if(empty($v)) {
unset($in[$k]);
}
}
?>
---
Justin French
http://indent.com.au
Though it's not really a one-liner:
[code]
while ($key = array_search('', $in)) unset($in[$key]);
[/code]
For more infos on array_seach(): http://www.php.net/array_search
Daniel
A note I forgot to addi in my previous posting:
You ought to think over what you consider "empty" since empty() would
for example return true if the checked variable contained the integer 0
or the string '0'.
My posted line of code recognizes only an empty string as "empty".
You might want to take a look at this:
http://www.php.net/manual/en/types.comparisons.php
Daniel
--
WWE e-commerce IT GmbH
Eiffestrasse 462, D-20537 Hamburg
Tel.: +49-40-2530659-0, Fax: +49-40-2530659-50
--- End Message ---
--- Begin Message ---
assume $this->db is an object. $db->host is a string "localhost".
ehco $this->db->host;
// will output
localhost
but
ehco " $this->db->host ";
// whill output
Object id #2->host
is that a bug. or just have to workout by myself?
Thanks for all your good work
Tomasen
--- End Message ---
--- Begin Message ---
> echo $this->db->host;
> // will output
> localhost
>
> but
> echo " $this->db->host ";
> // whill output
> Object id #2->host
>
> is that a bug. or just have to workout by myself?
http://www.php.net/manual/en/language.types.string.php#language.types.string.parsing.complex
---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca http://mike.teczno.com/contact.html
--- End Message ---
--- Begin Message ---
Try enclosing the variable in Curly Braces
echo " {$this->db->host} ";
Otherwise, the string parser sees $this->db as the variable you're
referring to.
Chris
Tomasen wrote:
assume $this->db is an object. $db->host is a string "localhost".
ehco $this->db->host;
// will output
localhost
but
ehco " $this->db->host ";
// whill output
Object id #2->host
is that a bug. or just have to workout by myself?
Thanks for all your good work
Tomasen
--- End Message ---
--- Begin Message ---
You may also want to look at wget as a way of invoking
your PHP script if command line support is not available.
Henry
"I.A. Gray" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi.
>
> I am wanting to use a PHP script to check on an hourly/daily basis on a
few
> things- ie links on my sites, whether the sites are up and running and
also
> to send an e-mail to me. I know how to do this using PHP but my problem
is
> how to have this running 24/7. I can't really have this on a web page as
> wouldn't it time out? I don't have my own server and so use a hosting
> company. Is there a way of running a PHP script on a regular basis (say
> every 10 or 30 mins, or hourly or daily)? Would I have to set up my own
> server to do this? I just the simplest way of acheiving this. Any ideas?
> Does anyone know of any decent link checkers written in PHP that I could
> implement?
>
> Many thanks,
>
> Ian Gray
>
--- End Message ---
--- Begin Message ---
Could it be that php files are not executed for POST method?
Michael T. Peterson wrote:
Per request, here are the two other source files that get executed prior to
the invocation of validate_member_login.php, index.php and init.php.
But first, here's a simple restatement of the problem:
(1) Direct the browser to open index.php
(2) init.php is included by index.php.
(3) index.php dispatches user to member_login.htm. User fills in username
and password fields and then presses the submit button.
(4) <form action="validate_member_login.php" .../> is invoked.
(5) The source code of validate_member_login.php is displayed in the browser
rather then being executed.
However, when the invocation sequence is:
(1) Direct the browser directly to member_login.htm and fill in the username
and password fields.
(2) Press submit.
(3) validate_member_login.php is executed properly.
Here's index.php. Its purpose is to check the session variables to
determine whether the user is logged in. If not, the user is dispatched to
member_login.php via redirct using header().
Now, here are the two php files of interest, index.php and init.php. First,
index.php,
<?php
include_once( 'init.php' );
/**
* If member is already logged in, his/her username and password values will
be available to us.
*/
if( isset( $HTTP_SESSION_VARS['session_id'] ) && isset(
$HTTP_SESSION_VARS['username'] ) )
{
$session_id = $HTTP_SESSION_VARS['session_id'];
$username = $HTTP_SESSION_VARS['username'];
$result = authenticate_session( $username, $session_id );
if( $result != SUCCESS )
{
if( $result == MEMBER_NOT_REGISTERED ) {
header( 'Location: '.MEMBER_REGISTRATION_PAGE );
} else if( $result == PASSWORD_MISMATCH ) {
header( 'Location: '.MEMBER_LOGIN_PAGE );
} else {
die( $result );
}
}
header( 'Location: '.MEMBER_HOME_PAGE );
}
header( 'Location: '.MEMBER_LOGIN_PAGE );
?>
Here is init.php, the file that index.php includes (see above). This file
just sets up the exectution environment.
<?php
session_start();
/**
* init.php
*
* Script that initializes the execution environment.
*/
//
// Check whether this is running on a UNIX or a Windows operating system.
// We need to know this to set the include_path separator character
// character correctly.
//
$isWindows = false;
$pathDelimiter = ':';
$operatingSystem = PHP_OS;
if( strcmp( $operatingSystem, 'WINNT' ) == 0 )
{
$isWindows = true;
$pathDelimiter = ';';
}
// Uncomment and use this symbol when publishing to the internet on
ipowerweb.
// Yields /home/mazamaso/public_html
$WWWROOT = $_SERVER['DOCUMENT_ROOT'];
// Set up the dev directory's environment variables.
$PROJECT_DIR = $WWWROOT.'/northwest_steelheader';
$MEMBERS_DIR = $PROJECT_DIR.'/members';
$SCRIPTS_DIR = $PROJECT_DIR.'/scripts';
$DB_SCRIPTS_DIR = $SCRIPTS_DIR.'/db';
$UTILS_SCRIPTS_DIR = $SCRIPTS_DIR.'/utils';
$SESSION_SCRIPTS_DIR = $SCRIPTS_DIR.'/security';
$GRAPHICS_DIR = $SCRIPTS_DIR.'/jpgraphics';
$MEMBER_HOME_PAGE = $PROJECT_DIR.'/member_homepage.html';
$MEMBER_LOGIN_PAGE = $MEMBERS_DIR.'/member_login.htm';
$MEMBER_REGISTRATION_PAGE = $MEMBERS_DIR.'/member_registration_form.htm';
$MEMBER_LOGOUT_PAGE = $MEMBERS_DIR.'/member_logout.php';
$INCLUDE_PATH =
'.'.$pathDelimiter.$PROJECT_DIR.$pathDelimiter.$DB_SCRIPTS_DIR.$pathDelimite
r.$UTILS_SCRIPTS_DIR.$pathDelimiter.$GRAPHICS_DIR.$pathDelimiter.$SESSION_SC
RIPTS_DIR;
//
// Establish the site's environment variables
//
define( 'PROJECT_DIR', $PROJECT_DIR );
define( 'MEMBERS_DIR', $MEMBERS_DIR );
define( 'SCRIPTS_DIR', $SCRIPTS_DIR );
define( 'DB_DIR', $DB_SCRIPTS_DIR );
define( 'UTILS_DIR', $UTILS_SCRIPTS_DIR );
define( 'SESSION_DIR', $SESSION_SCRIPTS_DIR );
define( 'DEBUG', true );
define( 'MEMBER_HOME_PAGE', $MEMBER_HOME_PAGE );
define( 'MEMBER_LOGIN_PAGE', $MEMBER_LOGIN_PAGE );
define( 'MEMBER_REGISTRATION_PAGE', $MEMBER_REGISTRATION_PAGE );
define( 'MEMBER_LOGOUT_PAGE', $MEMBER_LOGOUT_PAGE );
if( strcmp( $WWWROOT, 'c:/program files/apache group/apache/htdocs' ) == 0 )
{
define( 'DB_NAME', 'wwwwwwww' );
define( 'DB_ADMIN', 'aaaaaaaaa' );
define( 'DB_PASSWORD', 'bbbbbbbbb' );
} else {
define( 'DB_NAME', 'wwwwwwww' );
define( 'DB_ADMIN', 'xxxxxxxx' );
define( 'DB_PASSWORD', 'yyyyyyyy' );
}
ini_set( 'include_path', $INCLUDE_PATH );
ini_set( 'session.save_path', $PROJECT_DIR.'session_stats');
// These are the base includes, i.e., that apply to every php file in the
site
include_once( 'print_utils.php' );
include_once( 'mz_error_handler.php' );
include_once( 'db_utils.php' );
include_once( 'passwords.php' );
include_once( 'date_utils.php' );
include_once( 'session_control_lib.php' );
set_error_handler( 'mz_error_handler' );
assert_options( ASSERT_ACTIVE, TRUE );
assert_options( ASSERT_BAIL, TRUE );
?>
<snip>
--- End Message ---
--- Begin Message ---
Hi!
Let's say my index.php consists of the following:
<? include("header.inc"); echo "<p>PHP says Hello World</p>"; ?>
<p>HTML says Hello World</p>
<? //.. some other php code that generates output... ?>
..some other HMTL output..
My question is:
how can I make the whole index.php generated output put in one PHP variable?
It is also important that it is done from the same index.php file.
Thanks,
Maris
--- End Message ---
--- Begin Message ---
hello!
use output buffering...
<?php
ob_start();
//... your code here
$_contents = ob_get_contents();
ob_end_clean();
?>
regards,
m.
Maris wrote:
Hi!
Let's say my index.php consists of the following:
<? include("header.inc"); echo "<p>PHP says Hello World</p>"; ?>
<p>HTML says Hello World</p>
<? //.. some other php code that generates output... ?>
..some other HMTL output..
My question is:
how can I make the whole index.php generated output put in one PHP variable?
It is also important that it is done from the same index.php file.
Thanks,
Maris
--- End Message ---
--- Begin Message ---
Thanks a lot Miroslav,
will try this construction! :)
"Miroslav Hudak" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> hello!
>
> use output buffering...
>
> <?php
> ob_start();
> //... your code here
> $_contents = ob_get_contents();
> ob_end_clean();
> ?>
>
> regards,
> m.
>
> Maris wrote:
>
> > Hi!
> >
> > Let's say my index.php consists of the following:
> >
> > <? include("header.inc"); echo "<p>PHP says Hello World</p>"; ?>
> > <p>HTML says Hello World</p>
> > <? //.. some other php code that generates output... ?>
> > ..some other HMTL output..
> >
> > My question is:
> > how can I make the whole index.php generated output put in one PHP
variable?
> > It is also important that it is done from the same index.php file.
> >
> > Thanks,
> > Maris
> >
--- End Message ---
--- Begin Message ---
* Thus wrote Scott Taylor:
Some people are complaining that when the visit one of my pages that the
pages refeshes over and over again. One person said that it was only
when he typed something in on one of the forms. How could an error like
this be caused? Could this be a bug in a browser?
More like a End User malfunction.
Or that your form submision is causing an infinite redirect loop of
some sort.
Curt
-- The infinite loop is what I thought at first too, but wouldn't this
show up on all browsers and not just netscape 7.1? What does End User
malfunction mean? That people don't know how to use their browsers/the
internet? I wouldn't doubt that this is the case unless I didn't have so
many people come to me with this - probably there have been at least 5-7
people who have reported this. Scott
--- End Message ---
--- Begin Message ---
The problem is in the browser, i have IE 6.0 and some pages on my localhost
server have the same problem, sometimes it happend, sometimes not. If i use
other browser like Opera the page has no problem.
I think this problem is not related to the version, because others with the
same version doesnt have the same problem.
The problem happend more frequently when i use big tables or long pages.
Solution: Upgrade the browser.
For the case
----- Original Message -----
From: "Scott Taylor" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 12, 2004 1:38 PM
Subject: [PHP] Re: Odd Refresh Error
>
>
>
> * Thus wrote Scott Taylor:
>
> >>
> >> Some people are complaining that when the visit one of my pages that
the
> >> pages refeshes over and over again. One person said that it was only
> >> when he typed something in on one of the forms. How could an error
like
> >> this be caused? Could this be a bug in a browser?
> >
> >
>
> More like a End User malfunction.
>
> Or that your form submision is causing an infinite redirect loop of
> some sort.
>
> Curt
> -- The infinite loop is what I thought at first too, but wouldn't this
> show up on all browsers and not just netscape 7.1? What does End User
> malfunction mean? That people don't know how to use their browsers/the
> internet? I wouldn't doubt that this is the case unless I didn't have so
> many people come to me with this - probably there have been at least 5-7
> people who have reported this. Scott
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
I'm confronted with a somewhat weird problem and hopefully someone can make a
suggestion. I have to perform the following 3-step task:
Step 1. Someone provides a string (let's call it the formatting string) which
contains a PHP expression, which will apply a PHP function on another string,
let's call this one the random string. I don't control either the formatting
nor the random string.
Example of formatting string: "trim('%val%')"
Step 2. As you may have guessed, I have to insert the random string in the
formatting string before I can eval() the latter. So I need to replace %val%
with the random string. But I have to be careful, since the random string may
itself contain either double or single quotes, which will break the eval()
later. So I also need an addslashes().
Operations performed:
$for_eval=str_replace('%val%',addslashes($random),$format);
$for_eval='$final_result='.$for_eval.';';
eval($for_eval);
Step 3. After the above, I should have the formatted string in $final_result.
***
So now for the problem: addslashes() indiscriminately escapes with backslashes
both single and double quotes. Strings variables can be specified with either
single or double quotes; each of the cases, in turn, will not un-escape the
other type of quote. For example, a string enclosed in double quotes will not
un-escape \' and a string enclosed in single quotes will not un-escape \".
But my addslashes() escaped both types of quotes. And the formatting string
(see step 1) will necessarily have enclosed the string to be (%val%) in only
one of the two types of quotes. So, after all steps are performed, I may very
well be left with either single or double quotes still escaped, depending on
the type of quotes which were used in the formatting string.
I was under the impression that double quote strings will be interpreted as to
unescape single quotes too. However, the manual says they don't do that; they
unescape some common print sequences (such as tab or newline), double quotes
(of course), backslash itself, and octal or hexa expressions. NOT single quotes.
If only I could be sure of the type of quotes which were used in the
formatting string, I could only escape those by hand. But I can't be sure.
Also, I can't forcefully strip slashes from the final result, because I don't
know which sequences that look like escapes are really escapes or are just
legitimate pieces of string.
If only double quote strings would un-escape both types of quotes; they don't,
so their un-escape action is not a 100% reversion of the addslashes() effect.
Any ideas?
--
Romanian Web Developers - http://ROWD.ORG
--- End Message ---
--- Begin Message ---
Folks
I am a new to php. I am currently learning about session handling and would
appreciate some assistance with the following:
I am using php 4.3.7 and I am using the default values in the php.ini for
session.use_cookies = 1
session.cache_limiter = nocache
When experimenting with a few simple lines of code
<script language='php'> ---- This is line 14
session_start();
</script>
I get the following errors:
Warning: session_start(): Cannot send session cookie - headers already sent by (output
started at e:\http\cgi\a.php:14) in e:\http\cgi\a.php on line 15
Warning: session_start(): Cannot send session cache limiter - headers already sent
(output started at e:\http\cgi\a.php:14) in e:\http\cgi\a.php on line 15
Can anyone offer me a insight on the reason for the error.
Mike
--- End Message ---
--- Begin Message ---
From: http://www.php.net/manual/en/function.session-start.php
"Note: If you are using cookie-based sessions, you must call
session_start() before anything is outputted to the browser."
You have to put session_start before anything else.
On Mon, 2004-07-12 at 15:40, Michael Purdy wrote:
>
> Warning: session_start(): Cannot send session cookie - headers already sent by
> (output started at e:\http\cgi\a.php:14) in e:\http\cgi\a.php on line 15
>
> Warning: session_start(): Cannot send session cache limiter - headers already sent
> (output started at e:\http\cgi\a.php:14) in e:\http\cgi\a.php on line 15
>
> Can anyone offer me a insight on the reason for the error.
>
> Mike
--
I/O, I/O,
It's off to disk I go,
A bit or byte to read or write,
I/O, I/O, I/O...
signature.asc
Description: This is a digitally signed message part
--- End Message ---
--- Begin Message ---
> When experimenting with a few simple lines of code
>
> <script language='php'> ---- This is line 14
> session_start();
> </script>
>
> I get the following errors:
>
> Warning: session_start(): Cannot send session cookie - headers already sent by
> (output started at e:\http\cgi\a.php:14) in e:\http\cgi\a.php on line 15
What's on lines 1-13? Does it have whitespace or indents on line 14, like
in your mail? Any use of headers, get/set cookies, or sessions must happen
before any output such as HTML or print/echo is sent to the browser.
Generally, it's a good idea to have set-up code such as session_start() be
one of the very first things you call in a script.
Wrong:
<html><head /><body><?php session_start() ?></body></html>
Right:
<?php session_start() ?><html><head /><body /></html>
---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca http://mike.teczno.com/contact.html
--- End Message ---
--- Begin Message ---
I'm having some trouble echoing a value to a file that is being pulled
from a MySQL database. I've included my code below I'm sure it's something
really simple but I'm not seeing it. $row['users.name'] and
$row['users.company'] echo nothing while $row['cnt'] echoes it's expected
values. If anyone can tell me what I'm doing wrong I'd appreciate it.
Thanks,
Ed
$ap = fopen("$ad_path/AdCount$issue.txt", "w");
mysql_connect ($local_host, $local_user, $local_pass);
mysql_select_db ($local_db);
$result = mysql_query ("SELECT *, COUNT(*) as cnt FROM users, listings
WHERE listings.user_id = users.id AND listings.active = '1' GROUP BY
users.company, users.name");
if ($row = mysql_fetch_array($result)) {
do {
fputs($ap, $row['users.name']);
fputs($ap, $sp);
fputs($ap, $sp);
fputs($ap, $row['users.company']);
fputs($ap, $sp);
fputs($ap, $sp);
fputs($ap, $row['cnt']);
fputs($ap, $nl);
}
while($row = mysql_fetch_array($result));
mysql_close(); }
fclose($ap);
--- End Message ---
--- Begin Message ---
After doing calculations etc on my data I am wanting to place it in a textarea form in
html. I am having trouble getting my data to show up in my texarea. For example, say
after all my calculations I my field called $test ends up containing "This is a test".
Here is what I tried:
<textarea name="zoutput" rows="20" cols="70" wrap value="<? echo $test; ?>" />
</textarea>
I can add the $test to input like this but not a textarea.
Name: <input type="text" name="zfname" value="<? echo $test; ?>"/> <br>
Is this possible?
Thanks,
Doug
--- End Message ---