php-general Digest 8 Mar 2005 16:53:16 -0000 Issue 3326
Topics (messages 210203 through 210233):
Re: Can't figure mail & post out
210203 by: Zareef Ahmed
210206 by: anirudh dutt
Re: Newbie Question re substr
210204 by: Jackson Linux
210207 by: Kim Madsen
210214 by: Jackson Linux
Re: fsockopen and session_start
210205 by: Jason Wong
210215 by: Pedro Garre
php-help
210208 by: K Karthik
210212 by: Frank Arensmeier
210216 by: John Nichel
Re: Document root, preferred way to find it???
210209 by: Jochem Maas
210218 by: Leif Gregory
recommended way for server side validation - include in same file or have a
different file
210210 by: Vinayakam Murugan
210217 by: Leif Gregory
210219 by: Brent Baisley
Re: ftp upload via web form - problem getting the file name correct
210211 by: Franklin van de Meent
210230 by: Steve Turnbull
Re: Using switch() to process a set of forms
210213 by: Franklin van de Meent
210233 by: Jochem Maas
Quite a basic question
210220 by: Mário Gamito
210221 by: Kae Verens
210222 by: Leif Gregory
210224 by: Jochem Maas
Re: Quite a basic question[Scanned]
210223 by: Michael Egan
usage of php & <script> tags
210225 by: Jochem Maas
210226 by: Robert Cummings
210227 by: M. Sokolewicz
210228 by: Richard Lynch
210229 by: Robert Cummings
php books with more extensive LDAP and FTP explenations
210231 by: Steve Turnbull
Re: call anchor from php
210232 by: Richard Lynch
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:
php-general@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On Mon, 7 Mar 2005 10:02:32 +0530, anirudh dutt <[EMAIL PROTECTED]> wrote:
> On Mon, 7 Mar 2005 08:37:52 +0530, Zareef Ahmed <[EMAIL PROTECTED]> wrote:
> > Hi Robert,
> >
> > Please take a look at php manual and try to know something about
> > $_POST, $_GET etc.
> > Your code is full of errors.
> >
> >
> > On Sun, 6 Mar 2005 15:33:30 -0500, Robert <[EMAIL PROTECTED]> wrote:
> > > $sendto = "$row[1]";
> > > echo "<br>Row one output = $sendto<br>";
> > > mail ($_POST['sendto'],'Testing', $body, $headers);
> > Again you are sending the mail to same person very time.
>
> no, that part is correct.
Dear Anirudh,
Yes syntax is correct but receipent field is looking for the value in
$_POST and programe is intended to send the emails to users in the
database.
> while ($row = mysql_fetch_array ($result, MYSQL_NUM)) {
> ...
> mail ($_POST['sendto'],'Testing', $body, $headers);
> echo "Sent to $row[1]<br>";} // <--*
$row['1'] is correct but it was not used as the reciepent.
zareef ahmed
> mysql_free_result ($result);
>
> * the values are retrieved and used in the loop, the mail IS going to
> the right person.
>
> > > $headers = "MIME-Version: 1.0\r\n";
> > > $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
> > > $headers .= "From: ";
> > From is not set, value is not here.
>
> this is the part that's causing the problem. u can leave it empty and
> let the system put the admin's email id. don't leave it incomplete
> though.
>
> i agree that there are logical errors regarding the data he's used,
> but that's not why it didn't work.
>
> @Robert: u may want to print/echo all the vars for mail() before using
> it, helps to debug. check all $POST vars too. this is how i generally
> set the headers:
> $headers = "From: $fname <$from_email>\n"."Return-Path: $ret"."\n";
>
> i use return path so that bounce messages/delivery failures go to another id.
>
> if u want to add the X-Mailer header:
> $headers.= 'X-Mailer: PHP/' . phpversion()."\n";
> (note ^^^ the dot)
>
> if still doesn't work, replace ur \r\n with \n. check manual page for details.
>
> considering that u're possibly mass mailing...
> http://us2.php.net/manual/en/function.mail.php
> [quote]
> Note: It is worth noting that the mail() function is not suitable
> for larger volumes of email in a loop. This function opens and closes
> an SMTP socket for each email, which is not very efficient.
>
> For the sending of large amounts of email, see the PEAR::Mail, and
> PEAR::Mail_Queue packages.
> [/quote]
> u could also open a pipe to the mail program...
> http://www.devarticles.com/c/a/PHP/Getting-Intimate-With-PHPs-Mail-Function/2/
>
> hth
>
> --
> ]#
> Anirudh Dutt
>
> ...pilot of the storm who leaves no trace
> like thoughts inside a dream
>
--
Zareef Ahmed :: A PHP Developer in India ( Delhi )
Homepage :: http://www.zareef.net
--- End Message ---
--- Begin Message ---
On Tue, 8 Mar 2005 10:28:32 +0530, Zareef Ahmed <[EMAIL PROTECTED]> wrote:
> On Mon, 7 Mar 2005 10:02:32 +0530, anirudh dutt <[EMAIL PROTECTED]> wrote:
> > On Mon, 7 Mar 2005 08:37:52 +0530, Zareef Ahmed <[EMAIL PROTECTED]> wrote:
> > > Again you are sending the mail to same person very time.
> >
> > no, that part is correct.
>
> Dear Anirudh,
> Yes syntax is correct but receipent field is looking for the value in
> $_POST and programe is intended to send the emails to users in the
> database.
u're right. i didn't c that he used mail ($_POST['sendto'],... and not
mail ($sendto,...
(i was more concerned with the syntax/value errors)
> > while ($row = mysql_fetch_array ($result, MYSQL_NUM)) {
> > ...
> > mail ($_POST['sendto'],'Testing', $body, $headers);
> > echo "Sent to $row[1]<br>";} // <--*
> $row['1'] is correct but it was not used as the reciepent.
yup.
@Robert: i know u've fixed the problem but...
On Sun, 6 Mar 2005 23:00:55 -0500, Robert <[EMAIL PROTECTED]> wrote:
> Thanks, I fixed the problem and it's working great. Didn't need the $_POST
> in the email and needed double quotes around the sender header variable.
u did have double quotes around ur headers.
"sender header variable" == the ( $headers .= "From: "; ) line ? any
program (not logic) changes other than that?
--
]#
Anirudh Dutt
...pilot of the storm who leaves no trace
like thoughts inside a dream
--- End Message ---
--- Begin Message ---
Zareef,
Almost....
On 7 Mar 2005, at 23:52, Zareef Ahmed wrote:
From: [EMAIL PROTECTED]
Subject: Re: [PHP] Newbie Question re substr
Date: 7 March 2005 23:52:15 GMT-05:00
To: [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Reply-To: [EMAIL PROTECTED]
On Mon, 7 Mar 2005 22:23:19 -0500, Jackson Linux
<[EMAIL PROTECTED]> wrote:
Hi,
I'm really new and getting lots of help but need some assistance.
I'm running a script which gets specific articles from a database if
they're entered in the URL after the ? . For instance if someone asks
for
www.foo.com/index.htm?a=1234
then the script would look for an database entry with the id of 1234
and display it in the page.
If there's no number specified (www.foo.com/index.htm) or if the number
given is to an article which doesn't exist, it gets the titles of all
the articles available and prints them as links to the proper article
number.
I'd also like it to grab the first 200 characters of text from the
$content field of the entry.
With help I have the title link part and I suspect I'm close but I keep
messing up the syntax
The code is:
<snip>
if (!empty($where)) {
echo "
<ul>";
$article = mysql_fetch_assoc($result);
} else {
while ($article = mysql_fetch_assoc($result)) {
$table_of_contents[] = "
<li><a href='{$_SERVER['PHP_SELF']}?a={$article['article_id']}'
title='{$article['title']}'>{$article['title']}</a><br />
$article['content'] = substr($article['content'], 0 200);</li>";
change these two lines to
title='{$article['title']}'>{$article['title']}</a><br />".
substr($article['content'], 0, 200)."</li>";
zareef ahmed
I did that and now it reads this:
if (!empty($where)) {
echo "
<ul>";
$article = mysql_fetch_assoc($result);
} else {
while ($article = mysql_fetch_assoc($result)) {
$table_of_contents[] = "
<li><a href='{$_SERVER['PHP_SELF']}?a={$article['article_id']}'
<li><a href='{$_SERVER['PHP_SELF']}?a={$article['article_id']}'
title='{$article['title']}'>{$article['title']}</a><br />".
substr($article['content'], 0, 200)."</li>";
}
}
\
Which doesn't kick back errors but also does not pull any
$article['content'] - it leaves a line break but no text is being
inserted from the content row.
?
--- End Message ---
--- Begin Message ---
From: Jackson Linux [mailto:[EMAIL PROTECTED]
Sent: 8. marts 2005 04:23
First of all, echo the output to see if You get, what Tou expect in a debug
situation:
if (!empty($where)) {
echo "
<ul>";
$article = mysql_fetch_assoc($result);
} else {
while ($article = mysql_fetch_assoc($result)) {
// humanize data
$article_id = $article['article_id'];
$title = $article['title'];
$content = substr($article['content'], 0 200); // get first 200 chars
// print and see if we get, what we expect
Print "id=$article_id<br>title=$title<br>content=$content<p>";
// now make the real stuff
print "<li><a href='{" . $_SERVER['PHP_SELF'] .
"}?a={$article_id}'}&title='{$title}'>{$article['title']}</a><br
/>\n$content</li>";
}
}
echo "
</ul>";
I´ve put the "&" in front of title since the link otherwise would be <a
href="a=1234title=sometext">, which is not what You want I guess.
And I substituted the
$article['content'] = substr($article['content'], 0 200);</li>"; } }
with
$content</li>";
since I believe You want to print the content and not just assign it? Otherwise
the <br /> makes no sense :-)
> Can anyone help ?
I hop that did the trick for You :-)
--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler
Naverland 31
DK-2600 Glostrup
www.comx.dk
Telefon: +45 70 25 74 74
Telefax: +45 70 25 73 74
E-mail: [EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
Thanks, Kim! Still having difficulties though......
On 8 Mar 2005, at 03:29, Kim Madsen wrote:
From: Jackson Linux [mailto:[EMAIL PROTECTED]
Sent: 8. marts 2005 04:23
First of all, echo the output to see if You get, what Tou expect in a
debug situation:
if (!empty($where)) {
echo "
<ul>";
$article = mysql_fetch_assoc($result);
} else {
while ($article = mysql_fetch_assoc($result)) {
// humanize data
$article_id = $article['article_id'];
$title = $article['title'];
$content = substr($article['content'], 0 200); // get first 200
chars
// print and see if we get, what we expect
Print "id=$article_id<br>title=$title<br>content=$content<p>";
// now make the real stuff
print "<li><a href='{" . $_SERVER['PHP_SELF'] .
"}?a={$article_id}'}&title='{$title}'>{$article['title']}</a><br
/>\n$content</li>";
}
}
echo "
</ul>";
I´ve put the "&" in front of title since the link otherwise would be
<a href="a=1234title=sometext">, which is not what You want I guess.
And I substituted the
$article['content'] = substr($article['content'], 0 200);</li>"; } }
with
$content</li>";
since I believe You want to print the content and not just assign it?
Otherwise the <br /> makes no sense :-)
Can anyone help ?
I hop that did the trick for You :-)
It's really sensible and logical what you did. I really appreciate it.
1. $content = substr($article['content'], 0 200); // get first 200
chars is choking, and I've looked in docs and can't understand why.
I get
Parse error: parse error, unexpected T_LNUMBER in
/usr/www/users/domain/dynamic/templates/substr.htm on line 57
2. This correction:
I´ve put the "&" in front of title since the link otherwise would be
<a href="a=1234title=sometext">, which is not what You want I guess.
Wow. Actually I wanted it to make <a href='a=1234' title='sometext'> -
does this:
print "<li><a href='{" . $_SERVER['PHP_SELF'] . "}?a={$article_id}'}'
title='{$title}'>{$article['title']}</a><br />\n$content</li>";
do that? (I ask because I can;t make any of it work?!)
Thanks so much for your help.
--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler
Naverland 31
DK-2600 Glostrup
www.comx.dk
Telefon: +45 70 25 74 74
Telefax: +45 70 25 73 74
E-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
---------
---------
Nick Selby
Flyguides, Inc.
347 675 8295
http://www.flyguides.com/press/selby.htm
--- End Message ---
--- Begin Message ---
On Monday 07 March 2005 22:02, Pedro Garre wrote:
> I am using fsockopen to simulate a POST to another page (test_post.php)
> within the same server.
It's not clear how exactly you're executing your code. I suspect that you
haven't closed the session before doing your simulated POST. Your order
of execution should be something like:
start session
assign values to session
close session
do the simulated POST
--
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
------------------------------------------
New Year Resolution: Ignore top posted posts
--- End Message ---
--- Begin Message ---
*This message was transferred with a trial version of CommuniGate(tm) Pro*
It works now. Thanks Jason.
I had never realized that once $_SESSION is set, and if you are not going to
modify it, the session could be closed. It does not seem a good programming
practice, thou.
On Tuesday 08 March 2005 05:15, Jason Wong wrote:
> *This message was transferred with a trial version of CommuniGate(tm) Pro*
>
> On Monday 07 March 2005 22:02, Pedro Garre wrote:
> > I am using fsockopen to simulate a POST to another page (test_post.php)
> > within the same server.
>
> It's not clear how exactly you're executing your code. I suspect that you
> haven't closed the session before doing your simulated POST. Your order
> of execution should be something like:
>
> start session
> assign values to session
> close session
> do the simulated POST
--- End Message ---
--- Begin Message ---
sir,
iam new to php i'll explain my problem .if u could help i'll be very
thankful...
in my mysql database i have two tables i.e., table1 and table2.
i have an array of result from one query "select feild1 from table1 "
i have to use this result in another query.....
"select field2 from table 2 where field1 = (array of first query iterated)"
can u help me doing this in php.
thanks,
karthik
--- End Message ---
--- Begin Message ---
Hi,
MySQL is capable of doing very complex queries. You could boil down
your query into just one single line:
'SELECT * FROM table1, table2 WHERE table2.field2 = table1.field1'
A good starting point would be the MySQL manual.
I would also strongly recommend you to take a look at the PHP manual
for information about connecting to a MySQL database from PHP, gaining
results and processing these results.
If you could post some PHP code to this list, I am sure members of this
list will gladly help you with debugging the code.
Regards,
Frank
2005-03-08 kl. 11.26 skrev K Karthik:
sir,
iam new to php i'll explain my problem .if u could help i'll be very
thankful...
in my mysql database i have two tables i.e., table1 and table2.
i have an array of result from one query "select feild1 from table1 "
i have to use this result in another query.....
"select field2 from table 2 where field1 = (array of first query
iterated)"
can u help me doing this in php.
thanks,
karthik
________________________________________________
Frank Arensmeier
Marketing Support
NIKE HYDRAULICS AB
Box 1107
631 80 Eskilstuna
Sweden
tel +46 16 82 34
fax +46 16 13 93 16
email: [EMAIL PROTECTED]
www.nikehydraulics.com
--- End Message ---
--- Begin Message ---
K Karthik wrote:
sir,
iam new to php i'll explain my problem .if u could help i'll be very
thankful...
in my mysql database i have two tables i.e., table1 and table2.
i have an array of result from one query "select feild1 from table1 "
i have to use this result in another query.....
"select field2 from table 2 where field1 = (array of first query iterated)"
can u help me doing this in php.
thanks,
karthik
This isn't PHP. Check the MySQL manual. You can construct your query
to select from both tables at the same time, so chances are you don't
need to get data from one table just so you can use that to retrieve
data from another table.
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
Leif Gregory wrote:
Hello Marek,
Sunday, March 6, 2005, 7:08:24 PM, you wrote:
I don't see where that tells me where the include folder would be.
MK> If you know how the files are layed out in your application, you do.
No... You missed the point of this whole thread which was explained in
point 1 and point 2 of the "Problem" section.
Restated in different words is how do you write some code which is
dynamic enough to withstand reorganization of folders either on the
same host, a different host (maybe with a different OS too), or a
mixture of any.
In HTML, a css declaration as follows:
<link rel="stylesheet" type="text/css" title="Site CSS" href="includes/site.css"
/>
er does it really?
<link rel="stylesheet" type="text/css" title="Site CSS" href="includes/site.css"
/>
I'm pretty sure the url is ./includes/site.css i.e. the include subdir of the
dir in which the html file that includes the link tag is in. if you move the
html file up or down a dir then the link to the css file will break....
maybe browsers are smart enough to also check /includes/site.css
works regardless of where the page is, where it's moved to, and
regardless of how many folders down it is as long as there is indeed a
folder off the site root called "includes" and as long as there is a
file in that folder called "site.css".
How do we mimic that capability in PHP so pages don't have to be
re-written if point 1 or point 2 of the "Problem" are met?
Cheers,
Leif Gregory
--- End Message ---
--- Begin Message ---
Hello Jochem,
Tuesday, March 8, 2005, 3:30:19 AM, you wrote:
J> <link rel="stylesheet" type="text/css" title="Site CSS"
href="includes/site.css" />
J> I'm pretty sure the url is ./includes/site.css i.e. the include
J> subdir of the dir in which the html file that includes the link tag
J> is in. if you move the html file up or down a dir then the link to
J> the css file will break....
J> maybe browsers are smart enough to also check /includes/site.css
Oops, my bad. I missed the slash in front. I've never run into a
problem using this:
<link rel="stylesheet" type="text/css" title="Site CSS"
href="/includes/site.css" />
and I've never placed a period at the beginning.
But you raise an interesting point. Is the server telling the browser
where the doc root is, or is the browser just guessing by dumping
everything after the domain name and using what's left as the doc
root.
--
Leif (TB lists moderator and fellow end user).
Using The Bat! 3.0.2.3 Rush under Windows XP 5.1
Build 2600 Service Pack 2 on a Pentium 4 2GHz with 512MB
--- End Message ---
--- Begin Message ---
Hi
I have always felt for reasons for cleanliness and clarity, it is
better to have the validation and insert / update statements in a
seperate file rather than have it in the same script.
Case 1
----------
//file:form.php
if $_POST
then validate
Insert or update on success
else
if $_GET['primarykey'] then
show form for editing
else
show form for adding
fi
<form action="form.php" method=post>
Show form
</form>
Case 2
----------
//file:form1.php
if $_GET['primarykey'] then
show form for editing
else
show form for adding
fi
<form action="formvalidate.php" method=post>
Show form
</form>
However in the second case, in case of an error, displaying the data
becomes an issue.
Any recommended ways for server side validation
--
Warm Regards
~~~~~~~~~~~~
Vinayak
--- End Message ---
--- Begin Message ---
Hello Vinayakam,
Tuesday, March 8, 2005, 4:11:43 AM, you wrote:
V> However in the second case, in case of an error, displaying the
V> data becomes an issue.
V> Any recommended ways for server side validation
I usually do the updates in the same file unless there are a lot of
different things going on (inserts, updates, deletes etc), then I'll
break it out into separate files. However, I do almost always have an
included file with all my error checking code.
So, let's say in the main page(let's call it index.php) where we're
filling out a form, we have the following three items:
formFirstName
formLastName
formEmployeeNumber
We submit and the action is PHP_SELF
At the top of index.php is an include for errorhandler.php which only
happens if $_POST['submit'] == "Submit"
errorhandler.php includes functions.php at the top and
errorhandler.php looks like this:
validateString('firstName', $_POST['formFirstName'], 25)
validateString('lastName', $_POST['formLastName'], 25)
validateNumeric('EmployeeNumber', $_POST['formEmployeeNumber'], 5)
functions.php contains all my commonly used functions, and
validateString() might look like this:
function validateString($fieldName, $fieldValue, $size) {
global $errors[];
if ($strlen($fieldValue) <= $size) {
if (does not contain any undesirable characters) {
$errors['$fieldname'] = 0;
}
else {
$errors[0] = "1";
$errors[$fieldName] = "You may only use letters and hyphens.";
}
}
else {
$errors[0] = "1";
$errors[$fieldName] .= "This field is limited to $size characters.";
}
return;
}
Then back in index.php I test $errors[0] to see if there was an error,
if so, I skip over the insert, update or delete and just go back down
to the form and display the error where appropriate.
Note: I didn't test the above code for this explanation.
It gets a bit harder when you have separate files but it's doable.
--
Leif (TB lists moderator and fellow end user).
Using The Bat! 3.0.2.3 Rush under Windows XP 5.1
Build 2600 Service Pack 2 on a Pentium 4 2GHz with 512MB
--- End Message ---
--- Begin Message ---
The way I do it is to have display, edit, validation and save all in
the same "file". I have an "op" variable that tracks whether the
operation is an edit or reedit (reuse submitted data) because of
validation failure. Another variable would track if it's a new entry
(blank fields) or editing an existing entry (retrieve data). For
clarity, I break out pieces into separate files and just include them
if needed. This keeps the file smaller and easier to traverse and
debug.
if ($op=='save') {
validate
if validated
include('saveFile.php')
op = 'view'
else
error message stuff
op = 'reedit'
}
if ($op=='reedit') {
prep submitted data for reediting, include error message(s)
} elseif ($id=='new') {
prep 'blank' data, set defaults
} elseif ($id>0) {
retrieve data for display or editing
}
if ($op=='edit' || $op=='reedit') {
create form field for data entry
} else {
massage data for display
}
Merge data with HTML template file
Display final page
That's basically my template. The "core" file is really just the logic,
data retrieval is obviously done through a function call. The display
piece, the html, is in a separate file and is structured for handling
simple data display or data entry form fields. The logic dictates the
role of the template, data entry or display. It's also then very simple
to create a display for cellphones, just create a different html
template. I've tried to follow the MVC (Model View Controller) design
pattern concept, which has worked very well for me.
Hope that helps.
On Mar 8, 2005, at 6:11 AM, Vinayakam Murugan wrote:
Hi
I have always felt for reasons for cleanliness and clarity, it is
better to have the validation and insert / update statements in a
seperate file rather than have it in the same script.
Case 1
----------
//file:form.php
if $_POST
then validate
Insert or update on success
else
if $_GET['primarykey'] then
show form for editing
else
show form for adding
fi
<form action="form.php" method=post>
Show form
</form>
Case 2
----------
//file:form1.php
if $_GET['primarykey'] then
show form for editing
else
show form for adding
fi
<form action="formvalidate.php" method=post>
Show form
</form>
However in the second case, in case of an error, displaying the data
becomes an issue.
Any recommended ways for server side validation
--
Warm Regards
~~~~~~~~~~~~
Vinayak
--
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 ---
Hello Steve,
I tried this on my own servers and after replacing "<OUR FTP SERVER>"
with $ftp_server it works perfectly, all ASCII files get uploaded the
way they should with the correct filenames.
Do you get any errors? (add error_reporting(E_ALL); above the login
vars to show them all)
--- End Message ---
--- Begin Message ---
Franklin van de Meent wrote:
> Hello Steve,
>
> I tried this on my own servers and after replacing "<OUR FTP SERVER>"
> with $ftp_server it works perfectly, all ASCII files get uploaded the
> way they should with the correct filenames.
>
> Do you get any errors? (add error_reporting(E_ALL); above the login
> vars to show them all)
Hi
I got a direct email reply yesterday which didn't show up on this list.
Basically I needed to replace
if (ftp_put($c, $ftp_server, $tmp_file, FTP_ASCII)){
with
if (ftp_put($c, $_FILES['ftp_f']['name'], $tmp_file, FTP_ASCII)){
and it worked.
The <OUR FTP SERVER> was just a suggested meaning for the url which is
actually in there.
Thanks for the help
Steve
--- End Message ---
--- Begin Message ---
On Mon, 07 Mar 2005 19:19:24 -0600, Greg Dotts
<[EMAIL PROTECTED]> wrote:
> Sure enough Kirk! That was it. Seems strange that you can set a
> name/value pair on the <form> tag, but they aren't used. Guess they
> were just kidding ;-)
The name attribute is used in javascript, for example when you are
changing a field value: document.formname.fieldname.value = 'foo';
The value attribute does not exist for the form tag, go to
http://www.w3schools.com/tags/tag_form.asp for a list of allowed
attributes
--- End Message ---
--- Begin Message ---
Franklin van de Meent wrote:
On Mon, 07 Mar 2005 19:19:24 -0600, Greg Dotts
<[EMAIL PROTECTED]> wrote:
Sure enough Kirk! That was it. Seems strange that you can set a
name/value pair on the <form> tag, but they aren't used. Guess they
were just kidding ;-)
The name attribute is used in javascript, for example when you are
changing a field value: document.formname.fieldname.value = 'foo';
which is a really crap way of referencing forms - besides given that a
form is a unique entity its better to reference it by id IHMO. in a perfect
world you could just use document.getElementById() and be done with it.
The value attribute does not exist for the form tag, go to
http://www.w3schools.com/tags/tag_form.asp for a list of allowed
attributes
--- End Message ---
--- Begin Message ---
Hi,
This is quite a very basic question, but i think the code following my
signature should work.
Instead, i get a
"Warning: Cannot modify header information - headers already sent by
(output started at /home/vhosts/dte/cv/register_action.php:10) in
/home/vhosts/dte/cv/register_action.php on line 12"
and no redirection :(
How can i solve this ?
Any help would be apreciated.
Warm Regards,
Mário Gamito
<?php
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$sub_domain = explode (".", $hostname);
if ($sub_domain[1] != 'dte') {
echo"
<script language=\"JavaScript\">
window.open (\"http://www.google.com\", \"mywindow\", \"status=1,
toolbar=0, resizable=0,
width=200, height=200\");
</script>";
}
header("Location: http://www.dte.ua.pt/cv/");
?>
<HTML>
<HEAD>
<TITLE>Gestão de currículos do DDTE</TITLE>
(...)
--- End Message ---
--- Begin Message ---
MÃrio Gamito wrote:
> Hi,
>
> This is quite a very basic question, but i think the code following my
> signature should work.
> Instead, i get a
> "Warning: Cannot modify header information - headers already sent by
> (output started at /home/vhosts/dte/cv/register_action.php:10) in
> /home/vhosts/dte/cv/register_action.php on line 12"
>
> and no redirection :(
>
> How can i solve this ?
> Any help would be apreciated.
>
> Warm Regards,
> MÃrio Gamito
>
> <?php
>
> $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
> $sub_domain = explode (".", $hostname);
> if ($sub_domain[1] != 'dte') {
> echo"
> <script language=\"JavaScript\">
> window.open (\"http://www.google.com\", \"mywindow\", \"status=1,
> toolbar=0, resizable=0,
> width=200, height=200\");
> </script>";
> }
> header("Location: http://www.dte.ua.pt/cv/");
the answer is in the question. You cannot send the header() function, as you
have already output some text to the browser.
Move the header() call above the echo call, and it should work.
btw: you should have at least "<html><head></head><body></body></html>" for
any HTML document.
--
kae verens
http://verens.com/
--- End Message ---
--- Begin Message ---
Hello Mário,
Tuesday, March 8, 2005, 8:18:34 AM, you wrote:
M> How can i solve this ?
M> Any help would be apreciated.
Because you're outputting javascript to the browser before doing the
redirection. You can't output *anything* to the browser before a
redirect.
M> echo"
M> <script language=\"JavaScript\">
M> window.open (\"http://www.google.com\", \"mywindow\", \"status=1,
M> toolbar=0, resizable=0,
M> width=200, height=200\");
M> </script>";
You output the above, then doing the below won't work.
M> header("Location: http://www.dte.ua.pt/cv/");
--
Leif (TB lists moderator and fellow end user).
Using The Bat! 3.0.2.3 Rush under Windows XP 5.1
Build 2600 Service Pack 2 on a Pentium 4 2GHz with 512MB
--- End Message ---
--- Begin Message ---
Mário Gamito wrote:
Hi,
This is quite a very basic question, but i think the code following my
signature should work.
Instead, i get a
"Warning: Cannot modify header information - headers already sent by
(output started at /home/vhosts/dte/cv/register_action.php:10) in
/home/vhosts/dte/cv/register_action.php on line 12"
and no redirection :(
How can i solve this ?
Any help would be apreciated.
you've already been told why this won't work. I just add that in order
to open a popup to 'google' (or where ever) and 'redirect' the page to
http://www.dte.ua.pt/cv/ you are going to have to 'redirect' using javascript
or a 'meta refresh' ... you can't redirect with php in this scenario?
(at least I can't think how - and I have already proved my fallibility to
the list :-) - maybe there is a way, anybody?)
Mario, maybe spend a little more time with the manual? - the problem you
had/have
is described in depth... the manual is you best friend (ok google is just _best_
friend but when it comes to php the manual comes a close 2nd).
goodluck :-)
Warm Regards,
Mário Gamito
<?php
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$sub_domain = explode (".", $hostname);
if ($sub_domain[1] != 'dte') {
echo"
<script language=\"JavaScript\">
window.open (\"http://www.google.com\", \"mywindow\", \"status=1,
toolbar=0, resizable=0,
width=200, height=200\");
maybe adding this?:
window.location = 'http://www.dte.ua.pt/cv/';
</script>";
}
add remove the call to header:
header("Location: http://www.dte.ua.pt/cv/");
?>
<HTML>
<HEAD>
<TITLE>Gestão de currículos do DDTE</TITLE>
(...)
--- End Message ---
--- Begin Message ---
Mario,
>From the PHP Manual:
"Remember that header() must be called before any actual output is sent, either
by normal HTML tags, blank lines in a file, or from PHP. It is a very common
error to read code with include(), or require(), functions, or another file
access function, and have spaces or empty lines that are output before header()
is called. The same problem exists when using a single PHP/HTML file."
You cannot have anything being output to the browser before the header line.
See:
http://uk.php.net/manual/en/function.header.php
HTH,
Michael Egan
> -----Original Message-----
> From: Mário Gamito [mailto:[EMAIL PROTECTED]
> Sent: 08 March 2005 15:19
> To: php-general@lists.php.net
> Subject: [PHP] Quite a basic question[Scanned]
>
>
> Hi,
>
> This is quite a very basic question, but i think the code
> following my
> signature should work.
> Instead, i get a
> "Warning: Cannot modify header information - headers already sent by
> (output started at /home/vhosts/dte/cv/register_action.php:10) in
> /home/vhosts/dte/cv/register_action.php on line 12"
>
> and no redirection :(
>
> How can i solve this ?
> Any help would be apreciated.
>
> Warm Regards,
> Mário Gamito
>
> <?php
>
> $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
> $sub_domain = explode (".", $hostname);
> if ($sub_domain[1] != 'dte') {
> echo"
> <script language=\"JavaScript\">
> window.open (\"http://www.google.com\", \"mywindow\",
> \"status=1,
> toolbar=0, resizable=0,
> width=200, height=200\");
> </script>";
> }
> header("Location: http://www.dte.ua.pt/cv/");
> ?>
>
> <HTML>
> <HEAD>
> <TITLE>Gestão de currículos do DDTE</TITLE>
> (...)
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
The information contained in this email (and in any attachments sent with it)
is confidential. It is intended for the addressee only. Access to this email by
anyone else is unintended and unauthorized.
If you are not the original addressee, 3tc asks you to please maintain
confidentiality. If you have received this email in error please notify 3tc
immediately by replying to it, then destroy any copies and delete it from your
computer system.
Any use, dissemination, forwarding, printing or copying of this email by anyone
except the addressee in the normal course of his/her business, is strictly
prohibited. 3tc owns the copyright in this email and any document created by us
and assert the right to be identified as the author of it. Copyright has not
been transferred to the addressee.
We protect our systems with Sophos Anti-virus -
www.sophos.com
--- End Message ---
--- Begin Message ---
I sure I'm not the only one on this list that reads php-internals
after reading the thread entitled:
""
I'm wondering if anyone here has _ever_ used the <script> tags
to enclose php code? e.g.:
<script language="php">
echo "testing 123";
</script>
or if many were even aware of the possibility?
IMHO it rather pointless and its should be avoided at all cost,
but anyway it probably makes someone happy so no harm done :-).
rgds,
Jochem
--- End Message ---
--- Begin Message ---
On Tue, 2005-03-08 at 10:55, Jochem Maas wrote:
> I sure I'm not the only one on this list that reads php-internals
> after reading the thread entitled:
>
> ""
>
> I'm wondering if anyone here has _ever_ used the <script> tags
> to enclose php code? e.g.:
>
>
> <script language="php">
>
> echo "testing 123";
>
> </script>
My template compiler outputs the script tags exclusively since they are
XML compliant.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
On Tue, 2005-03-08 at 10:55, Jochem Maas wrote:
I sure I'm not the only one on this list that reads php-internals
after reading the thread entitled:
""
I'm wondering if anyone here has _ever_ used the <script> tags
to enclose php code? e.g.:
<script language="php">
echo "testing 123";
</script>
My template compiler outputs the script tags exclusively since they are
XML compliant.
Cheers,
Rob.
never *ever* used em here... I've always been using <? or <?php (mostly
the later)
--- End Message ---
--- Begin Message ---
Jochem Maas wrote:
> I sure I'm not the only one on this list that reads php-internals
> after reading the thread entitled:
>
> ""
>
> I'm wondering if anyone here has _ever_ used the <script> tags
> to enclose php code? e.g.:
>
>
> <script language="php">
>
> echo "testing 123";
>
> </script>
Only in talks/presentations, as far as I can recall...
I think it maybe was useful for some REALLY lame HTML editors -- which may
no longer be on the market, at this point... This is really more of a
"guess" than a "memory".
I can certainly imagine that in those early head days of HTML coding, some
then-popular HTML editor didn't grok the maybe-not-quite-kosher <?php and
<? or even <% tags, and did something "bad" with them. Maybe the HTML spec
allows for *ANY* character, but I could see a lot of folks expecting only
alphanumber, or even only alphabetic, in the HTML syntax, regardless of
the spec.
> or if many were even aware of the possibility?
> IMHO it rather pointless and its should be avoided at all cost,
> but anyway it probably makes someone happy so no harm done :-).
I doubt that it's a whole lot of effort on the part of the PHP parser to
support it, so unless there's a strong reason to deprecate it, leave it
alone. There are much more important things to work on, I should think.
'Course, I'm not the one doing that work, so there ya go.
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
On Tue, 2005-03-08 at 11:08, M. Sokolewicz wrote:
> Robert Cummings wrote:
>
> > On Tue, 2005-03-08 at 10:55, Jochem Maas wrote:
> >
> >>I sure I'm not the only one on this list that reads php-internals
> >>after reading the thread entitled:
> >>
> >>""
> >>
> >>I'm wondering if anyone here has _ever_ used the <script> tags
> >>to enclose php code? e.g.:
> >>
> >>
> >><script language="php">
> >>
> >>echo "testing 123";
> >>
> >></script>
> >
> >
> > My template compiler outputs the script tags exclusively since they are
> > XML compliant.
> >
> > Cheers,
> > Rob.
> never *ever* used em here... I've always been using <? or <?php (mostly
> the later)
Not really a big deal on my end, since they're just used in the template
output it's a a couple lines to be changed here and there and then the
templates would compile to <?php.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
Hi
Does any one have a good (fairly advanced) PHP book which has detailed
explanations of LDAP and FTP?
I allready have two o'rielly books (Programming PHP & PHP Cookbook) and
these do cover the topics briefly, but if any one has read a book with more
intensive explanations, please recommend...
Also, I know the php.net website gives good examples,but a book would be
nice...
Thanks
Steve
--- End Message ---
--- Begin Message ---
Ross Hulford wrote:
> Is it possible to call a named anchor from within a php script?? I need my
> page to go to the point in the page where the form is and bypass all the
> rubbish.
If you are giving the user a link to that page, you can simply give them
the named anchor in the link:
echo "<a href=\"http://example.com/index.htm#goodstuff\">here</a>";
If you want to use PHP to read that page, and get only the HTML starting
at the anchor, you want http://php.net/strpos or http://php.net/explode to
tear apart the HTML at the anchor point.
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---