Re: [PHP] ampersands in href's

2005-06-04 Thread Leon Poon
The simplest way to make sure everything work well regardless of what the 
values are:


?
$url = somepage.php?var1=.urlencode($var1).var2=.urlencode($var2);
echo a href=\.htmlspecialchars($url).\;
?

htmlspecialchars() changes characters '', '', ''', '', '' into the HTML 
equivilant. And yup, you should do this for all *ML pages as long as the 
thing being printed is not part of the mark-up syntax.




Jack Jackson wrote:

Rory Browne wrote:

On 6/4/05, Jack Jackson [EMAIL PROTECTED] wrote:


Hi, Rory

Rory Browne wrote:


I think you have the idea. The 's are used to seperate the various
variables. If you want to set $p to something like 'Tom  Jerry' then
personally I'd do something like:

?php

$p = Tom  Jerry;
$s = Cat  Mouse;
printf(a href='{$_SERVER['PHP_SELF']}?p=%ss=%s, urlencode($p),
urlencode($s));

?


That's nice. To get more specific (because my code varies a bit from
yours and I don't wanna mess up the ) and ' and  s:
$p and $c are actually row ID numbers so up to 3 digits. So for example 
if


$p=1
$c=32

I was wanting to see a URL of

http://foo.com?r=1c=32



In that case, you can simply echo them out, once you're sure that $r,
and $c are actually integers.


I forgot to mention that above I did $r = intval($_GET[r])

!



Thanks, everyone!


echo a href='http://foo.com?r=$rc=$c'whatever/a

if not(sure they're integers, you could always
printf(a href=\http://foo.com?r=%dc=%d\;whatever/a, $r, $c);

Alternatively you could $r = (int)$r;

or echo a href='http://foo.com?r=; . (int)$r . c= . (int)$c .
'whatever/a;

There's more than one way to do it...


so was this the way to go?


//Make a thumbnail table of contents to display in the left sidebar

while ($sidebar = mysql_fetch_assoc($sidebar_result)) {
   $sidebar_thumbnails[] = a class='img-link'
href='{$_SERVER['PHP_SELF']}?p=%pc={$sidebar['art_id']}, urlencode($p)'
title=\{$sidebar['art_title']}\img class='sidebar-img'
src='{$image_dir}{$sidebar['art_thumbnail']}' width='50' height='60'
border='0' alt=\{$sidebar['art_title']}\ //a;
  }

?

Thanks in advance!




On 6/4/05, Jack Jackson [EMAIL PROTECTED] wrote:



Hi,

If I want to make a link to a URL which includes some GETs can I just 
do:


a href='{$_SERVER['PHP_SELF']}?p={$p}c={$s}' ... etc etc

or must I escape the ampersand somehow?

TIA,
--Jack

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







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








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




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



Re: [PHP] Re: 1 web site, 3 servers, 3 countries - best practises?

2005-04-22 Thread Leon Poon
I think he wants mirror, sort of...

I will do this if I were you:
Select the server wif the most bandwidth. Call this the master.
The other 2 are slaves.
To sync files:
==
Enable network file system server on the 2 slaves. Export the htdocs 
directories.

Setup the master to mount the exports.
Setup file monitoring tools (maybe fam?) on the master to copy new files to 
the mounted slave directories when alteration of files in htdocs is 
detected.

DO NOT instead mount exports of the master's htdocs on the slaves otherwise 
the slaves will be very slow in serving out files.

Of course, you have to enable security - things like IP 
restriction/encryption on the NFS.

To sync database:
=
Use database slaving tools?
If you are using MySQL, see 
http://mysql.hjc.edu.sg/doc/mysql/en/replication-intro.html. All updates 
from ANY server must be done at the master though.

Or you can just host the SQL server at the master. All queries goes to the 
master.


Hope this helps!

-Leon

- Original Message - 
From: Drewcore [EMAIL PROTECTED]
To: php php-general@lists.php.net
Sent: Friday, April 22, 2005 11:45 AM
Subject: Re: [PHP] Re: 1 web site, 3 servers, 3 countries - best practises?


well, i guess it all depends...
are you talking about having one server in south america that acts as
your database server, one server in asia that's your web server, and
then another server in north america that servers some other task?
or are you talking about having a localized database, http, etc,
server for each location (read: continent/country)?
the first is easy... it'll all just mesh... the second is more difficult.
drew
--
dc .. drewcore.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

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


Re: [PHP] Forms on PHP

2005-01-11 Thread Leon Poon
Refer to the following line numbers:
01  ?php
02  // Start of PHP code - Extract values from form.
03  /* Other values read */
04  $n=$_POST['n'];
05 
06  // Pass the data from the form to lightcurve_csharp
07  $command=./lightcurve_csharp $a $i $e $lomega $bomega $lambda $n;
08  $result=`$command`;
09 
10  $form_submitted=$_POST['form_sumbitted'];
11  if (isset($form_submitted)) {
12 if ($form_submitted) {
13 echo 'The form has been submittedbr';
14 unset($form_submitted);
15 }
16  } else
17 echo 'The form has not been submittedbr';
When the user first load the page, no data was posted. So there was no 
$_POST['form_sumbitted'] available. Line 10 will cause $form_submitted to 
contain the NULL value (I think). $form_submitted will evaluate to FALSE at 
line 12. Thus it will not display any message.

By the way, by doing line 10, $form_submitted would have been set regardless 
whether there is $_POST['form_sumbitted'], and line 11 will evaluate to TRUE 
always. Thus you will never ever see the 'form not been submitted' message.

Anyway, when you posted for the first time, $_POST['form_sumbitted'] is 
available. The 'The form has been submittedbr' message will be printed. 
After that, when you press Reload button on the browser, the post data will 
once again be sent from the user. (This is the behaviour of reloading a 
posted page. In Internet Explorer there should be a message dialog box 
asking the user whether to resend form data in order to refresh.) Reposting 
the data during the reload means that there will be 
$_POST['form_sumbitted'], thus once again the 'form hass been submitted' 
message.

In order to prevent this from happening, you should do a header('Location: 
success-page.php') on a successful submit. This is so that at the redirected 
page, the user would not have resent data even if he press the Reload 
button.

Hope this helps

-Leon 

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


Re: [PHP] sorting mysql results

2005-01-10 Thread Leon Poon
Sort when querying from database:
SELECT name, type FROM some_table ORDER BY type ASC, name ASC
- Original Message - 
From: Sebastian [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Tuesday, January 11, 2005 5:38 AM
Subject: [PHP] sorting mysql results


I have a list of rows in the database and i would like to sort them in two
categories.
example,
echo $row['name'] . '-' . $row['type'];
// output:
row 1 - files
row 2 - files
row 3 - music
row 4 - files
I would like this output:
files
--
row 1 - files
row 2 - files
row 4 - files
music
---
row 3 - music
if the $row['type'] is music i want to output an hr and the results 
below
it but below the files results.. makes sense?
i thought i remember doing this once using a dummy var but cant remember
how. i guess i could always run a second query, but would like to avoid
that.

thanks for any help.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

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


Re: [PHP] PHP form POST question

2005-01-09 Thread Leon Poon
When you access /foo, the server will redirect the client to /foo/ (because 
it is a directory). At the redirected page, the post data will not be sent 
again by the browser thus there are no _POST values.

Try using action=/foo/. That may work.

- Original Message - 
From: James (IFMS) [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Monday, January 10, 2005 10:04 AM
Subject: [PHP] PHP form POST question


I just narrowed something down about forms and POST and would like 
education. In the following scenarios, all work except #4. $_POST is null. 
Why is that?

Setup:
1) Running on localhost
2) /foo/index.php has the following:
   ? var_dump($_POST); var_dump($_GET); ?
3) /index.php contends vary per scenario (below)
Running RHEL 3, all updates (PHP 4.3.2).
SCENARIO 1:
/index.php contains the following:
form method=get action=/foo/index.php
input name=foobutton type=submit
/form
In this case in /foo/index.php $_GET has the right value, i.e.
array('foobutton' = '');
SCENARIO 2:
/index.php contains the following:
form method=get action=/foo
input name=foobutton type=submit
/form
In this case in /foo/index.php $_GET has the right value, i.e.
array('foobutton' = '');
SCENARIO 3:
/index.php contains the following:
form method=post action=/foo/index.php
input name=foobutton type=submit
/form
In this case in /foo/index.php $_POST has the right value, i.e.
array('foobutton' = '');
SCENARIO 4:
/index.php contains the following:
form method=post action=/foo
input name=foobutton type=submit
/form
In this case in /foo/index.php $_POST is NULL.
HUH? Why is $_POST empty? Is Apache doing something to kill the form's 
post information when it has to resolve /foo to /foo/index.php?

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

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