Re: [PHP] explode? (table field to a variable of same name)

2002-02-19 Thread Simon Willison

First grab an associative array of the variables from the database with 
mysql_fetch_array()

Then use extract($array); to extract all of the variables in the array 
to the symbol table:

www.php.net/extract

Simon

Baloo :0) wrote:

>How can I assign automatically all fields of a database to a variable of
>the same name?
>
>Instead of having to manually do
>$user_id=$row["user_id"];
>etc
>
>Then how could I know the number of fields in the table so I can do a
>loop to print them all in html?
>
>In advance, thanks for your help.
>
>Alfredo
>
>




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




Re: [PHP] Help for passing variable to all pages

2002-02-20 Thread Simon Willison

>
>
>test link
>
You can't pass resource types like database connection IDs in URLs as 
they are only relevant for the instance of the script in which they are 
created. The same goes for things like file identifiers (from fopen) and 
other stuff like that.

Simon



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




Re: [PHP] Retaining data across multiple sites

2002-02-20 Thread Simon Willison

Ben Sinclair wrote:

>I want to retain some data across my sites, which have different domain names.
>I can't use cookies because they rely on the domain name, and I'd rather not
>pass the information on every link Any suggestions?
>
I've been thinking about this recently and here's what I came up with:

Have a domain or subdomain dedicated souly to user sessions, for 
example: session.yourdomain.com

Whenever a user visits a page on ANY of your domains (currentdomain.com 
in this example), check if they have a cookie set. If they don't:
1. Create a session for that user with a unique session ID
2. Send them a page which includes a single pixel gif image looking like 
this:
   http://session.yourdomain.com/pixel.php?s=zs9s0a8fs6fudisdfsf8dfdfsfs&domain=currentdomain.com";
 
width=1 height=1>
( Remember - session.yourdomain.com has access to ALL cookies set for 
session.yourdomain.com )
3. session.yourdomain.com CHECKS to see if this user has a cookie set. 
If they DO then they are already
known to session.yourdomain.com - session.yourdomain.com records the 
fact that this user is logged on to
currentdomain.com as zs9s0a8fs6fudisdfsf8dfdfsfs in a shared database.
4. If session.yourdomain.com does NOT find a cookie then it means this 
is a new user who is not "known" to the system yet.
session.yourdomain.com creates a cookie recording the user, and 
notes that the user is also logged in to currentdomain.com with
whatever session ID was set over there.

This is all pretty complicated but the end result is that the 
session.yourdomain.com domain knows about every user, and a shared 
database (accessible by all of your domains) maintains a record of each 
unique user (as according to the session.yourdomain.com cookie) and what 
their session is for each of the different domains.

Final note: http://session.yourdomain.com/pixel.php needs to actually 
send a pixel to the client browser - this can be done with the following 
code in the zend code library: http://www.zend.com/codex.php?id=193&single=1

Cheers,

Simon



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




Re: [PHP] text files instead of mySQL

2002-02-20 Thread Simon Willison

M.E. Suliman wrote

> Is it possible to convert a PHP script that writes and pulls data from a
>mySQL database to use text files / database instead. 
>
Yes it is but you could have a job on your hands depending on the 
complexity of the script. Personally I favour PHP's serialization 
capabilities for flat file work - you can take pretty much any object or 
array (or an array of objects, you can nest them as much as you like) 
and use serialize() to turn it into a string. You can then save the 
string in a text file, and later on re-read it and unserialize it to get 
your original data structure back.

However, if the script you are investigating makes heavy use of SQL join 
syntax you could have a very nasty job on your hands coming up with data 
structures that can be "queried" in the same way without performance 
becoming an issue.

Simon



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




Re: [PHP] sending form values in http header?

2002-02-21 Thread Simon Willison

I have no idea why your code isn't working, but if you are interested 
there is a class called Snoopy which can do exactly qhat you are 
attempting (posting values to a form, as well as grabbing pages from 
URLs and other neat tricks):

http://snoopy.sourceforge.net/

marcbey wrote:

>is it possible to send variables in the header to the next script with
>an form?
>
>script:
>
>$ip = "192.168.0.90";
>$fp = fsockopen ( $ip, 80, $errno, $errstr, 30);
>$header  ="POST /tests/form2.php HTTP/1.1\r\n";
>$header .="Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
>application/vnd.ms-excel, application/msword, */*\r\n";
>$header .="Referer: http://192.168.0.90/tests/form2.php?\r\n";;
>$header .="Accept-Language: de\r\n";
>$header .="Content-Type: application/x-www-form-urlencoded\r\n";
>$header .="Accept-Encoding: gzip, deflate\r\n";
>$header .="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
>5.1)\r\n";
>$header .="Host: 192.168.0.90\r\n";
>$header .="Content-Length: 9\r\n";
>$header .="Connection: Keep-Alive\r\n";
>$header .="Cache-Control: no-cache\r\n\r\n";
>
>$header ."user=marc";
>
>fputs ( $fp, $header, strlen( $header ) );
>
>while ( !feof( $fp ) )
>{
>  echo fgets( $fp,128 );
>}
>
>fclose($fp)
>
>and shoud connect to the script  and sending the variable user
>
>
>
>if ( $HTTP_POST_VARS["user"] == "marc" )
>{
> echo "http_user ist marc";
>}
>else
>{
> echo "no user";
>}
>?>
>
>  
>  
>
>
>
>
>it doesent work, but why?
>
>
>
>--
>---
>magic garden GmbH - Agentur für Informationsarchitektur
>
>Hermannstr. 15 - 70178 Stuttgart (Am Feuersee)
>
>www.magic-garden.de ¦ [EMAIL PROTECTED]
>
>Tel. (07 11) 619 57-42 ¦ Fax (07 11) 615 01 38
>
>
>
>




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




Re: [PHP] Email Verification

2002-02-24 Thread Simon Willison

Steven Walker wrote:

> Does anybody know any good ways (or available code) for verifying 
> email addresses?
>
> Checking syntax is not enough.. I'd like to actually be able to test 
> whether the email address exists.

The only way to be sure is to send them an e-mail with a link or 
validation code that they must use to prove the address exists - or if 
it's for an account just tell them that the (random) password for their 
account will be e-mailed to the address they provide.



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




Re: [PHP] Substr and HTML tags - Problem...

2002-02-25 Thread Simon Willison

Sascha Ragtschaa wrote

>I need to limit a teaser-text via substr($teaser,0,100). The Problem I now
>have is, if the last 4 string chars are a html tag like  and this tag
>will be cut by the substr to something like that: webpage...
>
>How can I avoid that the html tags are cut by the substr function? Is there
>a way to make the function know, that it has to leave html tags uncut??
>
Personally when I'm doing teasers I strip all HTML from the content 
before using substr:

$teaser = strip_tags($content);
$teaser = substr($teaser, 0, 100);
$teaser .= '...'; // Nice touch to have a '...' on the end :)

I can't think of a way of keeping HTML tags but ensuring you don't cut 
off half way through one - I suppose you could do it by scanning along 
the string character by character keeping track ofwhether or not you 
have encountered a < without a matching >, then if you get to the end 
and you are half way through a tag running back to the start of the tag 
and deleting from there.


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




Re: [PHP] Converting arrays

2002-02-25 Thread Simon Willison

Gary wrote:

> Hi All,
>  I am not too bad at building arrays in php but I need to convert a 
> javascript form into php. How wuld I conver the small snippit here?
>
> var d = new Array(), l = new Array();
> l[0] = new Array(1, -360, 1, "CHICAGO");
> l[1] = new Array(1, -420, 1, "EDMONTON");
> l[2] = new Array(1, -540, 1, "FAIRBANKS");
>
> TIA
> Gary 



The code won't be much use without knowing how it will be used though.


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




Re: [PHP] Is there a way to put a scroll in a table ???

2002-02-26 Thread Simon Willison

J.F.Kishor wrote:

>1. Is there any other solution to solve it out ?
>2. Is there a way to put a scroll in a table ?
>
>I tried using layers and its working fine in Internet explorer, and in
>Netscape the scroll does'nt work.
>
Try using iframes - they are supported in IE, Netscape 6 / Mozilla and 
Opera - however they won't work in Netscape 4.


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




Re: [PHP] extending a class?

2002-02-26 Thread Simon Willison

Nick Wilson wrote:

>So I was thinking:
>
>$form=new form('dk')
>
>Would extend the class to include all the dk language routines and
>
>$form=new form('en')
>
>Would do likewise for english.
>
You can do this with encapsulation. Your "form" object would actually be 
a wrapper around an encapsulated object which does all of the actual 
work. When you call the constructer it specifies which object is 
encapsulated by the wrapper. For example:

class FormBase {
// Contains any methods shared by both formDK and formEN
}

class FormDK extends FormBase {
// The class for DK language support
}

class FormEN extends FormBase {
// The class for EN language support
}

class Form {
var $formObject;
function form($language) {
if ($language == 'dk') {
$this->formObject = new FormDK;
} else {
$this->formObject = new FormEN;
}
}
// The other methods in this class simply "pass through" to 
$this->formObject - e.g
function doSomething($variable) {
return $this->formObject->doSomething($variable);
}
}

Another different of doing the same kind of thing would be to use an 
"object factory" as seen in the PEAR DB abstraction layer. This works by 
having a static class method (i.e a method that can be called without 
creating an instance of the class first) which returns a different 
object depending on what arguments you use. Here is an example (it 
expects FormEN and FormDK to have been defined as above):

class Form {
function getFormObject($language) {
if ($language == 'dk') {
return new FormDK;
} else {
return new FormEN;
}
}

You can now create you object with the following code:

$form = Form::getFormObject('en');
or
$form = Form::getFormObject('dk');



Cheers,

Simon Willison



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




Re: [PHP] CGI

2002-02-26 Thread Simon Willison

bvr wrote:

>Please note that plain this:
>
>>or 
>>>if (action=="cgi") echo `./cgi-bin/cgiscripts/${scripts} 2&>1`;
>>?>
>>
>is not a good idea, because it allows a visitor to run arbitrary
>commands on your server.
>
>bvr.
>
If you still want to use that method have a look at these two functions 
which can be used to make user input "safe" for use on a command line:

http://www.php.net/manual/en/function.escapeshellarg.php
http://www.php.net/manual/en/function.escapeshellcmd.php

Simon


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




Re: [PHP] CGI

2002-02-26 Thread Simon Willison

bvr wrote:

>Still this wouldn't prevent a visitor from passing something like :
>
>../../../../bin/cat /etc/passwd
>
>bvr.
>
Erk good point - I should have mentioned that it's a very good idea to 
run basename() on user input as well as this will knock off any 
directory paths they may have attempted to add. Alternatively run a 
regular expression so ensure their input consists only of harmless 
characters (for example[a-zA-Z0-9] )

http://www.php.net/basename

>>>if (action=="cgi") echo `./cgi-bin/cgiscripts/${scripts} 2&>1`;
>>>
>>If you still want to use that method have a look at these two functions 
>>which can be used to make user input "safe" for use on a command line:
>>
>>http://www.php.net/manual/en/function.escapeshellarg.php
>>http://www.php.net/manual/en/function.escapeshellcmd.php
>>
>>Simon
>>
>
>
>
>




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




Re: [PHP] class effeciency

2002-02-28 Thread Simon Willison

Nick Wilson wrote:

>Is there a better way? It just seems like overkill to include 6-700
>lines of methods /twice/
>
Use inheritance. Define a "base" class with all of the methods in it. 
Then define the two other classes to extend this base class, meaning 
they will have all of the methods you have defined but can implement 
their own variables:

http://www.php.net/manual/en/keyword.extends.php



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




Re: [PHP] Hi

2002-02-28 Thread Simon Willison

dharmavatar wrote:

>Hi everybody,
>I am new in this group,so could any one tell me how to start learn PHP?
>I had install PHP in IIS so where is good place to start.
>Thanks in advance.
>Regards
>Dharmavatar
>
www.devshed.com has some excellent beginners tutorials in their PHP 
section (the PHP 101 series). Also check out this post I made on a web 
forum a while ago, it has a large number of beginners resources listed:

http://www.sitepointforums.com/showthread.php?s=&threadid=18699


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




Re: [PHP] d: Security problem with PHP

2002-02-28 Thread Simon Willison

It's a new problem - www.php.net has a fix available though.

Nick Wilson (E-mail) wrote:

>-BEGIN PGP SIGNED MESSAGE-
>Hash: SHA1
>
>
>Hi everyone, a potential client just sent me this. Is it an old problem?
>or a new one?
>
>- --begin forwarded worrier---
>
>Hi Nick
>
>Did you mention that you use PHP?
>
>I subscribe to a photo gallery site and they stopped uploads due to the
>following problem.
>
>"Feb 27, 2002, 10:11 PM] Emergency Security Update 
>   Within the last 24 hours, details of a vulnerability in PHP which
>can be exploited remotely have been made public. The vulnerability allows
>any attacker to send a malformed POST request to a PHP-enabled Web server in
>a manner that will allow remote access as the user running the Web server
>processes. In the general case on our servers, this means the "nobody" user.
>
>   Although the "nobody" user has limited privileges, any such access
>is a potential launching point for other nefarious activities. Moreover,
>some customers may be using a PHP with cgiwrap, meaning that their actual
>account is vulnerable because of this weakness. 
>   We are working to deploy and test a new build of Apache that will
>include PHP 4.1.2, the version created specifically to address this
>vulnerability. However, this requires careful testing and can not be
>deployed immediately. In the interim, therefore, we have disabled the file
>upload feature of PHP on our servers. This is the quick workaround
>recommended by PHP developers and the CERT advisory. We are also contacting
>all customers who are using custom PHP builds, and recommending that they
>take similar steps until such time as they can deploy PHP 4.1.2. 
>   We understand that this change interferes with functionality for
>some customer sites. We will have the new Apache+PHP build in place as soon
>as possible, and will post a further notice at that time. We ask that our
>customers respect our insistence on treating security vulnerabilities as
>problems no less critical than system outages. 
>   For more information, please visit:
>   
>    
>
>regards
>
>
>Steve Pickering
>
>SimCorp Financial Training A/S
>Indiakaj 1, 2100 Copenhagen O
>Denmark
>Phone: +45 35 44 68 00, Direct: +45 35 44 68 17, Mobile: +45 40 86 41 13,
>Fax: +45 35 44 68 11
>mailto:[EMAIL PROTECTED] Homepage: http://www.simcorp.com
>
>
>
>This message, and any associated files, is intended only for the use of the
>individual or entity to which it is addressed and may contain information
>that is confidential, privileged, subject to copyright or which constitutes
>a trade secret. If you are not the intended recipient you are hereby
>notified that any dissemination, copying, or distribution of this message or
>files associated with this message is strictly prohibited. If you have
>received this message in error, please notify us immediately or forward this
>message immediately to [EMAIL PROTECTED] Thank You
>
>- - End forwarded message -
>
>- -- 
>- ---
> www.explodingnet.com   |Projects, Forums and
>+Articles for website owners 
>- -- Nick Wilson -- |and designers.
>
>-BEGIN PGP SIGNATURE-
>Version: GnuPG v1.0.6 (GNU/Linux)
>
>iD8DBQE8fgF7HpvrrTa6L5oRAlz3AJ9O0FG+5JQrkSFfRYrD+NuKnUnkUQCdFkSM
>ZpnF/f9HI/AtHeZAV7hPsPk=
>=3HmD
>-END PGP SIGNATURE-
>




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




Re: [PHP] Array or SQL?

2002-02-28 Thread Simon Willison

Here is a way of doing it with arrays - I don't know enough advanced 
mySQL syntax to see how it could be done just in mySQL:

$resultsArray = array();

while ($results = mysql_fetch_array($article_query))
{
$art_name = $results["article_name"];
$art_text = $results["article_text"];
$q_count = substr_count($art_text, "$q");
$resultsArray[$q_count] = $art_text;
}

// $resultsArray is now a 2D array of results - order it

arsort($resultsArray);
reset($resultsArray);

// Now display the results

$list = '';
while (list($name, $score) = each($resultsArray))
{
$list .= "$name - score $score\n";
}
$list .= '';

echo $list;

Kristjan Kanarik wrote:

>Hi,
>
>I've never had reason to get deeply into array functions, but now it is
>very likely needed. I'm working on a small search engine (to search
>text from articles) and I'm not sure wheter I will be able to complete it
>without any external help.
>
>Here is a snip of code:
>
> /* I'm using MySQL 3.23.37 together with 4.0.6 on a FreeBSD box */
>
> $article_query = mysql_query("select article_name, article_text from
>articles where article_name LIKE '%$q%'") or die (mysql_error());
> /* $q is the search query with a space added in front */
>
>while ($results = mysql_fetch_array($article_query))
>   {
>   $art_name = $results["article_name"];
>   $art_text = $results["article_text"];
>   $q_count = substr_count($art_text, "$q");
>   }
>
>
>
>
>What I'd like to do is to get the results displayed and ORDERED by q_count
>- this number shows how many times the search query accoures in the
>article text. Now, this could probably be done in two ways:
>
>1) redefining the SQL query to something like this:
>article_query =  mysql_query("select article_name, article_text from
>articles where article_name LIKE '%$q%' ORDER BY $q ACCOURANCE IN
>ARTICLE_TEXT DESC") or die (mysql_error());
>
>What I am not sure of is how to write the 'ORDER BY $q ACCOURANCE IN
>ARTICLE_TEXT DESC' part.
>
>2) building a two-dimensional array (one dimension is the $art_name and
>$art_text, another the $q_count), sort it by $q_count and then display the
>members of this array.
>
>
>I feel very uncomfortable both with array's and complicated SQL queries,
>therefore I wonder if somebody could show me the way? The solution letting
>MySQL to do the job is probably faster and therefore prefered... I guess.
>Or not?
>
>TIA,
>Kristjan
>
>P.S. Pls. CC me as well, I am only on the digest.
>


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




Re: [PHP] Where can I learn?

2002-02-28 Thread Simon Willison

Sean Kennedy wrote:

>I know the basic basics of PHP that I learned from the PHP 4 Bible book, but I 
>would like to learn ALOT more. I'm going to continue in my book, but does 
>anyone have a suggestion on where to learn more?
>
Read EVERY article in the archive of www.phpbuilder.com - it'll take a 
while but you'll learn a huge amount about PHP. www.zend.com and 
www.devshed.com also have some great articles for learning more about PHP.


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




Re: [PHP] if(isset($submit))

2002-02-28 Thread Simon Willison

jtjohnston wrote:

>I can't get this to work:
>if(isset($submit))
>
>with:
>
>src=\"next.gif\" border=\"0\" align=\"ABSCENTER\">
>
>I'm not coding correctly?
>
If you are testing for $submit a work around is to have a hidden field 
in your form that looks like this:



That way any tests for $submit will come up as true once the form has 
been submitted, but you can still use an image for the actual button.


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




Re: [PHP] Help me!!!Can I use PHP to send SMS message???

2002-02-28 Thread Simon Willison

hei wrote:

>Help me!!!Can I use PHP to send SMS message???If yes, how can I use it???
>
>
>(((Please e-mail the answer to me [EMAIL PROTECTED])))
>
One very cheeky way of doing this would be to sign up to one of the free 
SMS services on the web (such as lycos mobile) and set up a PHP script 
that can "pretend" to be a browser, log in to your account and post a 
message to the "send SMS" form. You could do this using something along 
the lines of CURL or Snoopy (I recommend  Snoopy as it doesn't require 
anything to be installed on your web server):

http://snoopy.sourceforge.net/

You would have to figure out how the authentication scheme for your 
chosen web-based SMS service works (most of them use cookies). The main 
disadvantage is that it's a bit of a dirty hack and it would stop 
working if the free web service went down or changed the way its 
authentication / SMS form worked. Free services also tend to limit you 
to a certain number of messages a day.

The professional alternative is to invest in some kind of web to SMS 
gateway, but I think that's quite an expensive option.


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




Re: [PHP] getting a files time and date.

2002-02-28 Thread Simon Willison

Philip J. Newman wrote:

>Is there any way that PHP can grab the time and date of a file ??
>
If you mean a file's last-access and last-modified date then yes, you 
need the stat() function:

www.php.net/stat

For example:

$stat = stat('file.txt'); 
$modified = date('l, F dS', $stat[9]);
$lastaccess = date('l, F dS', $stat[8]);




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




Re: [PHP] just wanna know

2002-02-28 Thread Simon Willison

eoghan wrote:

>whats the difference between
>print and echo ?
>
 From memory, print() is a function while echo is a language construct. 
The major difference is that you can use echo with a comma seperated 
list of arguments, while print requires you to concatenate strings. For 
example:

echo "hello ", "world";
print "hello "."world";

Of these two the echo command is more efficient. The print statement 
requires PHP to create a new string in memory and copy "hello " and 
"world" into it, then display that string. The echo command does not 
require the new string creation step - instead it sends "hello " to the 
browser, then sends "world" to the browser without needing to stick them 
together in memory first.

The difference in performance however is minimal to the point of being 
completely un-noticable.

I think that's the difference anyway :)

Simon



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




Re: [PHP] Variables containing HTML?

2002-02-28 Thread Simon Willison

Erik Price wrote:

>
> What's the difference between this and the serialize() function?
>
> Erik 

It solves a different problem to serialize(). serialize can take pretty 
much any PHP object / array / data structure and convert it into a 
string, but the resulting string will still need addslashes() applied to 
store it in a database and htmlspecialchars() for display in a hidden 
form field etc. The encode() function takes a PHP string and converts it 
into a "safe" string which can be put straight in a database / hidden 
form field / URL variable without needing any further processing - it 
can then be decoded at a later date.

In fact, the encode() and decode() functions would probably complement 
serialize() very well :)

> On Monday, February 25, 2002, at 11:27  PM, Demitrious S. Kelly wrote:
>
>> It breaks the individual characters down into their ascii equivalent,
>> and makes it one big 'numerical' string... then breaks the string back
>> into separate values and translates each value back into a character,
>> then recreates the string from the characters...
>>
>> I got sick of slashing and un slashing and validating, and revalidating,
>> etc, etc, etc, etc so I made this. Which makes things 1000% simpler
>>
>> -Original Message-
>> From: Nick Richardson [mailto:[EMAIL PROTECTED]]
>> Sent: Monday, February 25, 2002 8:11 PM
>> To: Demitrious S. Kelly; 'PHP General'
>> Subject: RE: [PHP] Variables containing HTML?
>>
>> Right on!!! - This works great!!
>>
>> Can you explain what it does ;) - i'm completly lost in it ;)
>>
>> //Nick
>>
>> -Original Message-
>> From: Demitrious S. Kelly [mailto:[EMAIL PROTECTED]]
>> Sent: Monday, February 25, 2002 8:02 PM
>> To: 'Nick Richardson'; 'PHP General'
>> Subject: RE: [PHP] Variables containing HTML?
>>
>>
>> Try these...
>>
>> function encode($string) {
>> $string=stripslashes($string);
>> $temp='';
>> $newstring='';
>> for ( $counter=0; $counter != ; $counter++ ) {
>> $temp=substr($string, $counter, 1);
>> if ( $temp == '' ) {
>> break;
>> }
>> $newstring=$newstring . str_pad( ord($temp), 3, "0",
>> STR_PAD_LEFT);
>> }
>> return ($newstring);
>> }
>>
>> function decode($string) {
>> $temp='';
>> $newstring='';
>> for ( $counter=0; $counter != ; $counter+=3 ) {
>> $temp=substr($string, $counter, 3);
>> if ( $temp == '' ) {
>> break;
>> }
>> $newstring=$newstring . chr($temp);
>> }
>> return ($newstring);
>> }
>>
>> -Original Message-
>> From: Nick Richardson [mailto:[EMAIL PROTECTED]]
>> Sent: Monday, February 25, 2002 7:56 PM
>> To: PHP General
>> Subject: [PHP] Variables containing HTML?
>>
>> Stupid question for everyone... i'm just having one of those braindead
>> moments.
>>
>> I have a page which allows users to add custom headers and footers in
>> HTML.
>> (i.e. Fill in a text area with a bunch of html, and that's stored in a
>> mysql
>> database and retrived when that user logs in again).
>>
>> The problem i'm having is this:
>>
>> When a users fills in all the info, and hits submit, they are taken to a
>> preview page which renders everything and has an accept button.
>> If i try to store the header and footer data in a hidden input it just
>> renders it on the screen (if it's more than one line it gets even
>> worse).
>>
>> How can i get this info (variable w/ strings that are QUITE long, and
>> include quotes and apostrophes) from the form they are entered on, into
>> a
>> preview page, then back into the script to be written into the database?
>>
>> I have thought about sessions, and they work until the user decides they
>> dont like the way it turned out and try to discard and change it, even
>> after
>> re-registering the variables in the session, they do not change to the
>> new
>> input.
>>
>> I hope someone out there can make sence of what i have said... because i
>> think i confused even myself ;)
>>
>> Thanks for any help!
>>
>> //Nick Richardson
>>
>>
>> -- 
>> 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
>>
>>
>
>
>
>
>
> 
>
> Erik Price
> Web Developer Temp
> Media Lab, H.H. Brown
> [EMAIL PROTECTED]
>
>




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




Re: [PHP] OMG your right ... $REMOTE_ADDR don't work in Samber 5.1, PHP4

2002-02-28 Thread Simon Willison

Philip J. Newman wrote:

>OK yah, this is a pain in the butt, $REMOTE_ADDR Dose not work in Sambar 5.1.  Anyone 
>have anyone have any solutions that can be used insteard?
>
Whenever you have a problem like this run phpinfo(); and have a look at 
the available environment variables. Useing print_r($HTTP_SERVER_VARS); 
can be very helpful as well.


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




Re: [PHP] Reuse variables?

2002-02-28 Thread Simon Willison

Tim Thorburn wrote:

> I've setup a form that users to our site fill out to request to be 
> added to our listings.  Currently its setup so that the user fills out 
> the form, and the information is emailed to me for reviewing - however 
> I'd like to carry it a step further and enter only some of the emailed 
> information automatically into a MySQL database.
>
> The way the script is setup now, it gathers the information from the 
> previous form, sends the email, and then is supposed to enter itself 
> into the database.  Although it doesn't get this far - it seems that 
> once the mail command is used, there is nothing left over - and vice 
> versa.
>
> Is it not possible to do two things with the same form data?

It's definitely possible. Sounds like your script has a bug in it, but 
without seeing the code there's not much we can do to help :)


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




[PHP] Re: Using Google's new SOAP based API in PHP

2002-04-12 Thread Simon Willison

Stefen Lars wrote:
> Hello all
> 
> CodingTheWeb.com has several reports of Google's new SOAP based 
> application programming interface:
> 
> http://www.codingtheweb.com/projects/newslog/index.php?filter=Google
> 
> Has anyone tries using this in PHP yet???

Yup - http://toys.incutio.com/php/php-google-web-api.html


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