Re: [PHP] Regex for telephone numbers

2010-12-29 Thread Josh Kehn


On Dec 29, 2010, at 7:12 PM, Ethan Rosenberg eth...@earthlink.net wrote:

 Dear List -
 
 Thank you for all your help in the past.
 
 Here is another one
 
 I would like to have a regex  which would validate that a telephone number is 
 in the format xxx-xxx-.
 
 Thanks.
 
 Ethan
 
 MySQL 5.1  PHP 5  Linux [Debian (sid)] 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

You can't, phone numbers are more complex then that. You could use 
\d{3}-\d{3}-\d{4} to match that basic pattern for all numbers though.

Regards,

-Josh
___
http://joshuakehn.com
Sent from my iPod
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Encryption/Decryption Question

2010-08-11 Thread Josh Kehn
On Aug 11, 2010, at 6:50 PM, tedd wrote:

 Hi gang:
 
 Okay, a question to the Encryption/Decryption gurus out there.
 
 If you were given:
 
 1. This encrypted string:
 
 p3IVhDBT26i+p4vd7J4fAw==
 
 2. Were told it was a social security number (i.e., in the form of 
 123-45-6789).
 
 3. And it had been generated from this code:
 
 $cipher = mcrypt_module_open(MCRYPT_TRIPLEDES,'','cbc','');
 mcrypt_generic_init($cipher, $key1, $key2);
 $encrypted = mcrypt_generic($cipher,$social_security_number);
 
 4. Where $key1 and $key2 are md5() values calculated from two different 
 security phrases.
 
 5. Where each security phrase contains multiple non-English words.
 
 What would it take for you to break the encrypted string and decipher the 
 social security number? Can it be done? If so, how long?
 
 And lastly, where would the best place to store these security phrases? 
 (Note: I didn't ask where would be the best place for me to put them.)  :-)
 
 Cheers,
 
 tedd
 
 PS: No, the SS number in question is not 123-45-6789. :-)
 
 -- 
 ---
 http://sperling.com/
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


Tedd-

Considering you can brute force the entire keyspace for Triple DES in under a 
few hours (without specialized equipment) I don't think it would take long.

Granted, I'm not an encryption expert. I look forward to hearing more.

Thanks,

-Josh

Joshua Kehn | josh.k...@gmail.com
http://joshuakehn.com


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



Re: [PHP] PHP The Anthem

2010-08-05 Thread Josh Kehn
That. That is awesome.  I will be forwarding this to some perl people now.

Regards,

-Josh

On Aug 5, 2010, at 7:57 PM, Daevid Vincent wrote:

 http://www.youtube.com/watch?v=S8zhmiS-1kw
 
 http://shiflett.org/blog/2010/aug/php-anthem
 
 ...some people have way too much time. ;-)
 
 
 -- 
 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] Quotes vs. Single Quote

2010-08-05 Thread Josh Kehn

On Aug 5, 2010, at 10:10 PM, Rick Dwyer wrote:

 Hi List.
 I've mentioned before that I am both just beginning to learn PHP AND I have 
 inherited a number of pages that I'm trying to clean up the w3c validation on.
 
 Something that confuses me is how the code on the page is written where in 
 one instance, it follows this:
 
 echo table border='1'tr
 
 And elsewhere on the page it follows:
 
 echo 'table border=1tr
 
 In what I've read and from many of the suggestions from this board, the 
 latter seems to be the better way to code, generally speaking.
 
 So given that the page has javascript in it, perhaps the reason for the 
 previous developer switching between the two was for ease of incorporating 
 JS? Don't really know... but what I would like to know is it considered 
 poor coding switch between the two on a single page or is it perfectly 
 acceptable?
 
 2nd question, in the 3 lines below:
 
 $_SESSION['newpage'] = $newpage;
 $checkstat = select field from table where fieldid = $field_id;
 $result1 = @mysql_query($checkstat,$connection) or die(Couldn't execute 
 query);
 
 
 If I were to recode in the latter style, should they not look like this:
 
 $_SESSION['newpage'] = $newpage;
 $checkstat = 'select field from table where fieldid = '.$field_id.'';
 $result1 = @mysql_query($checkstat,$connection) or die('Couldn\'t execute 
 query');
 
 
 The focus being here:
 
 '.$field_id.'';
 ('Couldn\'t execute query')
 
 Is this correct?
 
 Thanks for the help.
 
 --Rick
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
Rick-

It is generally accepted that you should use single quotes whenever possible. I 
only use double quotes when writing SQL queries (so I don't have to continually 
escape them for the single quotes) and when I need to output control characters 
like \r or \n. 

It would be considered best practice to make consistent use of them, but it 
wouldn't be something I would loose sleep over.

Regards,

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



Re: [PHP] the state of the PHP community

2010-07-29 Thread Josh Kehn
On Jul 29, 2010, at 1:36 AM, Nathan Rixham wrote:

 Hi All,
 
 I find myself wondering about the state of the PHP community (and related 
 community with a PHP focus), so, here's a bunch of questions - feel free to 
 answer none to all of them, on list or off, or add more of your own - this 
 isn't for anything specific, just out of interest and sure I (and everybody 
 who reads the replies) will learn something + doors/options/contacts may come 
 of it. The only thing I can guarantee is that I'm genuinely interested in 
 every reply and will read every one of them + lookup every tech and link 
 mentioned.
 
 in no particular order:
 
 What other languages and web techs do you currently use other than PHP?
 - if you include html or css please include version, if js then preferred 
 libs, and whether client or server side.

Java, JS (in the form of Node and MongoDB, +raw client / jQuery stuff) and PHP 
get used regularly. Python / Ruby infrequently.

 
 What's your previous language/tech trail?

Started with QBasic and realized it was crap. Moved on to Java, realized object 
rock but J2EE doesn't. Moved to PHP / Java.

 
 Are you considering any new languages or techs, and if so which?
 - names / links

http://www.mongodb.org/
http://nodejs.org/

See http://joshuakehn.com/blog/index.php/blog/view/28/MongoDB-Node-js/

 
 Is PHP your hobby/interest, primary development language, just learning or?

Primary dev, hobby, interest, all of the above? 

 
 How many years have you been using PHP regularly?

More then five, but it's really hard to say when it stopped being just a 
language and the primary.

 
 How many years have you been working with web technologies?

More then eight, though I remember HTML when tables were used for everything 
and spacer gifs were *the* thing. 

 
 Did you come from a non-web programming background?

Yes, primarily Java.

 
 Is your primary role web developer or designer?

Developer. I couldn't design if you paid me my weight in gold.

 
 In your developer life, are you an employer, and employee, contractor, 
 freelancer, part of a team of equal standing members?

Contractor / freelancer / employee / employer. Currently teaming up with a 
friend.

 
 Do you tend to work on jobs for geo-local clients, clients in the same 
 country, or do you work internationally 'on the web'?

I like to work in person, but sometimes that doesn't work. I have done 
international work before.

 
 How do you get your projects? do they come to you, word of mouth, do you hunt 
 and bid for projects, code call, visit clients, target clients individually 
 you think you can help, or?
 - not looking for trade secrets, just to get enough for an overall picture.

Word of mouth mostly. 
 
 Do you have any frustrations with the PHP community, do you find you want to 
 talk shop but can't, or find people to work with but can't, have projects in 
 mind you want to do but can't find people to do them with etc?

Not particularly.

 
 Do you network with other PHP'ers in real life - meetups etc, do you tend to 
 shy away, or do you find you circulate in other web related but non PHP 
 focussed communities?

I haven't gotten flashed on any PHP meetups, but I wouldn't shy away from them.

 
 Are you a member or any other web tech communities, opensource efforts, or 
 standardization bodies - again, if so which?

None that I recall.

 
 Are there any efforts, projects or initiatives which are floating your boat 
 right now and that your watching eagerly (or getting involved with)?

Node, Mongo. I'm also watching a couple git repos, memcached and scribe to name 
two. Some stuff I just can't be involved in (C / C++ dev is tricky when you 
work with Java / PHP).

 
 ps: please *do not* flame anybodies answers, that really wouldn't be fair.
 
 Best  Regards,
 
 Nathan
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

Regards,

-Josh

[PHP] Hello, I have a php/apache question

2007-11-12 Thread Josh McDowell
I just recently installed apache 2.0 on my comp with php 5.2.5 aswell. Apache 
is working and I am trying to get php to be configured into apache as a module, 
I put the ini file in the load module so it looks like this:

#LoadModule vhost_alias_module modules/mod_vhost_alias.so
#LoadModule ssl_module modules/mod_ssl.so
LoadModule php5_module c:/php/php5apache2.dll
AddType application/x-httpd-php .php
PHPIniDir C:/php

The problem is that when I test php in the web browser nothing comes up, I put 
a test.php notepad file in the document root with a ?php
phpinfo();
?  function in it and nothing comes up.

Also when I restart apache I get this message:

apache is running a threaded mpm, but your php module is not compiled to be 
threadsafe.
You need to recompile php.
preconfiguration failed.

Any suggestions would be helpful, thank you for your time.

-Josh

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



RE: [PHP] eval();

2005-10-30 Thread Josh McDonald
Keep in mind, eval()ing code you pull from the database will also raise the
damage from a SQL injection attack or similar from a PITA
restore-your-database to a much bigger PITA format-webserver.

-Josh
 
--
 
My name was Brian McGee
I stayed up listening to Queen
When I was seventeen

  Josh 'G-Funk' McDonald  ::  Pirion Systems, Brisbane
 
 07 3257 0490  ::  0437 221 380  ::  [EMAIL PROTECTED]
 

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Monday, 31 October 2005 3:57 PM
To: John Taylor-Johnston
Cc: php-general@lists.php.net; Jasper Bryant-Greene
Subject: Re: [PHP] eval();

On Sun, October 30, 2005 8:51 pm, John Taylor-Johnston wrote:
 eval(  ? $contents ?php  );

However, if eval() is the answer, you're probably asking the wrong 
question. You should take a hard look at your code and think of a  
better way to do what you need to do.


 Back to the drawing board? It is either store my html+embedded code in 
 a mysql record, or in an html file, which means playing with fopen. 
 It's easier to hand tweak in phpmyadmin.
 Nonetheless, even though your test code worked (thanks!) this doesn't.
 Sigh.

 if ($contents = displaynew()){
echo CONTENTS:pre, htmlentities($contents), /pre\n;  eval(  ?
$contents ?php  ); }

I'm guessing $contents ain't what you think.



 function displaynew()
 {
$file = basename($_SERVER['PHP_SELF']);
require 'connect.inc';
$sql = SELECT HTML FROM `$db`.`$table_editor` WHERE `Filename` 
 LIKE '.addslashes($file).' LIMIT 1;;
if ($myquery = mysql_query($sql) and mysql_num_rows($myquery)  0)

This 'and' should probably be '' ...

Though I never really used 'and' enough to know for sure.

At any rate, you've got *NO* error-checking for an invalid query here.

 {
$mydata = mysql_fetch_array($myquery, MYSQL_NUM);
return $mydata[0];
}
return false;
 }


--
Like Music?
http://l-i-e.com/artists.htm

--
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] Uploading a file

2005-09-06 Thread Josh

Hi
	I have recently been working on a site which allows the user to upload 
a file to the site. Originally calling the $_FILES['file']['tmp_name'] 
worked fine, however the web host has now disabled all global variables 
and if I'm not mistaken $_FILES is global. Does anyone know of a work 
around for this?


Cheers.
Josh

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



Re: [PHP] removing chars from string

2005-06-27 Thread Josh Olson
 I know that it is length, and I gave the correct length for an 11 character 
 string minus two characters. But as always, there is more than
 one way to skin a mule.


$string = '12345678901';

$jayString = substr($string, 0, 9);
$kevinString = substr($string, 0, 8);

echo $jayString; // echos 123456789
echo 'br /'; // echos 12345678
echo $kevinString;

It turns out to skin a mule is to outsmart him. Because mules aren't
actually stubborn, they're just smarter than most of us.

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



Re: [PHP] Problem with arrays

2005-06-24 Thread Josh Olson
for ($i = 0; $i  count($array1); i++)
$array1[$i][] = $array2[$i];

from kevin l'huillier

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



[PHP] Object Oriented PHP (5)

2005-06-24 Thread Josh Olson
PHP has inspired me to become a better programmer.  I have been
actively reading books as well as online content to try to become
better at designing and programming object oriented web applications.
My primary focus is PHP.

Will you help a pragmatic programmer in training out by suggesting
some worthwhile resources?

I have read the following already:
PHP 5 Power Programming
Advanced PHP Programming
Pragmatic Programming
Gang of Four Design Patterns
php.net/oop
zend.com php 5 resources
most of ibm object design articles
http://www.solarphp.com/home/
and many many many shitty online tutorials and source repositories

 ...and some of my OO code is still in production use 10  years after it was 
 written.
Inspiring.

Please don't Lynch me

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



Re: [PHP] Meta HTTP refresh problem

2005-03-25 Thread Josh Whiting
 Recently, during a rewrite of my login page, the Meta Refresh I am using 
 suddenly stopped working. I've tried using it by echoing it with php and 
 by just using it in HTML. I've also tried using a javascript redirect 
 with no luck either. Any thoughts on how to debug and what might be 
 holding me up?
[snip]
 //Test to see if you actually got to this part
 echo You should be going somewhere!;
 echo META HTTP-EQUIV=REFRESH CONTENT=\0;URL=main_page.php\;
 } else {
 printLogin();
 echo brcenterInvalid username/password/center;
 }

META tags have to go in the HEAD section of the HTML document.

this is an optional suggestion but, overall, one thing that would be
better is to determine (before you send any ouput) if the login was
correct or not, and if not, use an HTTP redirect:

if (bad login) {
  header(Location: http://mydomain.com/login.php?tryAgain=1;);
} else {
  header(Location: http://mydomain.com/mainpage.php;);
}

(the tryAgain=1 is to tell the script that you want to show a  
login failed, please try again message)

using a redirect instead of a meta refresh is more user friendly because
(1) it's faster since some browsers force a waiting period before the
refresh happens (as a usability feature), and (2) the user can use
back/forward without running into the this page contains POST data, do
you want to resend it? alert, which I avoid in my designs like the 
plague (always using a redirect instead of showing output as the result 
of a POST action).

HTH
/josh w

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



Re: [PHP] header(Location: page.php target=_parent)?????

2005-03-25 Thread Josh Whiting
 How should I formulate the header function to replace the current frameset 
 page with a new one?  I have tried a combination of header(Location: 
 page.php target=_parent); but I get an error message saying the page does 
 not exist.

 Also, can I save a frameset page with a .php extension?  I have tried it out 
 and it seems to work.  Maybe perhaps I should not do this as there  may be 
 some implications later on???

you cannot replace the main frameset using HTTP headers in the
individual frame pages.  HTTP headers do not allow for this because
frames are a feature of HTML, not HTTP. therefore you must use HTML or
javascript techniques to get a single frame to change the overall
frameset.

however, for what it's worth, you can replace the main framset using a
header in the main frameset page itself, if you make that a php script
and use the header() function. (which means the answer to your second
question is yes)

/jw

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



Re: [PHP] OR statement

2005-03-24 Thread Josh Whiting
 This work fine, however, I would like to add to the criteria above. I would
 like to say:
 
  if ($audio == Cool or junk or funky){
 
 ...
 

if (in_array($audio,array(Cool,junk,funky))) {
...
}

not the most elegant looking but it gets the job done.

/josh w

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



Re: [PHP] Re: Getting the process ID

2005-03-24 Thread Josh Whiting
 The problem I am having is that people are double-submitting certain 
 transactions.  My first attempt to prevent this was to store a flag in the 
 session record indicating whether or not certain transactions had been 
 completed, but this turned out to be insufficient at times because users 
 could try and initiate a second transaction before the first transaction had 
 finished (and thus the system had not yet flagged the transaction completed 
 in the session record).  They then both completed in parallel, and voila, 
 duplicate transactions again.
 
 I realized that this sort of problem would always exist unless I had some 
 sort of semaphore mechanism.  Once a user has *started* a transaction, they 
 need to be prevented from initiating a second transaction until the first 
 transaction has been completed.
 
 I am open to suggestions on how to do this.  What is the best way?

do you have access to a database? why not just manage the transaction 
on the database level?  transactions, locking, etc. are a core part of 
what databases do for a living. it's not a problem best solved with PHP.

/josh w

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



Re: [PHP] Passing Arrays between pages

2005-03-22 Thread Josh Whiting
 Please can someone tell me how you pass arrays between PHP pages.
 
 $var = serialize($testArray);
 echo INPUT NAME = \kcompany[]\ TYPE = \hidden\ VALUE=\$var\;
 
 Then unserialize the variable on the receiving page.

To this you might also add an MD5 hash to check for authenticity,
depending on what you're doing with that incoming data that you're
unserializing (consider an client who sends you a serialized array that
you didn't intend). You'll also want to encode the serialized data with 
htmlentities:

$serialized = serialize($testArray);
$hash = md5($serialized . my secret phrase);
echo 'input type=hidden name=serialized 
value='.htmlentities($serialized).'';
echo 'input type=hidden name=hash value='.$hash.'';

then on the receiving end:

if ($_POST['hash'] != md5($_POST['serialized'] . my secret phrase) {
  // the hash doesn't match up, consider the data unusable
} else{ 
  $testArray = unserialize($_POST['serialized']);
}

HTH
/jw

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



Re: [PHP] Different approach?

2005-03-21 Thread Josh Whiting
On Thu, Mar 17, 2005 at 11:01:44AM -0500, John Taylor-Johnston wrote:
 Hi,

 I've read:

  http://dev.mysql.com/doc/mysql/en/create-table.html

 Would anyone code/approach this differently?
[...]
 $sql = INSERT INTO $table
 (StudentNumber,Exercise1,Exercise2) values
 ('$StudentNumber','$Exercise1','$Exercise2');

 mysql_select_db($db,$myconnection);
 mysql_query($sql) or die(print mysql_error());


your example looks pretty solid, but the code above does not escape the
$StudentNumber, $Exercise1, and $Exercise2 variables.  If any of these
variables contain data that when placed into the SQL string interferes
with the SQL itself, you'll have unexpected failures and also a security
hole if untrusted users can populate those variables.  The solution is
to wrap any strings or untrusted input like that in a call to
mysql_escape_string(), like so:

$sql = INSERT INTO $table
(StudentNumber,Exercise1,Exercise2) values ('.
mysql_escape_string($StudentNumber).','.
mysql_escape_string($Exercise1).','.
mysql_escape_string($Exercise2).');

-jw

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



Re: [PHP] warning question about mysql sessions concurrency

2005-03-16 Thread Josh Whiting
On Wed, Mar 16, 2005 at 06:59:43PM +0100, Marek Kilimajer wrote:
 SO, does anyone have some code that uses MySQL to replace PHP's native
 session storage that also correctly handles this concurrency problem? 
 Ideally I'd like to see just a set of functions that can be used with 
 sessions_set_save_handler() to transparently shift PHP's sessions to a 
 database, but I'm not going to use the stuff I've found on the web or 
 even in books (appendix D of O'Reilly's Web Database Applications with 
 PHP  MySQL publishes code with this problem).

 
 MySQL's InnoDB supports row-level locking. So row the right row in 
 session_start and release it in session_close function.

But mysql does not support nested transactions.  Locking the row means
that your entire script has to happen inside a single transaction. 
Since my application logic requires transactions as well, it would mean
using two separate connections to MySQL, one for the session transaction
and one for business transactions, and that means twice the connection
overhead.

 In MyISAM you can use application-level locking: GET_LOCK() and 
 RELEASE_LOCK() in session_start and session_close, respectively. 
 Parameter would be session id with some prefix.

AH!  GET_LOCK() - that would do the trick!  I didn't realize MySQL
supported locking mechanisms independent of transactions/tables etc.

 The problem is when you need to create session id - you must lock the 
 whole table to find unused session id and insert it into table.

Hmm... couldn't I just do an 'insert ignore' with the session id every
time to kick off the process? Then MySQL would handle checking for an
existing row and create an empty one if it didn't exist. A very stripped
down example:

To open a session:
1. insert ignore into sessions (id,content) values ($sess_id,'')
2. select get_lock('my_prefix_.$sess_id, 15)
3. if NULL returned then abort, otherwise lock is aquired OK
4. select * from sessions where id=$sess_id

Do stuff ...

To close it:
1. update sessions set content='...'
2. select release_lock(my_prefix_.$sess_id)

I don't have all the details covered yet but I think that is just 
what I needed.  Thanks!!

/Josh W

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



Re: [PHP] warning question about mysql sessions concurrency

2005-03-12 Thread Josh Whiting
On Fri, Mar 11, 2005 at 09:57:46AM -0800, Richard Lynch wrote:
  well the trouble is not in the writing at the end of the request, which
  would likely only be a single query and therefore not need a transaction
  in itself. the trouble is the lack of locking out other requests from
  reading the data when you're using it during the main body of
  the request.
[...]
 Short Version:  Either your frames/tabs are gonna be so clunky as to be
 useless, or you need to lock them into only one, or you need business
 logic, not session-logic.  Solving the race condition at session layer
 will only make your application un-responsive.
 
 This may go a long way to explaining why you're not finding any readily
 available solutions out there at the session layer.

You raise good points.  However, my goal is simply to have a
transparent, database-driven replacement for PHP's native session
handler.  I don't want to change my application logic because I'm
switching session handlers - my application shouldn't care!  And so,
transparently reproducing PHP's session layer functionality is going to
mean locking concurrent requests out, because that is what PHP's session
handler already does (for good reason IMHO).

you're argument about slow frames is valid, but is ALSO applicable to
PHP's native session handler, e.g. i'm not introducing a new problem. 
the trouble can be mostly avoided in either case by not starting session
in frames that don't need it (most of them), and doing any session stuff
right away and calling session_write_close() ASAP to free up the lock so
other frames can run.  

you're right that i could change my application logic to deal safely
with concurrent requests from the same session, but PHP already nicely
defeats the issue so you don't have to worry about it, and at a more or
less negligable performance loss if you design the scripts to reduce
session open/locked time to the bare minimum...

i would speculate that the reason i haven't found a readily available
solution is because most folks either (1) don't understand the problem,
or (2) don't think such a race condition is likely enough to warrant a
fix, or (3) are using a different backend (oracle, etc.) that makes the
problem easy to solve. the PHP team, however, clearly thought it was
important enough as is evident by their session handler design.

...have i convinced you yet of the worthiness of this endeavor? :)

/jw

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



Re: [PHP] warning question about mysql sessions concurrency

2005-03-10 Thread Josh Whiting
On Wed, Mar 09, 2005 at 02:52:52PM -0800, Richard Lynch wrote:
  Agreed, initially I thought of that but I also need to use transactions
  in my business logic and MySQL doesn't support nested transactions, so
  I'd have to open a separate connection to the DB to handle the session
  transaction while another connection handles the business
  transaction(s).  I'm hoping to find a solution that uses locking in the
  application level instead of the database.  Were I using a DB that
  supported nested transactions, it would be a different story.  maybe
  it's time to switch databases.
 
 Since the data only changes when you write it, at the end of the script,
 you could maybe get away with the transaction only being in the
 session_save handler, and be sure to rollback or commit your business
 logic before that.
 
 That would for sure take a lot of discipline, and might even be downright
 impossible for what you need, but it's worth pondering.

well the trouble is not in the writing at the end of the request, which
would likely only be a single query and therefore not need a transaction
in itself. the trouble is the lack of locking out other requests from
reading the data when you're using it during the main body of
the request.

so... no luck finding a concurrency-aware database session handler?

i'm going to try to roll my own, and i'll certainly share what i come up
with on the list.

thanks though, for the help up to this point!

/jw

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



Re: [PHP] warning question about mysql sessions concurrency

2005-03-08 Thread Josh Whiting
On Tue, Mar 08, 2005 at 10:38:28AM -0800, Richard Lynch wrote:
 Josh Whiting wrote:
  SO, does anyone have some code that uses MySQL to replace PHP's native
  session storage that also correctly handles this concurrency problem?
 
 Create your MySQL session tables using ENGINE=innoDB (in older MySQL, use
 TYPE=innoDB)
 http://mysql.com can tell you lots more about innoDB
 
 Then just wrap the contents of each function from the books in a BEGIN
 query to make them be transactions...  Err, no, I mean, start the
 transaction in the one function and COMMIT in the save function.
 
 That should take care of all the concurrency issues, I think.

Agreed, initially I thought of that but I also need to use transactions
in my business logic and MySQL doesn't support nested transactions, so
I'd have to open a separate connection to the DB to handle the session
transaction while another connection handles the business
transaction(s).  I'm hoping to find a solution that uses locking in the
application level instead of the database.  Were I using a DB that
supported nested transactions, it would be a different story.  maybe 
it's time to switch databases.

 I guess I'm just saying that in the real world, the race condition for a
 single user/session just doesn't occur that often, and when it does, the
 user generally recognizes the problem/error and accepts that they caused
 it by being impatient or running two windows at once or whatever they did
 that made it happen.
 
 That doesn't make it Right, but it does make it Practical.

Point taken.  I guess it's almost more of a pyschological thing for me 
as a programmer - the idea of writing code vulnerable to race conditions 
just doesn't sit well with me.

on the other hand, with the growing popularity of tabbed browsers, and 
of coures the frames issue, i think it is reasonable to demand proper 
behavior during concurrent requests, and while you may not be using 
frames, lots of sites do, and that's a setup for a real headache.

thanks
/josh

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



Re: [PHP] warning question about mysql sessions concurrency

2005-03-06 Thread Josh Whiting
On Sun, Mar 06, 2005 at 02:27:53PM +, Chris Smith wrote:
 Josh Whiting wrote:
 I've been trying to switch to MySQL-based session storage instead of the
 native PHP session storage.  In doing so, I've run into a lot of code on
 the web that exhibits a serious flaw regarding concurrent requests from
 the same client. All the code I've seen has glossed over the need to
 lock the session for the duration of the request, e.g. not allow
 concurrent requests to use it until it has finished.  PHP's native
 session handler correctly does this, but lots of MySQL-driven session
 code does not.

 Neither do.

PHP absolutely does.  Take the following code:
?
session_start();
if (!isset($_SESSION['count'])) $_SESSION['count'] = 0;
$_SESSION['count'] = $_SESSION['count'] + 1;
sleep(5);
echo htmlbodyh1Current count:;
echo $_SESSION['count'];
echo /h1/body/html;
?

Open up two browser windows/tabs and load this page in both, try to make
both pages load at the same time.  Notice the second request takes 10
seconds while the first takes 5.  That's because the second one is
really, actually, indeed WAITING for the first one to finish.  (You may
have to do a first initial request before trying this to get the cookie
set.)  This also is not a side effect of web server processes,
threading, etc., it's really waiting until the session lock is released.

 No request should be blocking (i.e. wait for concurrent processes to
 execute).  This implies a poor understanding of transactional processing
 from both yourself and PHP!

On the contrary, when dealing with a session store (in PHP, which AFAIK
always writes the session and the end of the request), it's very
important for serial access instead of concurrent.

Take the following sql from two MySQL clients:

client 1: start transaction;
client 2: start transaction;
client 1: select * from mytable where id=1 FOR UPDATE;
# i.e. give me the data from the row with a write lock
client 2: select * from mytable where id=1 FOR UPDATE;
...

client 2 is going to have to sit there and wait until client 1 commits
or rolls back.  that's how it should work with the session store.  each
PHP request should acquire a write lock on the session so no other
request can even *read* the data until the original request is done.

 - You usually only store some kind of identification for a user in the
 session - no other data.  doing otherwise is dangerous as there are
 multiple copies of data floating around uncontrolled.  A session-id is
 enough information to store.  Don't use the session for storing data
 willy nilly - it is for identifying the session only - nothing else.
 Can't say that enough.  Don't use it for shortcutting code.

there is no point to storing only a session id in a session store. the
session id is already in the cookie or querystring.  what's the point of
a session, then?  tell me how you store a user's login status, a user's
shopping cart contents, etc. - that is the place i call the session
store and that is the thing that needs to block concurrent
(write) requests, whatever you want to call it...

 - If you want a proper transactional system, there are two ways to
 handle concurrency:
[snip]
 Personally, no-one in the PHP/MySQL arena tends to understand these
 concepts as the two technologies are rarely used for pushing data around
 on big systems (this is generally Java/Postgres' domain).

i understand your explanations.  in the case of session concurrency, if
you're using a fail commit on change and are also using frames with
PHP's session design, you're site just isn't going to work.
one frame will appear and the rest will say sorry, some other process
got to the data first.  instead, each frame request has to wait for
each other to finish, which is how PHP's native session handler does it.

 I ONLY use PHP/MySQL for knocking up quick web apps to fart out content
 - nothing serious because it's simply not suited.

Have you checked out InnoDB?  Row level locking, transactions, etc etc.
Not as fully featured, agreed, but all the critical stuff is there.
MySQL isn't the same as it was a few years ago.

/jw

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



[PHP] warning question about mysql sessions concurrency

2005-03-05 Thread Josh Whiting
I've been trying to switch to MySQL-based session storage instead of the 
native PHP session storage.  In doing so, I've run into a lot of code on 
the web that exhibits a serious flaw regarding concurrent requests from 
the same client. All the code I've seen has glossed over the need to 
lock the session for the duration of the request, e.g. not allow 
concurrent requests to use it until it has finished.  PHP's native 
session handler correctly does this, but lots of MySQL-driven session 
code does not.

Example timeline:
1. client sends a request
2. session data is loaded from the db 
3. same client sends a request before the first one is finished (e.g. 
frames, tabbed browsing, slow server response times, etc)
4. session data is again loaded from the db
5. the first request changes some values in $_SESSION
6. the second request changes some values in $_SESSION
7. the first request writes the data to the db and exits
8. the second request writes it's data (over that written by the first 
request) and exits

PHP's native handler solves this problem by forcing concurrent requests
to wait for each other. The same thing needs to happen in a
database-driven session handler.

SO, does anyone have some code that uses MySQL to replace PHP's native
session storage that also correctly handles this concurrency problem? 
Ideally I'd like to see just a set of functions that can be used with 
sessions_set_save_handler() to transparently shift PHP's sessions to a 
database, but I'm not going to use the stuff I've found on the web or 
even in books (appendix D of O'Reilly's Web Database Applications with 
PHP  MySQL publishes code with this problem).

Folks using database sessions who do not deal with this scenario be
warned! I'm surprised so much bad code is going around for this task...

Many thanks in advance,
Josh Whiting

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



[PHP] Search Engine Friendly URLs

2005-01-15 Thread Josh
I am converting a site to use includes instead of a Dreamweaver template.  I
want the URLs to look like this: www.my-site1234.com/contact instead of
www.my-site1234.com/default.php?p=contact.

I found some tutorials on editing the .htaccess file but where do I find it
on the server?

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



Re: [PHP] Preventing execution without inclusion

2005-01-14 Thread Josh Whiting
 as per PHP5 example
 
 1 (the preferred way): user accesses 
 http://www.example.org/index.php?function=Join, this loads the class 
 NewUser and begins its implementation. Because of the __autoload, it 
 includes class.join.php, in order to utilize the class.
 
 2 (the wrong way): user accesses 
 http://www.example.org/includes/class.join.php without going through 
 index.php.
 
 I am trying to prevent 2 from even occuring, utilizing a piece of code 
 that would check if index.php had included it, or not. This code would 
 be in the beginning of all the class files, at the top, before any other 
  code was to be executed.
 
 As of yet, it has eluded me...

Put the include file outside the web directory tree.

/jw

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



Re: [PHP] Persistent PHP web application?

2005-01-08 Thread Josh Whiting
On Thu, Jan 06, 2005 at 08:41:57PM -0500, Jason Barnett wrote:
 Does not up to date mean the code isn't working with current releases
 of php 4 or 5? I'd be interested in giving it a try.

 I believe this is the case.  AFAIK the APC library doesn't support PHP5
 or at least it didn't when I looked at it.  If you want to pitch in
 support for APC you should just download it (or PEAR INSTALL it from the
 command line to try it :) )

I don't think Rasmus was talking about APC. AFAIK he mentioned some
extension code that used the Apache SAPI to run a PHP script to acheive
what we're talking about (persistent global vars/functions/objects etc). 

(quoting Rasmus):
 The apache-hooks SAPI can do this, although when I initially wrote it
 nobody seemed interested.  George fixed it/rewrote it to work much better,
 but nobody was interested in his version either, so the current
 implementation isn't up to date anymore.  The problem was likely that
 people really didn't understand how to use it and it is a rather unsafe
 thing to let PHP scripts fiddle with all the various Apache request hooks.
 You can really toast your server that way.  A simple generic data loading
 extension is something people will be able to understand and they are
 unlikely to destroy their server with it.

Rasmus, can you say more about what this is and it's current state of
functionality (or lack thereof)?

(back to quoting Jason):
 I'm picturing an extension that would simply not allow an uncautious or
 unknowing scripter to ruin the server, but would only allow him to store
 all his app defs and data model startup stuff in a one-shot performance
 booster.  It could even do it in a separate (CLI?) interpreter and copy
 the data over (but only once!) to the Apache-embedded interpreter using
 a shared memory resource... hmmm.

 So your process is something like (correct me if I misunderstand):
 php_script

[snip...]

 The above suggestion is quite messy and probably not thread-safe, but
 it's a start.  ;)

Well, bravo for venturing a possible implementation, but I'm not versed
in Apache or PHP internals to propose or evaluate one in that kind of
detail :(.  I don't know what is possible or how PHP internally stores
variables, functions, objects, etc that would make them able to persist 
or be shuffled around.

/jw

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



Re: [PHP] On large application organization [long and possibly boring]

2005-01-08 Thread Josh Whiting
 Josh, I am interested in what you mean by but there may be a better
 overall approach. 

(which was in reference to my original question which was: why are you
using a big switch?)

The reason I say that is because, though I'm no expert on application
design, in my own code I've found that whenever I'm tempted to use a big
switch, it's probably a better idea for me to make a class hierarchy.  I
just have a hard time imagining a case where a big switch accurately
represents the problem to be solved, since in real life solving problems
is more complicated than a flat set of totally isolated operations.

For example, a while ago I wrote some form validation code for a
classifieds application that used a 50+ case switch to validate incoming
form data, one case for each possible kind of field (make  model,
price, location, color, etc).  There was a large amount of overlapping
functionality for similar field types and it was also hard for me to
understand exactly what the start and end goal was for all the cases. 
If some common thing needed to be changed, most or all the cases had to
be updated and kept consistent, and by the 45th case my brain is going
to miss something.

Now I'm not suggesting this is what you're doing - this is just bad
design on my part.  Currently I'm in the process of implementing a class
hierarchy of fields, where for example the make_and_model class
inherits from the drop_down parent class, which inherits from the
basic_field class, each one extended or overriding it's parents
validate() method.  If I need to update the way drop downs validate, I
make a change in the drop_down class and it propagates naturally to all
the instances and subclasses.  A much better method than my earlier
switch!

So, because I feel like I've learned a bit personally about avoiding big 
switches I was curious about your approach, which I say again could be 
perfectly elegant :)

/jw

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



Re: [PHP] On large application organization [long and possibly boring]

2005-01-07 Thread Josh Whiting
 If I have a large app what is the difference, other than having a very
 large file, of doing this
 
 switch($action){
   /* several dozen cases to follow */
   case foo:
   writing out all of the code
   break;
 }
 
 and this
 
 switch($action){
   /* several dozen cases to follow */
   case foo:
   include that will handle processing this case
   break;
 }
 
 Correct me if I am wrong, but includes (and/or requires) will get all of
 the code in all of the cases regardless if the case is being processed.
 That being the case the code would essentially be the same length. Given
 that, would there be an efficieny issue?
 
 This would (the second way) also make the project easier to work on by
 multiple programmers at the same time, similar to modular work being
 done by programmers on C++ projects.

Correction: include() statements are executed at *run time*, which means
that if the case is not executed, the include will not be executed and
the file is not even read!  The include() method is not only more
efficient but also easier to maintain as you suggest.

Otherwise, I'm curious as to why you're using a large switch, not that 
it's bad inherently IMHO, but there may be a better overall approach. 

/jw

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



Re: [PHP] Persistent PHP web application?

2005-01-07 Thread Josh Whiting
  Call me crazy or ignorant, i'm both, but would it be possible to build
  an extension that, in its MINIT hook as you suggest, actually runs a
  separate PHP script that contains global definitions, then makes those
  definitions available to later scripts?  this is basically my original
  desire of having a one-time, persistent global include for each apache
  process.  i realize you suggest pulling array data from a source like a
  DB or XML file, which would be a 90% solution for me, but the next step
  (a PHP script) just seemed logical/exciting...
  
  i realize i'm reaching with this, and it implies a conundrum (how does
  an extension run a PHP script if PHP hasn't fully started yet) but this
  kind of thing is just what makes me go and learn new things (C, php/zend
  internals) and I just might try to do it if it was feasible, for the fun
  of it, because it could be useful to lots of people, even if it took me
  a year or two to pull off.
  
  alas, this is a question for the pecl-dev list.
  
  (the mental gears are churning...)
 
 The apache-hooks SAPI can do this, although when I initially wrote it 
 nobody seemed interested.  George fixed it/rewrote it to work much better, 
 but nobody was interested in his version either, so the current 
 implementation isn't up to date anymore.  The problem was likely that 
 people really didn't understand how to use it and it is a rather unsafe 
 thing to let PHP scripts fiddle with all the various Apache request hooks.  
 You can really toast your server that way.  A simple generic data loading 
 extension is something people will be able to understand and they are 
 unlikely to destroy their server with it.
 
 -Rasmus

Does not up to date mean the code isn't working with current releases
of php 4 or 5? I'd be interested in giving it a try.

Forgive my ignorance of Apache and PHP internals, but I'm not
understanding the concept of your implementation. I'm not enivisioning
allowing a PHP script to be able to meddle with the Apache request
process.  

I'm picturing an extension that would simply not allow an uncautious or
unknowing scripter to ruin the server, but would only allow him to store
all his app defs and data model startup stuff in a one-shot performance
booster.  It could even do it in a separate (CLI?) interpreter and copy
the data over (but only once!) to the Apache-embedded interpreter using 
a shared memory resource... hmmm.

I'm not versed enough to suggest a feasible implementation, but if 
the overall goal is feasible then I'm willing to climb the learning 
curve.

I'm also quite surprised there wasn't much interest in these concepts, I
admit the benefits would be small for most apps, but complex apps with
large data setup could save valuable time, and having persistent
namespaces/modules is plugged as a worthy feature of mod_perl and
mod_python, for what it's worth.

/jw

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



Re: [PHP] Persistent PHP web application?

2005-01-06 Thread Josh Whiting
 Anything you do in the MINIT hook is basically free, so it would be 
 trivial to load the data for the array from somewhere.  Like a database, 
 an xml file, etc.  So you wouldn't need to hardcode a complex array 
 structure in your MINIT hook, just have this generic little extension 
 that creates an array (or object) from some external source.  To change 
 the data you would change that external source and restart your server, 
 or you could write a PHP function in your extension that forced a reload 
 with the caveat that each running httpd process would need to have that 
 function be called since your array/object lives in each process separately.
 
 If you ask really nicely one of the folks on the pecl-dev list might 
 just write this thing for you.  Especially if you spec it out nicely and 
 think through how it should work.
 
 -Rasmus

Call me crazy or ignorant, i'm both, but would it be possible to build
an extension that, in its MINIT hook as you suggest, actually runs a
separate PHP script that contains global definitions, then makes those
definitions available to later scripts?  this is basically my original
desire of having a one-time, persistent global include for each apache
process.  i realize you suggest pulling array data from a source like a
DB or XML file, which would be a 90% solution for me, but the next step
(a PHP script) just seemed logical/exciting...

i realize i'm reaching with this, and it implies a conundrum (how does
an extension run a PHP script if PHP hasn't fully started yet) but this
kind of thing is just what makes me go and learn new things (C, php/zend
internals) and I just might try to do it if it was feasible, for the fun
of it, because it could be useful to lots of people, even if it took me
a year or two to pull off.

alas, this is a question for the pecl-dev list.

(the mental gears are churning...)

/jw

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



Re: [PHP] Persistent PHP web application?

2005-01-06 Thread Josh Whiting
 I think I understand where you're coming from. I've had a similar 
 problem and the best solution I've found is eAccelerator (previously 
 known as Turck MMCache). What EA does is keep the bytecodes PHP compiles 
 inshared memory so next time you need that script PHP doesn't need to 
 recompile, EA returns the bytecode from SHM. Now, since PHP scripts are 
 compiled and saved in SHM all I need to do is /save/ the data that does 
 not change often but requires a lot of queries as code (an array inside 
 a script) and include it whenever I need the data. No recompiling, no 
 need to touch the DB again, pure speed. I hope all this helps you. I 
 personally don't need extra processes and stuff like that but if you 
 really want all that you can take a look at phpbeans.
 
 Hope it helps,
 
 
 Adrian Madrid

phpBeans looks interesting. after browsing the site a bit, looking at
the introductory material and so on, i couldn't discern the way the
phpbean server persists the beans, and, hence, if the solution would be
fitting for what i'm looking for.  what i'm looking for is a solution
that will keep compiled zend variables and functions (the end result of
executed php code that defines the variables and functions), in memory,
without serialization, across multiple requests.  if this is how the
beans are kept persistent, i'm interested :)

i'm going to try to find someone at phpbeans who can answer that. if 
others are interested, email me and i'll let you know what i find 
(if/when i find it)...

/jw

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



Re: [PHP] Re: [suspicious - maybe spam] [PHP] [suspicious - maybe spam] SELECT probrem

2005-01-06 Thread Josh Whiting
 Hello Phpu,
 
 Thursday, January 6, 2005, 10:42:15 AM, you wrote:
 
 P I have an array, for ex: $products=array(1, 2,  5 , 7)
 P I want to select all products from the database that has the ids of 
 products.
 P I use this but doesn't work:
 
 $product_ids = implode(',', $products);
 $sql = SELECT product_name FROM accessories WHERE product_id IN 
 ($product_ids);
 
 Best regards,
 
 Richard Davey

Slightly off topic but worth mentioning is:

If your $products array is generated dynamically, make sure it isn't
empty before running the query, MySQL does NOT like:

SELECT product_name FROM accessories WHERE product_id IN ()

The empty () will cause a MySQL error (it won't just return an empty
result set.)  Plus, why run the query if the array is empty anyway?

/jw

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



Re: [PHP] apache 1 vs 2 w/php

2005-01-05 Thread Josh Whiting
 I am undecided whether to upgrade to apache 2 (currently running 1.3.33)
 I've heard some bad stuff (some good maybe) about using apache 2 with php..
 does anyone have an opinions?

a somewhat interesting discussion on the subject was recently on
slashdot, i suggest reading at least the blog entries linked in the main
story blurb: http://slashdot.org/apache/04/12/21/1837209.shtml

the bad stuff you're referring to is the threading problem, which is
completely solved if you just use the prefork MPM in apache 2, which
AFAIK is the default on linux.  not sure about Win32.

as for a performance improvement... it isn't hard to setup apache 2 on
the same server as apache 1 listening on a different port, then do
benchmarks and see for yourself.

/jw

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



Re: [PHP] Persistent PHP web application?

2005-01-04 Thread Josh Whiting
Wow thanks for the helpful breakdown.

 PHP's model is to be completely sandboxed such that every request is 
 completely separate from every other.  Having a persistent interpreter 
 as you describe would break that rule and break the infinite horizontal 
 scalability model of PHP.

Understood.  A persistent interpreter is a whole different approach. I
appreciate your perspective on that, it helps me to reconsider overall
what I'm doing and why I want to do it :)

 Of course, there is nothing that prevents you from storing persistent 
 data somewhere more permanent.  If it is just simple read-only data you 
 have a lot of options.  For example, you could put them in a .ini file 
 that is only loaded on Apache startup and use get_cfg_var() to fetch 
 them.  If you compile PHP with the --with-config-file-scan-dir switch to 
 configure a configuration scan directory you can just drop your own ini 
 file in that directory and it will be read on startup.  This is just 
 key=value pairs and not PHP code, of course.

I'm dealing with large multidimensional arrays, like this:

$categories = array (
1 = array ( 
'name' = 'Autos',
'depth' = 1,
...

:(

 If you need to do something fancier you can stick things in shared 
 memory.  Many of the accelerators give you access to their shared memory 
 segments.  For example, the CVS version of pecl/apc provides apc_store() 
 and apc_fetch() which lets you store PHP datatypes in shared memory 
 directly without needing to serialize/unserialize them.

That pecl/apc feature sounds like a great, cheap solution to my giant
global variable definition problem, which takes the biggest single chunk
of parsing time. The key AFAICS is avoiding the (un)serialization time.
I'd love to see an example if you have one, just to show me a target to
aim for. I'm unfamiliar with C / reading C source code and with shared
memory so I'm having a tough time figuring out how to use that feature.

(It doesn't solve the function definition problem but that is OK - the
functions take FAR less time to parse than the global variable
definitions.)
 
 And finally, the big hammer is to write your own PHP extension.  This is 
 a lot easier than people think and for people who are really looking for 
 performance this is the only way to go.  You can write whatever code you 
 want in your MINIT hook which only gets called on server startup and in 
 that hook you can create whatever persistent variables you need, pull 
 stuff from a DB, etc.  At the same time you will likely want to pull 
 some of your heavier business logic identified by your profiling into 
 the extension as well.  This combination of C and PHP is extremely hard 
 to beat performance-wise regardless of what you compare it to.

This is something I'm VERY interested in. It is encouraging to hear that
it is easier than I expect, and I will look into it further. Based on
the responses from the list I've gotten, this seems like the most
promising total solution. Any outstanding books/articles on the topic,
considering I'm not a C programmer?

Thanks again
/josh w.

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



Re: [PHP] Re: Persistent PHP web application?

2005-01-04 Thread Josh Whiting
 Why don't you just create a daemon started from the command line 
 (shell/DOS) and have it accept socket connections from your Web server 
 PHP scripts and provide a SOA (Services Oriented API) to the code that 
 accesses your data structures pre-loaded in memory?

Setting up a separate persistent daemon PHP script is appealing to me
because It implements exactly what I want, which is a persistent PHP
application server, and also would allow me to abstract the
implementation behind an API, move it to other servers when load
increases, etc.

However, would a single process PHP server daemon be able to
appropriately handle the incoming load from Apache, which will be
running multiple processes handling concurrent incoming requests?
Implementing a multi-process forking SOAP server in pure PHP seems
inefficient, but maybe I'm not understanding the basic
premise/implementation of the suggestion?

Any good links/tutorials/examples/books for this?

Thanks!
/josh w.

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



Re: [PHP] Persistent PHP web application?

2005-01-04 Thread Josh Whiting
Thanks for taking the time for your comprehensive repsonse!

 However, given your programming philosophy so far, and the fact that you
 are worried about 7ms and that you specifically requested some kind of
 shared memory space in PHP, you should Read This:
 http://us4.php.net/manual/en/ref.sem.php

 That pretty much is exactly what you asked for.

 Be forewarned that few PHP scripters have needed this stuff, and it's not
 anywhere near as hammered on (read: debugged) as the other options above.

I had the thought of using shared memory but I've found a scarce supply
of introductory material and examples on the subject. The documentation
assumes a level of familiarity with shared memory that I don't have, so
I'm struggling. Examples of how to store and retreive a set of large
multidimensional arrays to/from shared memory would be wonderful to look
at, if you have some pointers to articles/books/etc

I am also curious if the the shared memory solution would be a
significant performance improvement, since, AFAIK, the data is
serialized/unserialized for storage/retreival. Since the Zend
Accelerator already uses a shared memory cache for the intermediate
code, would using my own shared memory be any different? Consider that
my global variable definition scripts are nothing more than giant
unserialize statements.

(Incidentally, I've benchmarked the difference between big unserialize
statements and big PHP code array definition statements and found almost
no difference, only a marginal improvement in performance using PHP code
instead of unserialize on long strings.)

  Additionally, there are
  a large number of function definitions (more than 13,000 lines of code
  in all just for these global definitions).

 You should look into breaking these up into groups of functionality -- I'm
 willing to bet you could segment these and have many pages that only call
 in a few functions.

That is good practice, I know i've been a bit lazy in that respect :)
However, it is the variable definitions (big arrays) that take the most
significant time, executing all the function definition code is actually
only a small fraction of the time taken to parse the arrays, so it's a
secondary concern, though you are right I should sit down and rework my
includes so I'm only bringing in what I need.  I'll set aside a week
for that :)

 So if what your application mostly does is load in all this data and
 respond to requests, you could write a *SINGLE* PHP application which
 listened on port 12345 (or whatever port you like) and responded with the
 data requested.  Like writing your own web-server, only it's a
 _-server where you get to fill in the blank with whatever your
 application does.

Please see my repsonse to Manuel Lemos and his suggestion to run a SOAP
server. Basically my concern is the lack of having a
multi-process/forking server to handle concurrent incoming requests
(which may or may not be a problem - not sure).  We're talking about a
persistent PHP server (SOAP or otherwise), and I'm having trouble
groking how that would work in an environment with many concurrent
requests.  (Other than, of course, running a PHP SOAP server inside
Apache which brings me back to square one :)

 Actually, Zend and others could be interested in your comparisons of
 with and without cache...

If folks are interested in my benchmarks I could spend some time and put
together a summary. Incidentally I did end up doing some comparison of
cached code and uncached code because I unwittingly had the accelerator
turned off for while until I realized it :)

 Hope that helps...  Almost feel like I ought to invoice you at this point :-)

:) Thanks for the pro bono consulting, you have indeed helped!

Regards,
/josh w.

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



Re: [PHP] Re: Persistent PHP web application?

2005-01-04 Thread Josh Whiting
  However, would a single process PHP server daemon be able to
  appropriately handle the incoming load from Apache, which will be
  running multiple processes handling concurrent incoming requests?

 I don't think you've quite got the right picture here...

 When you write your single process PHP server daemon, Apache's not even in
 the same picture frame any more.

 The requests aren't coming from Apache -- PHP is listening to a port you
 select, exactly in the same way that Apache listens to port 80, MySQL
 listens to 3306, your SSH server listens to 22, your Mail server listens
 to 25, your FTP server listens to [I forgot]...

 In other words, you are giving PHP a promotion from a Module of Apache,
 to being its own web server, only it won't be a web server, it will be
 a Whatever You Want server.  I'll call it WYW (Whatever You Want) for
 the rest of this post.

 Just don't ask me how to pronounce WYW. :-)

pronounce it like wha u as in wha u say? :)

What I envision is an apache server running mod_php, opening sockets to
a standalone WIW (whatever I want) server (a long-running PHP script)
on some other port.  Apache/mod_php handles the remote HTTP clients, the
WIW server treats the php scripts running from apache as clients.  This
is what I meant by the incoming load from Apache.

 I'm betting the do-nothing PHP socket-server will handle VERY heavy load.
 That code is all thinly-disguised wrappers around the C socket library on
 your server -- The same library Apache, FTP servers, and so on are all
 using to handle their load, almost for sure.

 Whether or not what you need to *DO* with the incoming data and your
 calculations needed to compose a valid response will be fast enough really
 depends on what you want your WYW server to *DO*...

 You might even want to have multiple PHP processes going, just like
 Apache, if you need to handle really have load.

Ok I'm getting the picture.

Am I barking up the wrong tree with this whole concern for persistent
PHP native variables and code? It seems like the implementation of a
standalone PHP server is overkill and I ought to just throw more
loadbalanced servers at the application rather than cut the application
init time with a solution like this... or at least that is how I'm
starting to see it.

Not to say you're suggestions are in vain, if anything they're helping
me to see the bigger picture.

Regards,
/josh w.

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



[PHP] Persistent PHP web application?

2005-01-03 Thread Josh Whiting
Dear list,

My web application (an online classifieds server) requires a set of
fairly large global arrays which contain vital information that most all
the page scripts rely upon for information such as the category list,
which fields belong to each category, and so on. Additionally, there are
a large number of function definitions (more than 13,000 lines of code
in all just for these global definitions).

These global arrays and functions never change between requests.
However, the PHP engine destroys and recreates them every time. After
having spent some serious time doing benchmarking (using Apache Bench),
I have found that this code takes at least 7ms to parse per request on
my dual Xeon 2.4ghz server (Zend Accelerator in use*). This seriously
cuts into my server's peak capacity, reducing it by more than half.

My question is: is there a way to define a global set of variables and
functions ONCE per Apache process, allowing each incoming hit to run a
handler function that runs within a persistent namespace? OR, is it
possible to create some form of shared variable and function namespace
that each script can tap?

AFAIK, mod_python, mod_perl, Java, etc. all allow you to create a
persistent, long-running application with hooks/handlers for individual
Apache requests. I'm surprised I haven't found a similar solution for
PHP.

In fact, according to my work in the past few days, if an application
has a large set of global functions and variable definitions, mod_python
FAR exceeds the performance of mod_php, even though Python code runs
significantly slower than PHP code (because in mod_python you can put
all these definitions in a module that is loaded only once per Apache
process).

The most promising prospect I've come across is FastCGI, which for Perl
and other languages, allows you to run a while loop that sits and
receives incoming requests (e.g. while(FCGI::accept() = 0) {..}).
However, the PHP/FastCGI modality seems to basically compare to mod_php:
every request still creates and destroys the entire application
(although the PHP interpreter itself does persist).

Essentially I want to go beyond a persistent PHP *interpreter* (mod_php,
PHP/FastCGI) and create a persistent PHP *application*... any
suggestions?

Thanks in advance for any help!
Regards,
J. Whiting

* - Please note that I am using the Zend Accelerator (on Redhat
Enterprise with Apache 1.3) to cache the intermediate compiled PHP code.
My benchmarks (7ms+) are after the dramatic speedup provided by the
accelerator. I wouldn't even bother benchmarking this without the
compiler cache, but it is clear that a compiler cache does not prevent
PHP from still having to run the (ableit precompiled) array and function
definition code itself.

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



Re: [PHP] Total Server Sessions

2005-01-03 Thread Josh Whiting
 $num_sessions = count(glob(session_save_path() . '/sess_*'));
 echo There are about {$num_sessions} active sessions.;
 
 It will be fairly active so long as your garbage collection is triggered 
 fairly often.

it is worth noting that this doesn't work if you are using the recursive
directory structure method to store sessions, or any other session
storage method other than the default (in-memory sessions, database
sessions, etc).  and on a shared host, you may be counting the total
number of sessions for all the virtual hosts on the server. also, on a
shared host, it is usually up the sysadmins how PHP stores sessions, so
your mileage may vary.

/jw

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



[PHP] Uncompressing files on server

2004-12-19 Thread Josh
I have some PHP files from a content management system.  I uploaded the
compressed files to the server, but how do I un-compress them now?  I am
using Filezilla.  Can it be done, or do I have to uncompress the file on my
computer and then upload?

thanks

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



[PHP] Miami PHP groups?

2004-12-16 Thread Josh
Any computer groups or resources for learning PHP in the Miami area?  I am
new here ... trying to learn PHP... would like to meet other people doing
the same.

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



[PHP] PHP 5 to PHP4 - Apache2Triad

2004-12-13 Thread Josh
I installed PHP5 with MySQL and Apace 2, along with a lot of other stuff as
part of Apache2Triad.

But I want to replace PHP5 with PHP4 because some of the things I am testing
on my computer require PHP4.

Can anyone tell me how to do this or where I can find information on how to
do it?  I thought I remember reading something about how Apache2Triad came
with PHP4 also and there was a simple way to switch, but I have spent hours
looking and can't find the information.

Thanks

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


Re: [PHP] Web Development Overnight!!!

2004-12-13 Thread Josh
$70 for a domain name registration?   A domain name only costs $6 or $7 US
dollars per year...

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


[PHP] user password managment

2004-12-10 Thread Josh Howe
 

Does anybody have any tips or links for creating a system for managing
user's passwords. I want to make it so that when a user is created, an
email is sent with a link that allows them to set their password. The
link should only work for a set amount of time. I have ideas for
implementing something, but I have a hunch tat there is some code
already out there for this. Does anybody know of any? Thanks! 



[PHP] session question

2004-12-07 Thread Josh Howe

Hi,

I've looked at the php session documentation, and it doesn't look like
there's any way to run code when a session expires. I'd like to do some
cleanup when a user's session expires, is there any way to trap this?
Thanks. 

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



[PHP] getting the phsyical path

2004-12-03 Thread Josh Howe
 

Hi,

 

Sorry if this is a dumb question. Is there a way in php to get the
physical path the document root of my website? I want to open a file in
the root of my web server, i.e. /, but I won't always know what the
physical path to the web root is, and it will vary depending on the
machine the web app is running on. I've tried using realpath (e.g.
realpath(/)) but it doesn't really work. Thanks.



[PHP] classes and variable scope

2004-12-01 Thread Josh Howe

Hi all,

If I have the following code:

$some_global_variable;

Class foo {

Function test() {
set_global();
echo $some_global_variable;
}

Function set_global () {
$some_global_variable = abcd;
echo $some_global_variable;
}
}

The first echo statement (the one inside the set_global function) prints
abcd, but the second prints nothing. How can I set the value of
$some_global_variable inside the set_global function so that it sticks?
I'm using PHP 4.3.3.

Thanks. 

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



[PHP] bubble sort crashing apache

2004-11-16 Thread Josh Howe

I've implemented my own bubble sort function that is crashing apache.
Can somebody either help me out with the bubble sort or help me figure
out a way to solve my problem with php's built in sorting functions?

This is my problem. I'm writing my own class for displaying html tables.
Right now, the only thing this class really abstracts is the sorting of
the table rows by any column ascending or descending. My table class
accepts an array of $row objects. Each $row object itself contains an
array of $cell objects. I've included the function I'm using to sort the
rows at the end of the email.

The problem I'm seeing is that after about the 3rd sort on a particular
column, apache crashes. Maybe bubble sort isn't the best sorting
algorithm, since when the user switches from ascending to descending
sort order on the same column or vice versa, I get the worst case
scenario for a bubble sort (the data is in reverse order). 

Any ideas? Thanks!!



private function sort() {
$col_name = $this-order_by;

/*
** Get the column number of the column we're
** ordering by.
*/
for ($i = 0; $i  count($this-col_names); $i++) {
if (strtoupper($col_name) ==
strtoupper($this-col_names[$i])) {
$col_num = $i;
break;
}   
}

/*
** bubble sort
*/  
for ($n = 0; $n  count($this-contents); $n++) {
$sorted = true;

for ($y = 0; $y  count($this-contents) - 1; $y++) {
$cell_arr_this =
$this-contents[$y]-get_cell_arr();
$cell_arr_next = $this-contents[$y +
1]-get_cell_arr();

if
($this-out_of_order($cell_arr_this[$col_num],$cell_arr_next[$col_num]))
{
$tmp_row = $this-contents[$y];
$this-contents[$y] = $this-contents[$y
+ 1];
$this-contents[$y + 1] = $tmp_row;

$sorted = false;
}
}

if ($sorted) break;
}
}

function out_of_order($val1, $val2) {
if ($this-order_dir == desc) {
if ($val2  $val1)
return true;
else 
return false;
} else {
if ($val1  $val2)
return true;
else 
return false;
}
}

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



[PHP] http response

2004-11-13 Thread Josh Howe
 

Is it possible in php to get a hold of the response stream and see what has
been sent already? I have a global php function, but it can't be called
inside html form elements, because it creates its own form, and when you
nest html forms things get weird. In this function, I want to check if there
is already an open form tag in the response without a corresponding
/form tag. Is there any way to do this? Thanks!!



RE: [PHP] http response

2004-11-13 Thread Josh Howe

That's perfect, thanks Rob.


-Original Message-
From: Robert Cummings [mailto:[EMAIL PROTECTED] 
Sent: Saturday, November 13, 2004 10:48 AM
To: Josh Howe
Cc: PHP-General
Subject: Re: [PHP] http response

On Sat, 2004-11-13 at 10:38, Josh Howe wrote:
  
 Is it possible in php to get a hold of the response stream and see what
has
 been sent already? I have a global php function, but it can't be called
 inside html form elements, because it creates its own form, and when you
 nest html forms things get weird. In this function, I want to check if
there
 is already an open form tag in the response without a corresponding
 /form tag. Is there any way to do this? Thanks!!

Look into ob_get_contents()

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.  |
`'

-- 
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] sending mail -- nullmailer

2004-10-08 Thread Josh Howe
 

Ok, so I came across nullmailer, which seems to do exactly what I want -
forward mail to an existing smtp server. But it isn't working. I'm using the
mail() php function, and the mails aren't arriving. The same code works fine
on a windows machine pointing to the same smtp server. Does anybody have any
experience configuring nullmailer? How do I tell linux to use nullmailer as
the default MTA? Thanks!! 



RE: [PHP] Re: sending mail -- nullmailer

2004-10-08 Thread Josh Howe

I don't want to setup and maintain a new mail server (sendmail) when we
already have an smtp server set up and maintained by our sys admin. Am I
crazy here? 

Can anybody recommend a good sendmail wrapper I can use that will work with
PHP and any other apps that use sendmail? Thanks



-Original Message-
From: Manuel Lemos [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 08, 2004 12:59 PM
To: Josh Howe
Cc: [EMAIL PROTECTED]
Subject: [PHP] Re: sending mail -- nullmailer

Hello,

On 10/08/2004 01:35 PM, Josh Howe wrote:
 Ok, so I came across nullmailer, which seems to do exactly what I want -
 forward mail to an existing smtp server. But it isn't working. I'm using
the
 mail() php function, and the mails aren't arriving. The same code works
fine
 on a windows machine pointing to the same smtp server. Does anybody have
any
 experience configuring nullmailer? How do I tell linux to use nullmailer
as
 the default MTA? Thanks!! 

I don't know why do you want to replace your Linux installation MTA. 
Usually is sendmail or compatible and can be configured to relay 
messages to a SMTP server instead of deliverying them directly.

Under Linux/Unix PHP just hands the message to the sendmail program. It 
would not make much sense to relay messages a SMTP server when sendmail 
can be more efficient by sending them directly to the SMTP of the 
recipient users, unless you are trying to send messages from a server 
that is blacklisted and the world is not accepting messages from it or 
because of some other blocking reason.

Anyway, if you really want to relay messages to a SMTP server under 
Linux/Unix, the mail function will not do that. Instead you may want to 
try this class that comes with a wrapper function named smtp_mail(). It 
emulates the mail() function and the purpose of its arguments except 
that it can relay the messages a SMTP server of choice.

http://www.phpclasses.org/mimemessage

You also need this:

http://www.phpclasses.org/smtpclass


-- 

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html

-- 
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] sending mail

2004-10-07 Thread Josh Howe
 

Do I need to have sendmail configured on my linux box to send mail via PHP?
Thanks!



RE: [PHP] sending mail

2004-10-07 Thread Josh Howe

I'm sorry, I don't know what and MTA is. Can I configure PHP to use any smtp
server? 


-Original Message-
From: Matthew Sims [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 07, 2004 5:58 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] sending mail



 Do I need to have sendmail configured on my linux box to send mail via
 PHP?
 Thanks!

Sendmail or any MTA will do.

So yes, you need to have a working mail server.

-- 
--Matthew Sims
--http://killermookie.org

-- 
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] mail() from addess problems

2004-09-07 Thread Josh Close
When I'm using mail() to send an email, the user is always

From: Apache [EMAIL PROTECTED]

How would I get this to change? I didn't see anything in php.ini or
httpd.conf. I've found it's not possible to do a header rewrite with
postfix either.

-Josh

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



Re: [PHP] mail() from addess problems

2004-09-07 Thread Josh Close
Thanks.

-Josh


On Tue, 07 Sep 2004 16:55:24 -0500, Greg Donald [EMAIL PROTECTED] wrote:
 
 
 On Tue, 2004-09-07 at 16:52, Josh Close wrote:
  When I'm using mail() to send an email, the user is always
 
  From: Apache [EMAIL PROTECTED]
 
  How would I get this to change? I didn't see anything in php.ini or
  httpd.conf. I've found it's not possible to do a header rewrite with
  postfix either.
 
 Add a From: header in the optional last field of your mail() call.
 
 --
 Greg Donald
 


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



[PHP] xml tags interfere with php tags

2004-09-01 Thread Josh Close
How do I get an xml tag to work with a php script?

?xml version=1.0?

php is trying to parse that.

-Josh

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



Re: [PHP] xml tags interfere with php tags

2004-09-01 Thread Josh Close
I was hoping there was another way around it. if not, I could do
that I guess.

-Josh



On Wed, 1 Sep 2004 14:06:18 -0500, Brent Clements
[EMAIL PROTECTED] wrote:
 The simplest answer is to either turn off short tags or change the short tag
 which php uses.
 
 You can do either by editing php.ini
 
 -Brent
 
 
 
 - Original Message -
 From: Josh Close [EMAIL PROTECTED]
 To: PHP [EMAIL PROTECTED]
 Sent: Wednesday, September 01, 2004 1:08 PM
 Subject: [PHP] xml tags interfere with php tags
 
  How do I get an xml tag to work with a php script?
 
  ?xml version=1.0?
 
  php is trying to parse that.
 
  -Josh
 
  --
  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] xml tags interfere with php tags

2004-09-01 Thread Josh Close
I'll do something similar to this. I don't want to have to turn short
tags off :P

-Josh

On Wed, 1 Sep 2004 12:21:29 -0700, Michal Migurski [EMAIL PROTECTED] wrote:
 
 
  How do I get an xml tag to work with a php script?
 
  ?xml version=1.0?
 
  php is trying to parse that.
 
 ?= ''.'?xml version=1.0?'.'' ?
 
 ugly, huh?
 
 I'm not sure if there is a better way, but I use the above to prevent
 erroneous PHP parsing of xml declarations regardless of short_open_tags
 setting, and to keep my text editor's syntax highlighting from being
 fooled.
 
 
 michal migurski- contact info and pgp key:
 sf/cahttp://mike.teczno.com/contact.html
 


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



[PHP] Re: writing source code to file

2004-08-17 Thread Josh Acecool M
file_get_contents(http://www.yoursite.com/script.php;);

using http:// causes it to get the html source.
Hannes Magnusson [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 http://www.php.net/manual/en/ref.outcontrol.php

 On Mon, 16 Aug 2004 10:35:42 -0400
 [EMAIL PROTECTED] (Doug Parker) wrote:

  I was wondering if there was a block of code I could place at the bottom
of
  the file that would write the page's source code to an html file.  I
need
  this because I'm posting pages to a server sans a PHP compiler.
Basically,
  I'd like for every time I run a page its source code to be saved in the
  filename of my choice, instead of me having to run the page, copy the
  source, and paste it into the file of my choice. I know how to use
fopen,
  but I'm not sure what to tell it to write to file, since the source I
want
  to write is being generated simultaneously.
 
  Any help would be greatly appreciated...

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



Re: [PHP] System Tray Icon

2004-08-16 Thread Josh Acecool M
Hmm,
Simply make a RSS feed or something, md5 the last changed date of all files
combined every say 30 mins and put that in the rss file, have the systray
icon program look at that file every 5 mins or so, if the file has changed,
flash..
John Nichel [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Harlequin wrote:
  Hi all.
 
  I just wanted to throw this message in here and get some opinions before
I
  go off developing something So will post in the correct newsgroup later
  (when I find which newsgroup I need).
 
  Before I post a more thorough thread in the correct area I just wanted
to
  find out if this was achievable and what tools I'd need.
 
  Basically: I would like to drop a system tray icon onto the user's PC
that
  links them to a website. I'd also like to develop a separate one that
  flashes when a page is changed.
 
  How difficult would this be to do...? Would it mean using VB, could I
use
  something less expensive perhaps or is it just not possible at all...?
 

 Hfirst time I've ever seen this subject on this mailing list.
 We're charting new OT waters every day.

 -- 
 John C. Nichel
 ÜberGeek
 KegWorks.com
 716.856.9675
 [EMAIL PROTECTED]

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



[PHP] base64_decode an image, works on blank page, not on page where text is..

2004-08-09 Thread Josh Acecool M
If I try to base64_decode an image which was encoded with base64_encode on a
blank page, it works, if I try on a page with stuff already on it, it just
shows me the source code to the image...

Example: Run this code as a blank page, no spaces before or after the ?
then run it again with a space or a character..

Any ideas how to fix it?
Thanks.


?php
if (!function_exists(ac_call_base64_image)) {
function ac_call_base64_image ($Image) {
//require (./ACWB/ACWB_Base64_Images.php);
//$Image = $ACWB_B64I[$Image];
return base64_decode($Image);
}
}
// RedX Image...
$ACWB_B64I['ACWB'] =
R0lGODlhHAAeAKIAAP8AAP///8DAwICAgP///wAAACH5BAEAAAUALAAcAB4AAAO
COLrc7mGUSau9NuL  Np+5g9YXhSHbmuaXF81zsEMx0HQgELFmybeO6S89HA2Z2lSHxl
jsKaQDALDozipAUZZRabV6fNW43yAtvi15KDCoNcK1q7ERJhHv
krSWanNSPnWV+dgUxAoaHiIZpdxcEjo+QkHwqK3iUX5eVmZqbk  50efqFECQA7;
echo ac_call_base64_image ($ACWB_B64I['ACWB']);
?


PS: phpBB2 somehow got it to work, not sure how though :-/

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



Re: [PHP] Local version works - production breaks [SOLVED]

2004-08-08 Thread Josh Acecool M
Glad to hear turning reg globals off made it work :-)
I had suspected that because people often use the same variables for
different things and with globals on, well it can overwrite other vars.

Josh Acecool M [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 That might be something, with reg globals ON, on your server, and say you
 try to get $_GET['id'] and $SESSION['id'] will be the same, they might be
 overwriting themselves.

 Try setting register globals to OFF on your server, its also more secure.


 Try setting register globals to OFF on your server, its also
 more secure.


Andre Dubuc [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 On Sunday 08 August 2004 01:51 am, Jason Wong wrote:
  On Sunday 08 August 2004 09:38, Andre Dubuc wrote:
   That's what I thought. But the differences are glaring. Seems like
none
   of the code wants to work. Navigation is a nightmare:
   header(location:...); usually brings an error message: function so
and
   so -- include(xxx.php); has already been declared -- cannot
redeclare
   (yet locally - absolutely no problem!) ??
 
  IIRC older versions of PHP allowed multiple declarations of a function.
  Somewhere along the line this was changed.
 
  --
  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
  --
  /*
  God isn't dead.  He just doesn't want to get involved.
  */

 Hi Jason et al,

 Thought I'd drop a note -- turning register_globals=off on the server in
 question magically made everything work.

 Now I'll rasie the question that IP manager has asked: Having
 register_globals=of/on should not amke any difference to your site if you
are
 using $_POST, $_SESSION etc. You must have a bug in your code.

 Since exactly the same code works locally with register_globals=on or off,
I
 suspect the proble is at his end, not in the code. Am I right in assuming
 this?

 Regards, and thanks fro the help  sugegstions!
 Andre

 Hi Jason et al,

 Thought I'd drop a note -- turning register_globals=off on the server in
 question magically made everything work.

 Now I'll rasie the question that IP manager has asked: Having
 register_globals=of/on should not amke any difference to your site if you
are
 using $_POST, $_SESSION etc. You must have a bug in your code.

 Since exactly the same code works locally with register_globals=on or off,
I
 suspect the proble is at his end, not in the code. Am I right in assuming
 this?

 Regards, and thanks fro the help  sugegstions!
 Andre


 God isn't dead.  We just don't want to get involved.

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



[PHP] Re: Local version works - production breaks

2004-08-07 Thread Josh Acecool M
Did you check the phpinfo on each server, make sure your server settings are
same as local?


Andre Dubuc [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi,

 I have re-written a very basic website to use sessions (switching to
https)
 for login to special areas of a site. After testing the site thoroughly
 locally, I uploaded the whole shebang to a unix server that runs Apache
1.3.x
 + PHP 4.3.4 + mysql.

 Almost all code broke - sessions would load, but almost every page was so
 messed up that -- well, I'm flabbergasted!

 I'm wondering, after reading a few threads on my local config whether the
 problem might lie with the Apache2 server I use locally (Mandrake special
 with Extranet). I also use an older version of PHP 4.3.1.

 I've examined both configs for differences, but can see nothing that would
 account for such an extremely messed up site. It loads locally beautifully
 (and all admin pages work) in Opera, Galeon, Mozilla, + Konqueror. Loads
with
 errors to mysql db in all others but Konqueror which does not even display
 the opening page (yet I can view source).

 Maybe this isn't the forum to ask -- but seeing that all db access is
through
 PHP -- I wonder whether anyone can point where i can start looking for the
 culprit(s).

 Any ideas, suggestions, or advice will be greatly appreciated.

 Tia,
 Andre

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



[PHP] Re: Security Code w/o Image PHP

2004-08-07 Thread Josh Acecool M
You could make a few randomly named images (more = better security but wont
be very secure since the names can be put in a spam bot...) make them show
up, each name has a specific number etc...
Eugene Voznesensky [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 How to generate and check security code in PHP w/o images (gd)?

 Thank you.


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



Re: [PHP] Re: Local version works - production breaks

2004-08-07 Thread Josh Acecool M
That might be something, with reg globals ON, on your server, and say you
try to get $_GET['id'] and $SESSION['id'] will be the same, they might be
overwriting themselves.

Try setting register globals to OFF on your server, its also more secure.

Andre Dubuc [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Josh,

 Aside from the differences in php versions, the only difference is thta
the
 local version has register_globals=off.

 I'm really stumped.

 Andre

 On Sunday 08 August 2004 06:07 am, Josh Acecool M wrote:
  Did you check the phpinfo on each server, make sure your server settings
  are same as local?
 
 
  Andre Dubuc [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]
 
   Hi,
  
   I have re-written a very basic website to use sessions (switching to
 
  https)
 
   for login to special areas of a site. After testing the site
thoroughly
   locally, I uploaded the whole shebang to a unix server that runs
Apache
 
  1.3.x
 
   + PHP 4.3.4 + mysql.
  
   Almost all code broke - sessions would load, but almost every page was
so
   messed up that -- well, I'm flabbergasted!
  
   I'm wondering, after reading a few threads on my local config whether
the
   problem might lie with the Apache2 server I use locally (Mandrake
special
   with Extranet). I also use an older version of PHP 4.3.1.
  
   I've examined both configs for differences, but can see nothing that
   would account for such an extremely messed up site. It loads locally
   beautifully (and all admin pages work) in Opera, Galeon, Mozilla, +
   Konqueror. Loads
 
  with
 
   errors to mysql db in all others but Konqueror which does not even
   display the opening page (yet I can view source).
  
   Maybe this isn't the forum to ask -- but seeing that all db access is
 
  through
 
   PHP -- I wonder whether anyone can point where i can start looking for
   the culprit(s).
  
   Any ideas, suggestions, or advice will be greatly appreciated.
  
   Tia,
   Andre

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



Re: [PHP] Local version works - production breaks

2004-08-07 Thread Josh Acecool M
Try adding
if (!function_exists(function_name)) {
function function_name ($blah) {
// Function Code
}
}
for each function.

That will fix the redeclare problem which happens if you call your cards.php
file in more than 1 file..

Andre Dubuc [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Saturday 07 August 2004 10:11 pm, Robby Russell wrote:
  On Sat, 2004-08-07 at 19:00, Ed Lazor wrote:
   It could be that you have local error reporting set to none.  It could
   also be that you're using full paths when referencing files which then
   breaks when moving files to a new server.  Basically, there's a lot of
   possibilities and I'm not going to have much luck helping unless you
   include error messages.  My guess is that resolving a few errors will
   address a core problem and everything will start working.
  
   -Ed
 
  Yes, it's very possible that he isn't getting errors locally because his
  errors aren't on.
 
  Andre,
 
  You might check your error settings on your local server. You might even
  consider upgrading php on your local server to the same version and
  debugging.
 
  -Robby
 
  --
  /***
  * Robby Russell | Owner.Developer.Geek
  * PLANET ARGON  | www.planetargon.com
  * Portland, OR  | [EMAIL PROTECTED]
  * 503.351.4730  | blog.planetargon.com
  * PHP/PostgreSQL Hosting  Development
  /


 Robby,

 I just enabled log_errors locally. No errors (as I thought).

 Since I am hacking a previously written site, the problem seems to arise
most
 when accessing his pre-built functions across pages. For instance, he uses
a
 'cards.php' to store all display functions -- showleft() -- showcentre() ,
as
 well as the connect() function. Since its a persistent connection -- he
opens
 the db once, then performs various queries in it. However, since
'cards.php'
 has already been called once by a page that might require both showleft()
and
 showcentre() -- it barfs and says that it cannot 'redeclare' the
showleft()
 function that has already been declared??  That is really some weird -- 
 particularly when it works so well (as expected) locally - and also since
I'm
 not 'redeclaring' but calling it for use!

 I cannot fathom why the production site would give this error. Perhaps I
need
 to do absolute paths for all headers? But it doesn't make sense that a
 function cannot be called many times -- declaring it once, yes, but
calling
 its use?? If that were the case, then one might as well write it out
longhand
 for each use, and forget the concept of 'functions'.

 I think I should look at the error logs for the site -- maybe they will
clue
 me in where I should look.

 Thanks,
 Andre

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



Re: [PHP] Re: [PHP-DB] Eval a file, and it gives parse error because it uses a preg_match statement with \$

2004-08-06 Thread Josh Acecool M
I dont have magic_quotes etc on, so when I use file_get_contents the EXACT,
yes, EXACT file gets placed.
Curt Zirzow [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 * Thus wrote Josh Acecool M:
  You dont understan..

 Not anymore. Honestly I haven't had a clue what was going on till
 Justin pushed you into the right direction.


 
  Say the template is:
 
  Blah
  {CONTENT}
  adasdasd
 
  I want to preg_replace(/{CONTENT}/, include(blah.php), $text);

 the example I quoted didn't use include().  Dont use include, use
 file_get_contents().

 
 
  Curt Zirzow [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]
   * Thus wrote Josh Acecool M:
   
but, I am doing this.
   
$text = file_get_contents('templateFile.php');
$text = preg_replace('/something/',
file_get_contents(something.php),
$text);
eval(? . $text . ?)
  
   This is rather an odd thing to do, kinda like taking an html
   document converting it to xml, add an element, then turning it back
   to html.
  
   To get around your \$ problem..
 see http://php.net/preg_quote

 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



[PHP] Re: IMPORTANT: Please Verify Your Message

2004-08-06 Thread Josh Acecool M
Stop E-Mailing me.
http://www.acecoolco.com/legal.php

- Original Message - 
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, August 06, 2004 2:10 AM
Subject: IMPORTANT: Please Verify Your Message


 html

 head
 meta http-equiv=Content-Type content=text/html; charset=windows-1252
 titleVerify Email/title
 /head

 body

 pfont face=Verdana size=2Hello [EMAIL PROTECTED] ,br
 br
 [EMAIL PROTECTED] is currently protecting themselves from
receiving junk mail using A
HREF=http://www.spamcease.com/cart/affiliate.php?id=3;Spamcease/A

 Just this once, click the link below so I can receive your emails.br
 You won't have to do this again.br
 br
 a
href=http://www.tgpwizards.com/spamcease2/verify.php?id=3964254;http://www
.tgpwizards.com/spamcease2/verify.php?id=3964254/abr
 /font/p

 /body

 /html



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



[PHP] Re: IMPORTANT: Please Verify Your Message

2004-08-06 Thread Josh Acecool M
I've requested that you do not contact me again.
http://www.acecoolco.com/legal.php

Please read the E-mail section properly.

- Original Message - 
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, August 06, 2004 3:10 AM
Subject: IMPORTANT: Please Verify Your Message


 html

 head
 meta http-equiv=Content-Type content=text/html; charset=windows-1252
 titleVerify Email/title
 /head

 body

 pfont face=Verdana size=2Hello [EMAIL PROTECTED] ,br
 br
 [EMAIL PROTECTED] is currently protecting themselves from
receiving junk mail using A
HREF=http://www.spamcease.com/cart/affiliate.php?id=3;Spamcease/A

 Just this once, click the link below so I can receive your emails.br
 You won't have to do this again.br
 br
 a
href=http://www.tgpwizards.com/spamcease2/verify.php?id=3976686;http://www
.tgpwizards.com/spamcease2/verify.php?id=3976686/abr
 /font/p

 /body

 /html



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



Re: [PHP] Re: [PHP-DB] Eval a file, and it gives parse error because it uses a preg_match statement with \$

2004-08-05 Thread Josh Acecool M
The files that are evaled work perfectly without being evaled.

I dont think eval was meant for large files etc.

Whats on that like: a preg_match that looks for \$variable = something;

and thats the like it messes up on.

Also, if the file which is evaled includes another file, the variables from
the included file wont get parsed or anything, and the variables set to it
by the first file, or the class dont work at all.

John Holmes [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Josh Acecool M wrote:
var $The_Template_Sys;
  
  $this - The_Template_Sys = file_get_contents($The_Template_File);
  
  $this - Sub_Template = TRUE;
  Any ideas?

 I have an idea I said in a previous email!

 you say you're getting a parse error. How could anyone possibly help you
 troubleshoot that parse error unless they had an example of what was in
 the file being eval()'d??

 What is actually in the file that's failing the eval()??!?!?! What line
 of the file is failing? What is on that line? What's on the couple of
 lines before it? What's on the couple of lines after that line that's
 failing? What does the line with the eval() call look like? Are you
 doing anything else with $this-The_Template_Sys before it's
eval()'d??

 -- 

 John Holmes

 php|architect - The magazine for PHP professionals -
http://www.phparch.com

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



Re: [PHP] Re: [PHP-DB] Eval a file, and it gives parse error because it uses a preg_match statement with \$

2004-08-05 Thread Josh Acecool M
5.0.0

Include WORKS, but using INCLUDE with PREG_REPLACE does NOT work, the text
you want to replace gets deleted and the INCLUDE includes on the top of the
page...

Justin Patrin [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Thu, 5 Aug 2004 09:51:10 -0700, Josh Acecool M
 [EMAIL PROTECTED] wrote:
  The files that are evaled work perfectly without being evaled.
 
  I dont think eval was meant for large files etc.
 
  Whats on that like: a preg_match that looks for \$variable = something;
 
  and thats the like it messes up on.
 
  Also, if the file which is evaled includes another file, the variables
from
  the included file wont get parsed or anything, and the variables set to
it
  by the first file, or the class dont work at all.
 

 What version of PHP are you using?

 Are you doing anything to the string before eval-ing it? You say that
 if you just include() is, it works fine. *Why* not just include it,
 then?

  John Holmes [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]
 
 
   Josh Acecool M wrote:
  var $The_Template_Sys;

$this - The_Template_Sys =
file_get_contents($The_Template_File);

$this - Sub_Template = TRUE;
Any ideas?
  
   I have an idea I said in a previous email!
  
   you say you're getting a parse error. How could anyone possibly help
you
   troubleshoot that parse error unless they had an example of what was
in
   the file being eval()'d??
  
   What is actually in the file that's failing the eval()??!?!?! What
line
   of the file is failing? What is on that line? What's on the couple of
   lines before it? What's on the couple of lines after that line that's
   failing? What does the line with the eval() call look like? Are you
   doing anything else with $this-The_Template_Sys before it's
  eval()'d??
  
   --
  
   John Holmes
  
   php|architect - The magazine for PHP professionals -
  http://www.phparch.com
 

 -- 
 DB_DataObject_FormBuilder - The database at your fingertips
 http://pear.php.net/package/DB_DataObject_FormBuilder

 paperCrane --Justin Patrin--


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



Re: [PHP] Re: [PHP-DB] Eval a file, and it gives parse error because it uses a preg_match statement with \$

2004-08-05 Thread Josh Acecool M
IF I do this:

$text = file_get_contents('templateFile.php');
$text = preg_replace('/something/', include(something.php), $text);
then it gets put ON TOP of the file, not where something is...

see what I am saying?

but, I am doing this.

$text = file_get_contents('templateFile.php');
$text = preg_replace('/something/', file_get_contents(something.php),
$text);
eval(? . $text . ?)

Justin Patrin [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Thu, 5 Aug 2004 21:42:58 -0700, Josh Acecool M
 [EMAIL PROTECTED] wrote:
  5.0.0
 
  Include WORKS, but using INCLUDE with PREG_REPLACE does NOT work, the
text
  you want to replace gets deleted and the INCLUDE includes on the top of
the
  page...

 You're not making senseyou're saying that using preg_replace *in*
 the included code doesn't work? That can't be what you mean.

 Including a file does *not* include it at the top of the page. It's
 included wherever you put the include statement. You can put them
 *anywhere*, not just at the top of the page. See the DB::connect()
 method in PEAR DB for an example.

 http://cvs.php.net/co.php/pear/DB/DB.php?r=1.59

 If what you're saying is that the output goes to the browser, you can
 use the output buffering functions to catch the output.

 http://us3.php.net/manual/en/ref.outcontrol.php

 If what you're doing is similar to this:
 $text = file_get_contents('templateFile.php');
 $text = preg_replace('/something/', 'something else', $text);
 eval($text);

 Then you *are* changing the text before eval-ing it (you never
 answered the many questions about this). If this is what you are
 doing, then it sounds like the issue is not in the eval or the
 included file, but in the preg_replace. Please give us the exact
 preg_replace line that you are using and what it is supposed to do so
 we can help with your regex.

 
  Justin Patrin [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]
 
 
   On Thu, 5 Aug 2004 09:51:10 -0700, Josh Acecool M
   [EMAIL PROTECTED] wrote:
The files that are evaled work perfectly without being evaled.
   
I dont think eval was meant for large files etc.
   
Whats on that like: a preg_match that looks for \$variable =
something;
   
and thats the like it messes up on.
   
Also, if the file which is evaled includes another file, the
variables
  from
the included file wont get parsed or anything, and the variables set
to
  it
by the first file, or the class dont work at all.
   
  
   What version of PHP are you using?
  
   Are you doing anything to the string before eval-ing it? You say that
   if you just include() is, it works fine. *Why* not just include it,
   then?
  
John Holmes [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
   
   
 Josh Acecool M wrote:
var $The_Template_Sys;
  
  $this - The_Template_Sys =
  file_get_contents($The_Template_File);
  
  $this - Sub_Template = TRUE;
  Any ideas?

 I have an idea I said in a previous email!

 you say you're getting a parse error. How could anyone possibly
help
  you
 troubleshoot that parse error unless they had an example of what
was
  in
 the file being eval()'d??

 What is actually in the file that's failing the eval()??!?!?! What
  line
 of the file is failing? What is on that line? What's on the couple
of
 lines before it? What's on the couple of lines after that line
that's
 failing? What does the line with the eval() call look like? Are
you
 doing anything else with $this-The_Template_Sys before it's
eval()'d??

 --

 John Holmes

 php|architect - The magazine for PHP professionals -
http://www.phparch.com
   
  
   --
   DB_DataObject_FormBuilder - The database at your fingertips
   http://pear.php.net/package/DB_DataObject_FormBuilder
  
   paperCrane --Justin Patrin--
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 

 -- 
 DB_DataObject_FormBuilder - The database at your fingertips
 http://pear.php.net/package/DB_DataObject_FormBuilder

 paperCrane --Justin Patrin--

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



Re: [PHP] Re: [PHP-DB] Eval a file, and it gives parse error because it uses a preg_match statement with \$

2004-08-05 Thread Josh Acecool M
You dont understan..

Say the template is:

Blah
{CONTENT}
adasdasd

I want to preg_replace(/{CONTENT}/, include(blah.php), $text);

blah.php contains Hello!

This is what appears

Hello!
Blah
adasdasd


Curt Zirzow [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 * Thus wrote Josh Acecool M:
 
  but, I am doing this.
 
  $text = file_get_contents('templateFile.php');
  $text = preg_replace('/something/', file_get_contents(something.php),
  $text);
  eval(? . $text . ?)

 This is rather an odd thing to do, kinda like taking an html
 document converting it to xml, add an element, then turning it back
 to html.

 To get around your \$ problem..
   see http://php.net/preg_quote


 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



[PHP] Re: [PHP-DB] Eval a file, and it gives parse error because it uses a preg_match statement with \$

2004-08-04 Thread Josh Acecool M
Any ideas?

John Holmes [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Josh Acecool M wrote:
var $The_Template_Sys;
 
  $this - The_Template_Sys = file_get_contents($The_Template_File);
 
  $this - Sub_Template = TRUE;

 Please respond to the list and not me personally.

 you say you're getting a parse error. How could anyone possibly help you
 troubleshoot that parse error unless they had an example of what was in
 the file being eval()'d??

 -- 

 John Holmes

 php|architect - The magazine for PHP professionals -
http://www.phparch.com

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



[PHP] javascript type cast

2004-08-03 Thread Josh Close
Is there any way to do a typecast in javascript? I know you can in
2.0, but that won't work here.

I have an input field and I need to add a number to it's value. 

var + 123 == 'var123'

You would think that it would automatically typecast var to an int
since it's being added to one, but it just concatenates it instead.

How can I add (or sum) the two values?

P.S. I'm doing this in a php page... that's why I'm asking here.

-Josh

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



[PHP] Re: javascript type cast

2004-08-03 Thread Josh Close
...I found you can do var*1 to get it to type cast.

Thanks.

-Josh



On Tue, 3 Aug 2004 11:28:16 -0500, Josh Close [EMAIL PROTECTED] wrote:
 Is there any way to do a typecast in javascript? I know you can in
 2.0, but that won't work here.
 
 I have an input field and I need to add a number to it's value.
 
 var + 123 == 'var123'
 
 You would think that it would automatically typecast var to an int
 since it's being added to one, but it just concatenates it instead.
 
 How can I add (or sum) the two values?
 
 P.S. I'm doing this in a php page... that's why I'm asking here.
 
 -Josh


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



Re: [PHP] javascript type cast

2004-08-03 Thread Josh Close
Yes, but most php users do some web programming and might have come
across this before.

-Josh

On Tue, 3 Aug 2004 12:34:40 -0400, John Nichel [EMAIL PROTECTED] wrote:
 On Tuesday 03 August 2004 12:28, Josh Close wrote:
  P.S. I'm doing this in a php page... that's why I'm asking here.
 
 But this doesn't make it a php problem.
 
 --
 John C. Nichel
 ÜberGeek
 KegWorks.com
 716.856.9675
 [EMAIL PROTECTED]
 
 --
 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] javascript type cast

2004-08-03 Thread Josh Close
Wow, no need to be an ass. I just wanted a little help and this list
is usually pretty friendly and willing to help. but I guess not.



On Wed, 4 Aug 2004 01:01:47 +0800, Jason Wong [EMAIL PROTECTED] wrote:
 On Wednesday 04 August 2004 00:38, Josh Close wrote:
  Yes, but most php users do some web programming and might have come
  across this before.
 
 Most people on this list eat as well, but that doesn't make this list an
 appropriate forum for discussing food.
 
 --
 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
 --
 /*
 Time will end all my troubles, but I don't always approve of Time's methods.
 */
 
 
 
 --
 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] javascript type cast

2004-08-03 Thread Josh Close
Ok. I write most my web apps in php. I rarely will use js for
anything, but I needed it on this rare occasion. I didn't want to have
to post to the same php page to get the results to change, so I though
a little js would do the job.

Being a php list, I thought that a few others would have run into the
same issue while doing this. Would it have made it better if I talked
a little about the php work that was being done on the page also?

All this is doing is making me like php less and less. And what about
the newer users to the list? This also makes me not want to answer
other peoples questions either. I've also noticed that a lot of
answers to peoples questions get flamed on this list also. It's like
you think you're better than them and came take them down for whatever
reason.

Yes, the question was OT and I knew it. Yes, I found the answer via
google 5-10 mins later. I had already searched a while before for it.
And I'm not going to go and get on a js list for one question I may
have once every 3 months. I figured someone here has ran into the same
situation before. Especially since type casting is a common thing
among most languages (even php).

All I have to say is, sorry I asked. I really wasn't worth it.

-Josh



On Tue, 03 Aug 2004 13:09:19 -0500, Alex Hogan
[EMAIL PROTECTED] wrote:
 I have been on a number of lists over the years, as what ever technology
 I'm using at the time has demanded.
 
 I would have to say that this list is one of the most curt and
 condescending lists I've ever been on.  Perhaps it's because the long
 time users don't realize they're being so, (unless of course you read
 the FAQ about asking smart questions which they are so happy to throw at
 you), or maybe it's because they are so much better at this particular
 technology that they don't have to even be civil.
 
 What ever the reason it leaves a bad impression for anyone embracing php
 and wanting to gather additional information that can sometimes only be
 obtained from an individual with experience and not a book. (imagine
 that)
 
 Now I fully expect that some one will come back and say something like,
 Well you don't have to stay on this list or something equally as
 moronic.  Quite frankly I don't care.  Flame away...
 
 Over the last seven months that I have been on this list I have seen the
 same questions addressed several times.  Sometimes worded different, but
 nothing really new.  Maybe that is what creates such animosity to the
 newer members of this list from the older ones.  Then again maybe it's
 nothing more than the age old trait of chastising someone else to give
 themselves a feeling of importance.
 
 My point is a little temperance goes a lot farther and shows a lot more
 than self importance.
 
 BTW.., Yes I'm top posting so go ahead and flame away for that too.
 
 alex hogan
 
 
  -Original Message-
  From: Vail, Warren [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, August 03, 2004 12:38 PM
  To: 'Jason Wong'; [EMAIL PROTECTED]
  Subject: RE: [PHP] javascript type cast
 
  I, for one, am not convinced that this all that far off topic.
 
  Since the accepted method to generate browser interaction
  with server side PHP, is to use Javascript, it doesn't seem
  any more off-topic than dealing with database questions about MySQL.
 
  I am probably like most PHP developers, with a very weak
  knowledge of Javascript, and while that makes the question
  feel like being off-topic, I'm not sure it should be.  I
  wish I knew of another list I could recommend as a resource
  for Javascript, but I don't, and that is probably a result of
  knowing so little.
 
  Only abuse occurring here, IMHO is the content police's
  treatment of Josh.
  
  Warren Vail
 *
 The contents of this e-mail and any files transmitted with it are confidential and
 intended solely for the use of the individual or entity to whom it is addressed. The
 views stated herein do not necessarily represent the view of the company. If you are
 not the intended recipient of this e-mail you may not copy, forward, disclose, or
 otherwise use it or any part of it in any form whatsoever. If you have received this
 e-mail in error please e-mail the sender.
 *
 
 
 
 --
 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] Re: [PHP-DB] Eval a file, and it gives parse error because it uses a preg_match statement with \$

2004-08-03 Thread Josh Acecool M
It has a preg_match in there that looks for \$variable = blah;

I cant help that a file works without Eval, and then to eval it, it messes
it up...

John Holmes [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Josh Acecool M wrote:
var $The_Template_Sys;
 
  $this - The_Template_Sys = file_get_contents($The_Template_File);
 
  $this - Sub_Template = TRUE;

 Please respond to the list and not me personally.

 you say you're getting a parse error. How could anyone possibly help you
 troubleshoot that parse error unless they had an example of what was in
 the file being eval()'d??

 -- 

 John Holmes

 php|architect - The magazine for PHP professionals -
http://www.phparch.com

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



Re: [PHP] javascript type cast

2004-08-03 Thread Josh Close
On Tue, 03 Aug 2004 14:15:32 -0500, Alex Hogan
[EMAIL PROTECTED] wrote:
 
  All I have to say is, sorry I asked.
 
 OK.., now you're really making me want to take a poke at you.
 
 You posted off topic, knew it was off topic, you got spanked for it.
 
 Don't make things worse by whining.

Not trying to whine for you. I was just surprised that people would
take several hours out of their day to complain about this, instead of
just saying it's OT and to not post OT.

I won't happen again, so you can stop whining.

-Josh

 
 alex hogan
 
 
 *
 The contents of this e-mail and any files transmitted with it are confidential and
 intended solely for the use of the individual or entity to whom it is addressed. The
 views stated herein do not necessarily represent the view of the company. If you are
 not the intended recipient of this e-mail you may not copy, forward, disclose, or
 otherwise use it or any part of it in any form whatsoever. If you have received this
 e-mail in error please e-mail the sender.
 *
 
 --
 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] javascript type cast OT

2004-08-03 Thread Josh Close
On Tue, 3 Aug 2004 15:30:20 -0400, John Nichel [EMAIL PROTECTED] wrote:
 On Tuesday 03 August 2004 14:54, Alex Hogan offered up the following tid-bit
 of information :
  However there is a difference between list courtesy and blatant
  aggression.  I understand that there are going to be more newbie's to
  programming here than on most language lists.  Does this mean that they
  don't get the same consideration that those get who it is apparent that
  they have been hacking code for a while?
 
  This is a general list.
 
 And when 'newbies' sign up to this list, they get a copy of the 'Newbie
 Guide', with a wealth of information on how to ask smart questions, how to
 find answers to common problems, etc.  If they are not going to use that
 advice, and just blast the list with an OT question, or one that's been
 asked a zillion times, why should we take the time out to help those who
 are not going to help themselves?

Well, you shouldn't. But you did take the time to flame on and on and
on and on (not you specifically).

 
 
 --
 John C. Nichel
 ÜberGeek
 KegWorks.com
 716.856.9675
 [EMAIL PROTECTED]
 
 --
 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] Re: [PHP-DB] Eval a file, and it gives parse error because it uses a preg_match statement with \$

2004-08-03 Thread Josh Acecool M
Also, variables do not get passed correctly from the engine to the evaluated
pages.


Josh Acecool M [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 It has a preg_match in there that looks for \$variable = blah;

 I cant help that a file works without Eval, and then to eval it, it messes
 it up...

 John Holmes [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Josh Acecool M wrote:
 var $The_Template_Sys;
  
   $this - The_Template_Sys = file_get_contents($The_Template_File);
  
   $this - Sub_Template = TRUE;
 
  Please respond to the list and not me personally.
 
  you say you're getting a parse error. How could anyone possibly help you
  troubleshoot that parse error unless they had an example of what was in
  the file being eval()'d??
 
  -- 
 
  John Holmes
 
  php|architect - The magazine for PHP professionals -
 http://www.phparch.com

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



Re: [PHP] Re: [PHP-DB] Eval a file, and it gives parse error because it uses a preg_match statement with \$

2004-08-03 Thread Josh Acecool M
Globals are off,
Magic_quotes are off
The file is the same
I cant use include with a preg_replace (I replace X with file_get_contents
blah because if I dont then the file thats included wont be included in
place of the replaced variable, it will be included on the top of the page
and not where its supposed to me.)

And using buffer is 8x slower than eval.

Justin Patrin [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Tue, 3 Aug 2004 12:11:02 -0700, Josh Acecool M
 [EMAIL PROTECTED] wrote:
  It has a preg_match in there that looks for \$variable = blah;
 
  I cant help that a file works without Eval, and then to eval it, it
messes
  it up...

 And why again are you using *eval* on a file? Why not
 include('file.php')? If you're doing parsing on the file contents,
 look there for your problem. It's likely you're adding backslashes
 somewhere. Look at the contents of the string you're trying to eval
 and see if it looks the same as the file you want to run. If not,
 that's your problem.

 If you're not adding slashes, perhaps magic_quotes_runtime or
 magic_quotes_gpc is? (These are php.ini settings)

 What vars aren't getting passed in? Globals? Looks like this is OOP,
 in which case globals aren't in scope while you're in a function. You
 call a function to run the template and the globals are automtically
 out of scope. You can do several things here.
 1) Use $GLOBALS['varname'] instead of $varname in your eval'd script.
 2) If you're using globals for request vars (GET or POST) then you
 should switch to the superglobals $_GET and $_POST (or $_REQUEST).
 3) global everything in $GLOBALS before you run eval()
   foreach ($GLOBALS as $key = $val) {
 $$key = $GLOBALS[$key];
   }

 If none of this works, perhaps safe mode is stopping this? (I'm not
 sure if it even can, but it's a possibility.)

 
  John Holmes [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]
 
 
   Josh Acecool M wrote:
  var $The_Template_Sys;
   
$this - The_Template_Sys = file_get_contents($The_Template_File);
   
$this - Sub_Template = TRUE;
  
   Please respond to the list and not me personally.
  
   you say you're getting a parse error. How could anyone possibly help
you
   troubleshoot that parse error unless they had an example of what was
in
   the file being eval()'d??
  
   --
  
   John Holmes
  
   php|architect - The magazine for PHP professionals -
  http://www.phparch.com
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
  !DSPAM:410fe2cd117221951811678!
 
 


 -- 
 DB_DataObject_FormBuilder - The database at your fingertips
 http://pear.php.net/package/DB_DataObject_FormBuilder

 paperCrane --Justin Patrin--

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



Re: [PHP] Re: [PHP-DB] Eval a file, and it gives parse error because it uses a preg_match statement with \$

2004-08-03 Thread Josh Acecool M
Another note:

I code for globals off.

Justin Patrin [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Tue, 3 Aug 2004 12:11:02 -0700, Josh Acecool M
 [EMAIL PROTECTED] wrote:
  It has a preg_match in there that looks for \$variable = blah;
 
  I cant help that a file works without Eval, and then to eval it, it
messes
  it up...

 And why again are you using *eval* on a file? Why not
 include('file.php')? If you're doing parsing on the file contents,
 look there for your problem. It's likely you're adding backslashes
 somewhere. Look at the contents of the string you're trying to eval
 and see if it looks the same as the file you want to run. If not,
 that's your problem.

 If you're not adding slashes, perhaps magic_quotes_runtime or
 magic_quotes_gpc is? (These are php.ini settings)

 What vars aren't getting passed in? Globals? Looks like this is OOP,
 in which case globals aren't in scope while you're in a function. You
 call a function to run the template and the globals are automtically
 out of scope. You can do several things here.
 1) Use $GLOBALS['varname'] instead of $varname in your eval'd script.
 2) If you're using globals for request vars (GET or POST) then you
 should switch to the superglobals $_GET and $_POST (or $_REQUEST).
 3) global everything in $GLOBALS before you run eval()
   foreach ($GLOBALS as $key = $val) {
 $$key = $GLOBALS[$key];
   }

 If none of this works, perhaps safe mode is stopping this? (I'm not
 sure if it even can, but it's a possibility.)

 
  John Holmes [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]
 
 
   Josh Acecool M wrote:
  var $The_Template_Sys;
   
$this - The_Template_Sys = file_get_contents($The_Template_File);
   
$this - Sub_Template = TRUE;
  
   Please respond to the list and not me personally.
  
   you say you're getting a parse error. How could anyone possibly help
you
   troubleshoot that parse error unless they had an example of what was
in
   the file being eval()'d??
  
   --
  
   John Holmes
  
   php|architect - The magazine for PHP professionals -
  http://www.phparch.com
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
  !DSPAM:410fe2cd117221951811678!
 
 


 -- 
 DB_DataObject_FormBuilder - The database at your fingertips
 http://pear.php.net/package/DB_DataObject_FormBuilder

 paperCrane --Justin Patrin--

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



[PHP] Re: [tcphp] alternating highlights

2004-08-03 Thread Josh Close
This is very simple actually

?

$result = mysql_query($sql);
$flag = 0;
while($row = mysql_fetch_array($result)){
  $field1 = $row['field1'];
  $field2 = $row['field2'[;

  if($flag){
  ?
  tr style=background: blue;
td?=$field1?/td
  /tr
  ?
$flag = 1;
  }
  else{
  ?
  tr
td?=$field1?/td
  /tr
  ?
$flag = 0;
  }
}

?

That was very quick, but I hope it helps.

-Josh

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



[PHP] multiple checkboxes

2004-08-02 Thread Josh Close
Very simple question.

When making multiple checkboxes, you put the name the same for a few
to group them together

form action=process.php method=post
input type=checkbox name=checkBoxGroup value=first /
input type=checkbox name=checkBoxGruop value=second /
/form

So they are grouped but then submitting them I only get the last
value check.

? print_r($_POST); ?

How would I get all the boxes check when grouping them by using the
same name for all checkboxes in the name field?

-Josh

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



Re: [PHP] freeTDS

2004-07-27 Thread Josh Close
Well, they're going to have to install php with mssql support also

./configure --with-mssql --with-freetds

there are examples in the freetds.conf file of what you need to do.
Basically just telling it where to connect.

-Josh


On Tue, 27 Jul 2004 16:49:37 -0400, John Nichel [EMAIL PROTECTED] wrote:
 
 
 Edward Peloke wrote:
  no, I don't see any mssql info...and yes, they said they did recompile with
  freetds.  If there anything I have to change in the freetds conf file or in
  php.ini?
 snip
 
 Then either :
 
 A) It hasn't been compiled with FreeTDS or,
 B) The web server hasn't been restarted.
 
 --
 John C. Nichel
 ÜberGeek
 KegWorks.com
 716.856.9675
 [EMAIL PROTECTED]
 
 --
 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: how to use session?

2004-07-21 Thread Josh Close
you have to have the session_start before ANY output, including
html, so do this

?

session_start()

?
html



On Thu, 22 Jul 2004 00:56:44 +0800, Sheawh
[EMAIL PROTECTED] wrote:
 even   Example: page1.php
 I got the same result,
 and what if i set session auto start ??
 is that means it starts a new session when accessing a HTML?
 
 HTML
  
 ?php
 // page1.php
 
 session_start();
 
 echo 'Welcome to page #1';
 
 $_SESSION['favcolor'] = 'green';
 $_SESSION['animal']  = 'cat';
 $_SESSION['time']= time();
 
 // Works if session cookie was accepted
 echo 'br /a href=page2.phppage 2/a';
 
 echo SID :  . session_id();
 // Or maybe pass along the session id, if needed
 echo 'br /a href=page2.php?' . SID . 'page 2/a';
 ?
  /HTML
 
 Torsten Roehr [EMAIL PROTECTED] ¦b¶l¥ó
 news:[EMAIL PROTECTED] ¤¤¼¶¼g...
 
 
  Sheawh [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]
   I have started a session using  session_start();
   but it returns :
  
   Warning: Cannot send session cookie - headers already sent by (output
   started at c:\inetpub\wwwroot\diary\index.php:7) in
   c:\inetpub\wwwroot\diary\reg_session.php on line 11
  
   Warning: Cannot send session cache limiter - headers already sent
 (output
   started at c:\inetpub\wwwroot\diary\index.php:7) in
   c:\inetpub\wwwroot\diary\reg_session.php on line 11
  
  
   If I don't want to use session cookie , how to set it?
   thanks.
 
  No output is allowed before starting the session. Look at the user
 comments
  in the manual and search the mailing list archives.
 
  Regards, Torsten Roehr
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


-- 
-Josh

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



Re: [PHP] Re: Book Required

2004-07-17 Thread Josh Close
Here's a php5 book, and there's a few others.

http://www.oreilly.com/catalog/learnphp5/index.html


On Sat, 17 Jul 2004 19:28:37 +0100, Lester Caine [EMAIL PROTECTED] wrote:
 Tularis wrote:
 
  Programming PHP by O`Reilly :)
 
 Write-up says it STILL uses MySQL as it's database material ;(
 
 Since I'm pushing PHP5 into all new sites, I'll wait for a PHP5 book :)
 
 The Firebird Bible ( which has taken two years to write ) is being
 printed at the moment and should be out by next month - not sure how
 much of the PHP chapters actually made it in the final manuscript.
 
 
 
 --
 Lester Caine
 -
 L.S.Caine Electronic Services
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


-- 
-Josh

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



[PHP] php 4.3.7/5.0

2004-07-13 Thread Josh Close
I've noticed that in the last release of php 4.3.7 (or 5.0.0), that
when checking the value of a variable has changed.

ex:

if($var){ /* do something */ }

doesn't work anymore. I've had to change code to

if($var  0)

but the problem is, what if $var was converted to $var = 0 instead
of $var = 0 somewhere throughout the code that I didn't know about?

Is there a way to be sure what's going on here?

-- 
-Josh

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



Re: [PHP] php 4.3.7/5.0

2004-07-13 Thread Josh Close
Well, the actual code is hard to tell. It's grabbed from a db so it
should be an int. But it's also run through some functions. That's why
I'd like a to tell what's going on better.

The variable is always set. Basically

$result = mssql_query($sql);
$row = mssql_fetch_array($result);
$var = $row[0];

So it should be an int. And if it's copied into a function it
shouldn't be changed.

But doing

if($var)

doesn't seem to work after I upgraded versions. Which is making me
think that they changed how that works.

And using is_string() or is_int() is pointless 'cause it doesn't
matter. I just want to know if the value != 0.

The problem is, if 0 gets changed to 0 somewhere throughout. That's
why I've always used if($var) because it's usually not cared what the
type is, but it seems to now.



On Tue, 13 Jul 2004 19:39:09 +, Curt Zirzow
[EMAIL PROTECTED] wrote:
 * Thus wrote Josh Close:
  I've noticed that in the last release of php 4.3.7 (or 5.0.0), that
  when checking the value of a variable has changed.
 
  ex:
 
  if($var){ /* do something */ }
  
 These values will all *not* do something:
 
   var_dump((bool) 0);
   var_dump((bool) array());
   var_dump((bool) );
   var_dump((bool) 0);
   var_dump((bool) null);
   var_dump((bool) false);
 
 
  doesn't work anymore. I've had to change code to
 
  if($var  0)
 
 what is the actual value of $var?
 
 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
 
 


-- 
-Josh

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



Re: [PHP] php 4.3.7/5.0

2004-07-13 Thread Josh Close
I think I'll just have to typecast everything, that should always work then.



On Tue, 13 Jul 2004 15:47:40 -0400, Adam Bregenzer [EMAIL PROTECTED] wrote:
 On Tue, 2004-07-13 at 15:35, Josh Close wrote:
  The problem is, if 0 gets changed to 0 somewhere throughout. That's
  why I've always used if($var) because it's usually not cared what the
  type is, but it seems to now.
 
 You can typecast values as well, this may be a good way to achieve what
 you are looking for:
 if ((int)$var != 0) {
   // Do Something
 }
 
 Also, if you are going to use this variable as an integer later you can
 do the following to explicitly convert $var into an integer:
 $var = (int)$var;
 
 That should convert 0 into the integer value 0.  Also, note the
 following:
 
 var_dump(0 == 0); //bool(true)
 var_dump(0 === 0);//bool(false)
 
 --
 Adam Bregenzer
 [EMAIL PROTECTED]
 http://adam.bregenzer.net/
 
 


-- 
-Josh

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



Re: [PHP] php 4.3.7/5.0

2004-07-13 Thread Josh Close
I'm positive that it will always be set, 'cause I set it. It's just
going the comparison.

if($var)

used to work for 

if($var != 0) or if($var != 0)

but that doesn't seem to work since I upgrade. So I'm just going to do

if((int)$var)

from now on, 'cause that should always work. I'll typecast everything
that being compared to and int to make sure.



On Tue, 13 Jul 2004 14:01:47 -0700 (GMT-07:00),
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 http://marc.theaimsgroup.com/?l=php-generalm=108646344905178w=2
 
 
 
 
 -Original Message-
 From: Matthew Sims [EMAIL PROTECTED]
 Sent: Jul 13, 2004 12:15 PM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP] php 4.3.7/5.0
 
  I've noticed that in the last release of php 4.3.7 (or 5.0.0), that
  when checking the value of a variable has changed.
 
  ex:
 
  if($var){ /* do something */ }
 
  doesn't work anymore. I've had to change code to
 
  if($var  0)
 
  but the problem is, what if $var was converted to $var = 0 instead
  of $var = 0 somewhere throughout the code that I didn't know about?
 
  Is there a way to be sure what's going on here?
 
  --
  -Josh
 
 What about the isset function? Or any of the following:
 
 http://us3.php.net/manual/en/ref.var.php
 
 --Matthew Sims
 --http://killermookie.org
 
 --
 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
 
 


-- 
-Josh

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



Re: [PHP] php 4.3.7/5.0

2004-07-13 Thread Josh Close
That sounds about right. It pretty much described the behavior between
the two versions.

Thanks for the info.


On Tue, 13 Jul 2004 18:44:06 -0500, Michael Sims
[EMAIL PROTECTED] wrote:
 Curt Zirzow wrote:
  * Thus wrote Josh Close:
  if($var)
 
  used to work for
 
  if($var != 0) or if($var != 0)
 
  but that doesn't seem to work since I upgrade. So I'm just going to
  do
 
  if((int)$var)
 
  I still think this is unnecessary
 
  if (0) { echo '0'; }
  if ()  { echo ''; }
  if (0)   { echo 0; }
 
  As I pointed out earlier, are still all the same; this behaviour
  hasn't changed.
 
 I agree.  As I pointed out in my earlier message in this thread, based on
 the description that the OP gave (and the fact that he's using
 mssql_query()), I think he's getting bitten by the problems introduced by
 the fix for bug #25777:
 
 http://bugs.php.net/bug.php?id=25777
 
 Basically PHP used to trim trailing spaces from data being returned via the
 mssql and sybase extensions, and the fix for the above bug (in both
 extensions) was to stop this trimming.  In my case this introduced a new
 problem, because bit fields that contain simply '0' in the database come
 back with trailing spaces.  While this:
 
 $ php -r 'if (0) echo Yes\n;'
 
 produces no output (because 0 == false) this does:
 
 $ php -r 'if (0 ) echo Yes\n;'
 
 because 0  != false.
 
 I have a hunch that if the OP does a print_r() on their $var, it will be a
 string that starts with zero and ends with one or more spaces.  Casting $var
 to int will restore the original behavior, but this is only because (int) 0
  === 0 and 0 == false.  So basically the cast to int does fix the OP's
 problem but not for the reasons he believes.
 
 Of course, that's a complete guess based off incomplete information.  I
 could be way off. :)
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


-- 
-Josh

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



Re: [PHP] php 4.3.7/5.0

2004-07-13 Thread Josh Close
That sounds about right. It pretty much described the behavior between
the two versions.

Thanks for the info.



On Tue, 13 Jul 2004 18:44:06 -0500, Michael Sims
[EMAIL PROTECTED] wrote:
 Curt Zirzow wrote:
  * Thus wrote Josh Close:
  if($var)
 
  used to work for
 
  if($var != 0) or if($var != 0)
 
  but that doesn't seem to work since I upgrade. So I'm just going to
  do
 
  if((int)$var)
 
  I still think this is unnecessary
 
  if (0) { echo '0'; }
  if ()  { echo ''; }
  if (0)   { echo 0; }
 
  As I pointed out earlier, are still all the same; this behaviour
  hasn't changed.
 
 I agree.  As I pointed out in my earlier message in this thread, based on
 the description that the OP gave (and the fact that he's using
 mssql_query()), I think he's getting bitten by the problems introduced by
 the fix for bug #25777:
 
 http://bugs.php.net/bug.php?id=25777
 
 Basically PHP used to trim trailing spaces from data being returned via the
 mssql and sybase extensions, and the fix for the above bug (in both
 extensions) was to stop this trimming.  In my case this introduced a new
 problem, because bit fields that contain simply '0' in the database come
 back with trailing spaces.  While this:
 
 $ php -r 'if (0) echo Yes\n;'
 
 produces no output (because 0 == false) this does:
 
 $ php -r 'if (0 ) echo Yes\n;'
 
 because 0  != false.
 
 I have a hunch that if the OP does a print_r() on their $var, it will be a
 string that starts with zero and ends with one or more spaces.  Casting $var
 to int will restore the original behavior, but this is only because (int) 0
  === 0 and 0 == false.  So basically the cast to int does fix the OP's
 problem but not for the reasons he believes.
 
 Of course, that's a complete guess based off incomplete information.  I
 could be way off. :)
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


-- 
-Josh

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



[PHP] warning: function registration failed

2004-07-12 Thread Josh Close
I installed php-5.0.0 and I get these error when doing php -v

PHP Warning:  Function registration failed - duplicate name -
mssql_connect in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name -
mssql_pconnect in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name -
mssql_close in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name -
mssql_select_db in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name -
mssql_query in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name -
mssql_free_result in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name -
mssql_get_last_message in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name -
mssql_num_rows in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name -
mssql_num_fields in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name -
mssql_fetch_field in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name -
mssql_fetch_row in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name -
mssql_fetch_array in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name -
mssql_fetch_object in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name -
mssql_data_seek in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name -
mssql_field_seek in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name -
mssql_result in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name -
mssql_min_error_severity in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name -
mssql_min_message_severity in Unknown on line 0
PHP Warning:  mssql:  Unable to register functions, unable to load in
Unknown on line 0

I'm using gentoo linux. I downgraded back to php-4x and I'm still
getting the errors.

What's going on here? How do I fix this?

Is it because gentoo now has both the mssql and freetds flags?


-- 
-Josh

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



[PHP] PHP / Email / ActionScript

2004-07-07 Thread Josh Eastgate
Hi,
 
I have made a shopping kart for a web site, in
flash...and I have it so when the shopping kart is
submitted...all the order details (variables) are sent
to a PHP file that sends the order to the businesses
email.
My main problem is with the PHP file. I dont know how
to use IF THEN ELSE statements within it. At the
moment I have it so that is sends 12 items details
even if the user has only ordered 5 or so. (so there
is allot of blank items) I want it so that it sends
the exact amount of items ordered (and their details)
to the businesses email.
 
Here is the php file (as a .txt):
http://chezanziar.com.au/PHP.txt
 
As you can seeat the moment it prints out 12 items
no matter what the case. I was thinking I could send a
variable to the PHP file (along with the other
information) that says how many items have been
orderedthen I could use some kind of loop (FOR
loop) to print the exact amount...the problem is I
dont know how to use FOR loops and IF THEN ELSE
statements within PHP...is it possible to use
these statements (FOR, IF) within the $EmailBody=??

Please help. 

Thank you.


Find local movie times and trailers on Yahoo! Movies.
http://au.movies.yahoo.com

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



[PHP] post without form

2004-07-07 Thread Josh Close
How can I post data without having it submitted from within a form?

With get I can just add it to the url. Is there a php function for this?

-- 
-Josh

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



  1   2   3   >