Re: [PHP] [php] while loop failure

2009-04-06 Thread Virgilio Quilario
 Does any one knows why while loop below ends after few loops when it meant
 to keep in loop?

 File name: while_loop_script.php

 define('run', 0);
 define('START', 10);

 while(START run){

 $ch = curl_init(mydomain/update_script.php?action=run);
 curl_exec($ch);
 curl_close($ch);

 }

 using php.exe to scheldule task it every 5 minutes:

 C:\php.exe D:\update\while_loop_script.php

 --
 www.willandy.co.uk


hi,

maybe you should put
error_reporting(E_ALL);
ini_set('display_errors', true);

with the setting above, run the script
C:\php.exe D:\update\while_loop_script.php

you should see errors when script ends.

virgil
http://www.jampmark.com

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



Re: [PHP] [php] while loop failure

2009-04-06 Thread Virgilio Quilario
 setting:

 max_execution_time = -1     ; Maximum execution time of each script, in
 seconds
 max_input_time = -1    ; Maximum amount of time each script may spend
 parsing request data
 ;max_input_nesting_level = 64 ; Maximum input variable nesting level
 memory_limit = 2036M      ; Maximum amount of memory a script may consume
 (128MB)

 the above setting should allowed script to execute indefinitely. is't it?


hi,

should it be this setting that allows the script to run forever?
max_execution_time = 0;

also when script runs from command line, max_execution_time defaults to zero.

cheers,
virgil
http://www.jampmark.com

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



Re: [PHP] [php] scheduled task in php

2009-04-02 Thread Virgilio Quilario
 Please how can you run a timed php script file via window scheduled task. or
 how can u execute a php script on a a time interval for instance every
 4minutes

hi Andrew,

first schedule a task, locate and select your php.exe, and schedule it
to run daily for the moment.
after creating it, you will see it listed on the window.
right click on it, and select properties.
on your Run box, add your script next to php.exe. ie
c:\path\to\php.exe myscript.php
click on schedule, click on advanced button, check on repeat task, put
4 on every box, and finally click on ok, then apply button.

that's it.

cheers,
virgil
http://www.jampmark.com

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



Re: [PHP] thread question

2009-04-01 Thread Virgilio Quilario
 Hi all,

 Another question:

 If a script starts to perform an operation and the user browses away will
 that terminate the thread perfoming the operation eg. the operation is
 aborted ?

 Mvh
 Toke

 the script is aborted as soon as server gets no response from the
 browser when it sent output to the browser.

 virgil
 http://www.jampmark.com

 Hi virgil,

 would that also apply to a script executed from the first script :

 example:

 if (do_stuff_which_takes_a_long_time){
  exec('php /path_toscript/script.phpsh');
 }

 would script.phpsh also be aborted if the connection is broken ?

 Regards,
 Toke

when exec starts running commands, php will wait until it ends.

virgil
http://www.jampmark.com

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



Re: [PHP] Error on .htaccess

2009-04-01 Thread Virgilio Quilario
 In all the servers i had tested my system i dont have any problem, but in
 this server the apache are displaying to me the error 500 Internal Server
 Error.

 Someone can say tome what is wront with my .htaccess?

 RewriteEngine On
 IfModule mod_rewrite.c
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond $1 !-d
 RewriteRule ^(.*)$ load.php?$1 [QSA,L]
 /IfModule

 This server are running PHP 5.2.9 and Apache 1.3.41 (Unix).

 Regards,
 Igor Escobar
 systems analyst  interface designer
 www . igorescobar . com


hi Igor,

try this and make sure load.php exist in your root web folder.

IfModule mod_rewrite.c
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !-d
RewriteRule ^(.*)$ /load.php?$1 [QSA,L]
/IfModule

not sure what you are trying to achieve with this line
RewriteRule ^(.*)$ /load.php?$1 [QSA,L]

i you mean to pass the query string, replace $1 with %{QUERY_STRING}

good luck

virgil
http://www.jampmark.com

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



Re: [PHP] thread question

2009-03-31 Thread Virgilio Quilario
 Hi all,

 Another question:

 If a script starts to perform an operation and the user browses away will
 that terminate the thread perfoming the operation eg. the operation is
 aborted ?

 Mvh
 Toke

the script is aborted as soon as server gets no response from the
browser when it sent output to the browser.

virgil
http://www.jampmark.com

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



Re: [PHP] PHPizabi - Applying php in TPL (smarty template engine)

2009-03-28 Thread Virgilio Quilario
 Well well I forgot to install Smarty, but show the message. Ididn't modify
 Smasrty.class.php. And index.tpl in libs directpory don't exist only the
 file in root.

 Anybody Can save me? I'm X confuss. All is new for me.

  Warning: Smarty error: unable to read resource: index.tpl in
 /home/lucianofelli/www/teste/smarty/libs/Smarty.class.php on line 1092


smarty wasn't able to read your tpl.
please see this page about troubleshooting smarty tpl
http://www.phpinsider.com/smarty-forum/viewtopic.php?t=4500

virgil
http://www.jampmark.com

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



Re: [PHP] foreach and form submission.

2009-03-28 Thread Virgilio Quilario
 Hi all.

 I'm writing a script that accepts several different forms with different 
 content. Depending on what data is sent with the form the script will do one 
 or the other think.

 Before the form data is processed I'd like to scrub it of HTML tags.

 I can do this manually as below but the form may have dozens of items of data 
 so I'd like to automate it.

 $_POST['name'] = strip_tags($_POST['name']);
 $_POST['address'] = strip_tags($_POST['address']);
 $_POST['phone'] = strip_tags($_POST['phone']);

 I saw a few lines of code once that used foreach  on the $_POST array 
 elements and it did not seem to matter how many or what names the elements 
 had.

 Conceptually like this

 foreach ($_POST - element) {
    $_POST-element = strip_tags($_POST-element)
 }

 Any ideas please ?

 Thanks.


here,

foreach ($_POST as $key = $value) {
  $_POST[$key] = strip_tags($value);
}

good luck.

virgil
http://www.jampmark.com

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



Re: [PHP] Calling function on the same line?

2009-03-28 Thread Virgilio Quilario

 I miss the utility to do stuff like that ... seriously ... but in any case:

 ?php
 echo ($f = 'str_replace') ? $f(a, b, aaa) : null;
 ?

 where echo is optional.

 Regards

you mean this
?= ($f = 'str_replace') ? $f(a,b,aaa) : null; ?

virgil
http://www.jampmark.com

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



Re: [PHP] Sort a multi-dimensional array on a certain key followed by another key

2009-03-28 Thread Virgilio Quilario
 Ok so, I have an array

 [0(index)][1st key][2nd key]

 Basically I don't care about the index. As a matter of fact I'd prefer it
 reset to still be in order afterwards.

 However, I need to sort the 1st key and keep correlation w the second key.
 Then sort on the second key.

 I have video volumes and scenes like

 [0][110][1]
 [1][110][3]
 [2][110][2]
 [3][110][4]

 Any help would be much appreciated.


looks like a job for array_multisort() function
http://php.net/array_multisort

virgil
http://www.jampmark.com

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



Re: [PHP] Problems with implode

2009-03-26 Thread Virgilio Quilario
 Dunno why you guys started talk about utf-8 problems, he has a list of
 ids
 which should contain only unsigned integers, otherwise I do not get how
 that
 query could work with an implode(',', $whatever) rather than 'id in
 ('.implode(',', array_map('mysql_real_escape_string', $whatever)).')'
 ...
 so, the problem could be more about missed ids in the array obtaining ,,
 ...
 so, in this case, array_filter before, no?

 it's certainly possible. but the way toke described his problem did not
 imply that his ids were unsigned integers.

 SELECT FROM ... WHERE id IN ('aardvark', 'abacus', 'abbey', ..., 'zulu',
 'zygote');




 AS written else it is not a problem with either implode nor with string,
 Only when sending debug info via unformatted mail.
 Which really should not give this problem, but it does one day I'll have
 time to figure out exactly what does trigger this error.

 Regards,
 Toke


it is probably the way the email message was formatted.
it has to cut long lines to email line length limit.
so you see some numbers are broken ie on different lines.

Virgil
http://www.jampmark.com

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



Re: [PHP] PHPizabi - Applying php in TPL (smarty template engine)

2009-03-26 Thread Virgilio Quilario
 Hi there!
 Any know how Can I use PHP code into Smarty Temple Engine (TPL files) ?
 I usued {php} include(text.php); {/php} but the code don't run simply
 output the code.
 What's the problem? Wht don't run?

 Thankx,
 Luciano Felli

it may be the file path.
try echoing something before the include and see if it shows.

here is a collection of smarty tips and techniques
http://www.jampmark.com/php-programming/16-very-useful-smarty-scripting-tips-and-techniques-to-make-templates-smarter.html

hope you find it useful.

good luck.

virgil

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



Re: [PHP] Script Analysis (was Conclusion of use strict...)

2009-03-21 Thread Virgilio Quilario
 Thanks,
 I downloaded Netbeans week or two ago and I found all that. I thought there
 is
 something more advanced (these things have any decent editor/ide (for
 example
 eclipse + pdt also have all that)). We are talking completely different
 level
 of checks :-) In the end I may switch to non-free version of Codenizer
 (unless
 someone points me how to check for at least non-initialized variables with
 Netbeans, and save me 20$ :-)


Hi Hans,

Is this what you are looking for?

Debug PHP code using Xdebug: You can inspect local variables, set
watches, set breakpoints, and evaluate code live. Navigate to
declarations, types and files using Go To shortcuts and hypertext
links.

It is from this url:
http://www.netbeans.org/features/php/

Or maybe this.
It highlights those variables not initialized.
See the screencast.
http://www.netbeans.org/kb/docs/php/php-editor-screencast.html

Maybe should try it sometime.

Best wishes,

Virgil
http://www.jampmark.com

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



Re: [PHP] [News] Affordable Independent Web Developer - Search Engine Optimization Services - March 19th, 2009

2009-03-21 Thread Virgilio Quilario
 As a matter of fact DANIEL ...I AM A REAL PERSON !

 You know, I really hate it that people like YOU reply back to me with your
 self-vain - self-important attitudes - and act like no one else on the F-ing
 planet has the right to live or even share the same air you breath

 YOU DANIEL are NOT that great! You are NO BETTER than me or anyone else
 here.

 As I CLEARLY state in my email, I work with other web developers in helping
 them do small menial work which just consumes their time and I have a crew
 of people willing to work and who just want to put FOOD on their TABLES! Do
 you understand that DANIEL?

 No one here is trying to OFFEND DANIEL HIS ALMIGHTY GREATNESSwe're just
 all trying to make the economy go around by generating business...or do
 I have to teach you about that as well???

 You know, before you go off being nasty about everything and trying to
 assert your SELF-appointed importance - why don’t you kindly say - don’t
 email us here - of course I will not. I have no interest in causing anyone
 any hassles, including myself.

 Had I known I would have met such unkind, unprofessional, self-centered
 attitude I wouldn't have even bothered to try to make contact with you.

 This whole attitude of anti-business that's taking place in the world is
 just going to lead to Government dependency and elimination of all personal
 Freedoms to self-expression and self-reliance. So you may call me a spammer
 but I am entitled to try my best to pay my own bills rather than ask for an
 Uncle Sam handout.

 I hope the best to all of you and great success to your Families and your
 businesses.


 ~Samantha (a real person)

hi Samantha,

Real or not, please post appropriate to the list.
This is about PHP programming not advertising services.
We do understand your intentions but this is not the right forum for
something like this.

Thank you.

Cheers,
Virgil
http://www.jampmark.com

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



Re: [PHP] today i found the best function I've ever seen

2009-03-21 Thread Virgilio Quilario
 if( !function_exists('clean_sql_term') )
 {
    function clean_sql_term($term) {
        return $term;
    }
 }

 beautiful


hi Nathan,

Nice find.
You have found a very useful function.
Here is how I use it to load needed PHP files that declares the function.
if (!function_exists('clean_sql_term'))
{
  require 'module.php';
}
clean_sql_term($term);

Above code makes sure that the function is available.
Really beautiful, though jurassic but useful.

Cheers,
Virgil
http://www.jampmark.com

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



Re: [PHP] Trying To Read - Show A Csv File Line By Line

2009-03-21 Thread Virgilio Quilario
 The for loop iterates through each field of each line, the while loop
 iterates through each line.  Move the br / out of the for loop, right
 before the end of the while loop as follows:
 ?php
 $row = 1;
 $handle = fopen(try3.csv, r);
 while (($data = fgetcsv($handle, 1000, ,)) !== FALSE) {
   $num = count($data);
   echo p $num fields in line $row: br //p\n;
   $row++;
   for ($c=0; $c  $num; $c++) {
       echo $data[$c] .  ; // This will separate each field with a space.
   }
  echo br /\n;
 }
 fclose($handle);
 ?


hi guys,

here is a shortcut to displaying a line of csv.
instead of using for loop, use implode like this.

echo implode(' ', $data) . br /\n;

that would display the fields separated by spaces.

Virgil
http://www.jampmark.com

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



Re: [PHP] Having trouble with a form to mail script.

2009-03-21 Thread Virgilio Quilario
 Hi there,
 Well, after reading the post about so called experts and licensing 
 programming, I
 can say that I sure am not licensed or even remotely close to a novice PHP
 programmer, just a ‘lil ole PHP beginner trying to get my web page set up and
 learn a few things.  I’m not sure if I am
 in the right forum but thought I would give this a shot…

 I just
 created a new mail form in Dreamweaver for a web site.  I’m
 working on a form to mail script that I started after reading a few on line 
 tutorials, and can’t seem to get right. When I run
 this little test script (named sendmail2.php) from the tutorial, on my server,
 just to make sure PHP is working OK for web email forms:

 ?php
 $email = $_REQUEST['email'] ;

 $message = $_REQUEST['message'] ;

 mail( h...@mydomain.com, Feedback Form Results,

 $message, From: $email );

 header( Location: http://www.mydomain.com/thankyou.html;
 );

 ?



 Which takes
 input from the following testmail.html page form:



 form method=post
 action=sendmail2.php

 Email: input name=email type=text /br
 /

 Message:br /

 textarea name=message rows=15
 cols=40

 /textareabr /

 input type=submit /

 /form

 It works
 great, I get the senders email address and comment sent to my email address –
 account.
 But the form
 I want to use my final design from Dreamweaver, is:

 form id=formEmail
 name=formEmail method=post
 action=sendmail2.php

 fieldset

 legendAccount Info:/legend

 label for=emailAddressUser Name:/label

 input type=text name=emailAddress
 id=emailAddress tabindex=10 /

 br /

 label for=pwdPassword/label

 input type=text name=pwd id=pwd
 tabindex=20 /

 br /

 label for=confirmConfirm Password:/label

 input type=text name=confirm
 id=confirm tabindex=30 /

 br /

 /fieldset

 fieldset

 legendPersonal Info/legend

 br /

 label for=firstnameFirst Name:/label

 input type=text name=firstname
 id=firstname tabindex=40 /

 br /

 br /

 label for=lastnameLast Name:/label

 input type=text name=lastname
 id=lastname tabindex=50 /

 br /

 br /

 label for=regionWhat state do you live
 in?/label

 select name=region id=region
 tabindex=60

 option value=alAlabama/option

 option value=inIndiana/option

 option value=mich
 selected=selectedMichigan/option

 option value=ohOhio/option

 /select

 br /

 p How long have u been sawing?/p

 label

 input type=radio name=WoodLength
 value=newbie id=WoodLength_0 tabindex=70
 /

 0-2 years/label

 br /

 label

 input type=radio name=WoodLength
 value=novice id=WoodLength_1 tabindex=80
 /

 3-5 years/label/td

 br /

 label

 input type=radio name=WoodLength
 value=expert id=WoodLength_2
 tabindex=90/

 6 plus years/labelbr /

 pWhat tools do you use most often?/p

 br /

 input type=checkbox name=shop
 id=shop tabindex=100 /

 label for=shopShopping/label

 br /

 input type=checkbox name=tools
 id=tools tabindex=120 /

 label for=toolsTools/label

 br /

 input type=checkbox name=saws
 id=saws tabindex=130 /

 label for=sawsSaws/label

 br /



 label for=CommentsAdditional Comments/label

 br /

 textarea name=Comments id=Comments
 cols=50 rows=10
 tabindex=140/textarea

 br /

 input type=submit name=submit
 id=Submit value=Join Mail List tabindex=160
 /

 br /

 /fieldset

 /form



 …and when I
 use it with the associated sendmail2.php script:




 ?php /*?

 ?php

 $emailAddress = $_REQUEST['emailAddress'] ;

 $pwd = $_REQUEST['pwd'] ;

 $confirm = $_REQUEST['confirm'] ;

 $firstname = $_REQUEST['firstname'] ;

 $lastname = $_REQUEST['lastname'] ;

 $region = $_REQUEST['region'] ;

 $WoodLength = $_REQUEST['WoodLength'] ;

 $shop = $_REQUEST['shop'] ;

 $tools = $_REQUEST['tools'] ;

 $saws = $_REQUEST['saws'] ;

 $Comments = $_REQUEST['Comments'] ;

 mail( h...@mydomain.com, Feedback Form Results,

 $message, From: $email );

 header( Location: http://www.mydomain.com/thankyou.html;
 );

 ?



 The email is
 received, but with a blank return email address and an empty message. None of
 the comments or form values get through - just a blank email sent to my
 address. Can anyone point me in the right direction – what am I doing wrong?



 Note: That
 password field is not really a login password, I just wanted to use it for
 testing purposes.


 Do I have to
 refrence the type and id attributes in the php script as well?



 Thanks for
 any input.

hi Linda,

change some parameters to the mail function:
mail( h...@mydomain.com, Feedback Form Results, $comments, From:
$emailAddress );

if you want to include the other inputs, just concatenate them into $comments.

Virgil
http://www.jampmark.com

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



Re: [PHP] need help with code

2009-03-21 Thread Virgilio Quilario
 I hate asking for help with simple code like this because I can usually 
 figure it out, but I'm stumped on this one.  I'm getting a parser error on 
 line 13, whether I comment out the require_once line or not.   Can you help?

 ?php
 require_once('twitterlib.php');

 $consumerKey=yVVRd1QCJYBtT8tT7ocg;

 $consumerSecret=DHzhJYOP2hBWfHpHawGxRQEFf98nF4TBTfabel2ukE;
 $accessToken = $_COOKIE['accessToken'];
 $reqToken = $_COOKIE['reqToken'];
 if ($accessToken===NULL)
 {
 if ($reqToken === NULL)
 {
 //get a req token
 $to = new TwitterOAuth($consumerKey, $consumerSecret);
 $tok = $to-getRequestToken();


 $reqToken = $tok['oauth_token'];

 $reqTokenSecret = $tok['oauth_token_secret'];



 $request_link = $to-getAuthorizeURL($toc);


 $content = 'Click on the link to go to twitter to authorize your account.';

 $content .= 'br /a href='.$request_link.''.$request_link.'/a';
 setCookie('reqToken',$reqToken,time()+(24*30*60*60),'/');
 setCookie('reqTokenSecret',$reqTokenSecret,time()+(24*30*60*60),'/');

 ?
 htmlheadtitleauthorize/title/headbody
 ?php echo $content;?
 /body/html
 ?php
 }
 else
 {
 /* If the access tokens are already set skip to the API call */

 if ($_COOKIE['accessToken']===NULL)
 {
 /* Create TwitterOAuth object with app key/secret and token key/secret from 
 default phase */

 $to = new 
 TwitterOAuth($consumerKey,$consumerSecret,$_COOKIE['reqToken'],$_COOKIE['reqTokenSecret']);

 /* Request access tokens from twitter */

 $tok = $to-getAccessToken();

 /* Save the access tokens. Normally these would be saved in a database for 
 future use. */

 setCookie('accessToken',tok['oauth_token'],time()*24*60*60*30,'/')
 setCookie('accessTokenSecret',tok['oauth_token_secret'],time()*24*60*60*30,'/')
 header(location http://www.chriswestbrook.com/twitter/twitter.php;);

 }


 }
 ?

hi Chris,

basing on the code you posted, you're missing the closing brace for
if ($accessToken===NULL)
{

there should be 3 closing braces before the last ?

cheers,
Virgil
http://www.jampmark.com

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



Re: [PHP] Select Query with Multiple Optional Values

2009-03-21 Thread Virgilio Quilario
 Trying to find best way to accomplish following scenario.  Looking to search
 inventory through a POST form, have the following optional fields to search
 by: Product Name, Color, Size, and Status.  Search maybe for the Product
 Name and/or Color or they may search for just the Color or all 4 fields.  I
 am trying to find the most efficient way to do this without having 100
 different if statements.

 ?php

 $where = array( '1 = 1' );

 if( !empty( $_POST['name'] ) )
 {
    where[] = 'name = '.$db-quote( $_POST['name'] );
 }

 if( !empty( $_POST['colour'] ) )
 {
    where[] = 'colour = '.$db-quote( $_POST['colour'] );
 }

 if( !empty( $_POST['size'] ) )
 {
    where[] = 'size = '.$db-quote( $_POST['size'] );
 }

 if( !empty( $_POST['status'] ) )
 {
    where[] = 'status = '.$db-quote( $_POST['status'] );
 }

 $query =
    SELECT 
   .    * 
   .FROM 
   .    inventory 
   .WHERE 
   .    (.implode( ) AND (, $where ).);

 ?

 Cheers,
 Rob.

Yep, that's the way to do it.
Or you may do it this way.

$fields = array('name','colour','size','status');
foreach ($_POST as $name = $value) {
  if (empty($value)) continue;
  if (!in_array($name, $fields, TRUE)) continue;
  $where[] = $name . '=' . $db-quote($value);
}

which is more compact and useful when you have 100 different optional fields.

Virgil
http://www.jampmark.com
Free tips, tutorials, innovative tools and techniques useful for
building and improving web sites.

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



Re: [PHP] mysql_real_escape_string paranoid enough?

2009-03-21 Thread Virgilio Quilario
 I typically do something like this:

 $data_sql = mysql_real_escape_string($data, $connection);
 $query = insert into data(data) values('$data_sql');
 $insert = mysql_query($query, $connection);
 if (!$insert){
  trigger_error(mysql_error($connection), E_USER_ERROR);
 }

 My custom error handler logs the mysql error, and displays a nice
 generic Something went wrong. Please try again or contact us message
 to the user, wrapped in the page layout, and then exits.

 I've just noticed that while the function signature says:
 string mysql_real_escape_string( ...)

 The docs say it could return FALSE in case of error.

 I'm not real sure what all could cause a FALSE return.

 Obviously, if the database server/process/chipmunk has DIED just
 before the call to mysql_real_escape_string, I'll get FALSE back.

 If the input string is just too whack for the function to parse, could
 I get FALSE, and then I'd be inserting junk into the DB?

 Or is it possible that the function returns FALSE for what is
 obviously a hack attempt?

 I guess I'm asking if anybody adds a line like:

 if ($data_sql === false){
  trigger_error(mysql_error($connection), E_USER_ERROR);
 }

 Or is that not really going to do anything useful/better than what I
 already have?

yes you could add that condition and it would be helpful if you also
include the value of $data in addtion to mysql_error so you can
examine and figure out what cause it to return FALSE.

also, php manual says this:
mysql_query() will also fail and return FALSE if the user does not
have permission to access the table(s) referenced by the query.

Virgil
http://www.jampmark.com
Free tips, tutorials, innovative tools and techniques useful for
building and improving web sites.

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



Re: [PHP] need help with code

2009-03-21 Thread Virgilio Quilario
 hi Chris,

 basing on the code you posted, you're missing the closing brace for
 if ($accessToken===NULL)
 {

 there should be 3 closing braces before the last ?

    That'll be the next error, but that error would print unexpected
 $end on line xxx.

well, if you're getting the parse error without additional description
then it must be the php versions because the lib might be throwing
exceptions and you are running php4.

cheers,
Virgil
http://www.jampmark.com
Free tips, tutorials, innovative tools and techniques useful for
building and improving web sites.

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



Re: [PHP] how to make multiple sql run faster

2009-03-21 Thread Virgilio Quilario
 Usually a single transaction is faster than an insert a time (with or without 
 union)

 Hi all,

 I am inserting more than 5000 rows into sql database but its taking more
 than 30 mins  to get it all the data inserted. I use union to insert
 multiple rows of 20 at a time.

 What is the best way to make insert sql statement run faster

hi,

inserting 5000 rows should only take seconds.
if you are looping, optimize the code inside the loop.
or before entering the loop, get a connection first and the use the
connection inside the loop.
or maybe you could post snippets, that would surely be helpful.

cheers,
Virgil
http://www.jampmark.com
Free tips, tutorials, innovative tools and techniques useful for
building and improving web sites.

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



Re: [PHP] Smarty Tips and Techniques

2009-03-20 Thread Virgilio Quilario
 Hi Virgil,

 After your last post here, I looked at your site, then the Smarty site.
 That was what triggered this question. Templates are a black art to me.
 I don't even know where to begin to understand them. Every reference I
 have looked at so far assumes that I already understand the MVC pattern,
 which is also one of the dark arts.

 Let me put it simply. I can't grok OO. I tried to do OOP for several
 years, but it simply does not make any sense to me. As a direct result,
 I don't understand the concept nor application of patterns. So how do I
 figure out how to use templates without having to absorb those first?
 Can I learn enough this way to determine if a site can be converted from
 the current state (PHP and XHTML spaghetti) into templates and begin
 that transformation?

 Thank you,

 Bob McConnell


HI Bob,

Smarty templates are just html files with placholders or variables and
simple constructs.
This was made to allow web designers to work on a page without having
to know PHP programming.
Smarty is not an MVC.
It is just a class that provides all the necessary functions to
replace variables and execute constructs in html page.
You just create an instance, set necessary config, do your PHP stuff,
assign values to template variables, and finally display.
It's just a matter of understanding how its functions or methods work.
You don't have to learn OOP and it is not about OOP or MVC.
It is just a convenient placeholder of functions necessary to run
smarty templates.

Spaghetti style programming can be very hard and really time consuming
to follow and convert.
Just take one step at a time.

Maybe I could write a tutorial for this.
Just need to find some spaghetti code for the  example.

Regards,
Virgil
http://www.jampmark.com

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



Re: [PHP] Script Analysis (was Conclusion of use strict...)

2009-03-20 Thread Virgilio Quilario
On Fri, Mar 20, 2009 at 6:47 PM, Pierre Lilliman lilli...@live.com wrote:

 I have been using same program for some (not very long time), and I find it 
 very useful, although it has some annoying things (inability to work with all 
 kinds of include expressions). Still I think every serious PHP developer 
 should consider using something like this.

 Cheers

 --- On Thu, 3/19/09, Hans Schultz  wrote:

 If someone is still interested in problem I found litle tool that is pretty 
 close to detecting errors in PHP at compile time (compile time rghhh :P). 
 It is Codenizer (http://www.softwarehood.com/Codenizer/), I am still checking 
 it, if someone uses it it would be nice to share experience :)

 On Wed, 04 Mar 2009 11:03:04 +0100, Hans Schultz  wrote:

 Concluding,  and one idea...I think I received satisfying advices on 
 everything but first question (Detection of typos and other simple 
 mistakes). And we were talking also about being able to catch them at 
 compile time, then if php at all has compile time etc. Today one thing 
 crossed my mind -- if there is compiler for php maybe it can catch these 
 errors natively, like java compiler for java? Unfortunatelly there is no 
 recent version available for windows so I can't test it myself 
 (http://www.roadsend.com/home/index.php?pageID=compiler). I am interesting 
 if someone is using it, and if it can detect this simple mistakes (I am 
 using eclipse + php plugin, but I feel there is something wrong in depending 
 on editor to detect programming errors :-) )
 Regards to all,
 --- On Thu, 2/26/09, Ovidiu Rosoiu  wrote:
 From: Ovidiu Rosoiu
 Subject: Re: [PHP] use strict or similar in PHP?
 To: Hans Schultz
 Cc: php-general@lists.php.net
 Date: Thursday, February 26, 2009, 9:14 PM

 Hans Schultz wrote:
 Hello,
 I am beginner with PHP and prior to PHP I have worked with java for some
 time
 and with perl for very short period. I can't help to notice some
 things that
 are little annoyance for me with PHP, but I am sure someone more
 experienced
 can help me :-)
 Is there in PHP something like use strict from perl? I find it
 pretty
 annoying to need to run script over and over again just to find out that I
 made typo in variable name.
 Is there some way for PHP to cache some data on the page? I like very much
 PHP's speed but it would be even better to be able to cache some
 frequently
 used data from database?
 Also regarding databases, I liked a lot java's way of sending data to
 database
 using parameters (select * from user where username = ? and
 then passing
 parameter separately with database doing necessary escaping and
 everything).
 Is there something like PHPDBC similar to JDBC?


Hi guys,

Check out Netbeans IDE for PHP.
http://www.netbeans.org/features/php/

Your wishes answered.
Though it doesn't have use strict but it tracks variables for you.

Virgil
http://www.jampmark.com

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



Re: [PHP] Web Development/Application Analysis

2009-03-20 Thread Virgilio Quilario
 Hello,

 I have just hired a remote PHP programmer. His main job is web
 development and applications.

 I have few concerns, I would be happy if someone can point me to the
 right direction.

   1. How can I provide him the requirements. I mean how can I analyze
 the site and put everything in writing.
   2. How can I estimate manhours.


 Is there a sample web site/application anyalsis.

 Basically, what is provided to the programmers in order for them to
 start working?

 --
 OOzy
 Ubuntu (8.10)

 OOzy:

 If you don't know what you want, then why did you hire a programmer?

 In any event, the first thing you need to do is to pin down what you want
 the site to do. Do you want it to gather emails, or sell a product, provide
 a video, sell your company, tap-dance, or what?

 If you know what you want, then put those objectives in a list of
 requirements. You don't have to be a programmer to know what you want, but
 you must be able to effectively communicate those ideas to the programmer so
 that they can: 1) understand what you want; 2) and can tell you if it's
 possible and what cost and time. I always tell my clients that If they can
 describe it, then I can do it -- however, some things can take more
 money/time than they an afford.

 In any event, as a client there are some thing that you need to know:

 http://sperling.com/four-things-clients-should-know.php

 Once you and the programmer understands the other's position and
 expectations (i.e., meeting of the minds), then the programmer should be
 able to determine an approximate number of hours and overall cost for the
 project.

 Here's another thing you must realize -- as the client you can choose:
 Quality; Time; Or Cost as your main concerns, but only two of them -- not
 all three. For example, if you want it done quick with high quality, then
 it's going to cost you. If you want high quality and low cost, then it's
 going to take a while. And if you want it done quick with low cost, then
 expect low quality -- and at that point, a respectable programmer would
 normally pass on the project -- professionals don't turn out crap.

 But the point is if you are dealing with a professional, they will try to
 provide honest service for your buck. If you try to cut their price or rush
 them, then you're only asking for trouble in some form.

 For example, I charge $50 per hour and had one prospective client say I've
 never paid $50 per hour for any programmer. The most I've ever paid is $25
 -- would you work for that? I answered, Sure, but it's going to take me
 twice as long to get anything done. The client didn't get the idea, I
 didn't get the work, and that was probably good for both of us -- not all
 relationships work.

 Just make sure that what you want is understood by the programmer before
 they start work on your project -- and -- that you understand what you are
 getting from them.

 Good luck,

 tedd


Hi,

I agree with tedd.
You don't have to be a programmer to know what you want.

Maybe search on the internet for a site that is very close to what you
have in mind or at least a starting point.
Send in the url to the programmer.
Tell him the needed functionalities in your own words.
Then ask the programmer if he can do it, how long and how much.

Perhaps consider grouping the functionalities according to priorities or stages.

For me, I am the one asking those questions to the client to get him
to know what he wants.

Virgil
http://www.jampmark.com

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



Re: [PHP] how to make for statement run faster

2009-03-20 Thread Virgilio Quilario
 I have a program where I process more that 5000 list of 100 data at  time
 but it very slow due to many  *for statement*s. how you make it run faster

code for statements to use a variable or contant for testing in every
iteration like below
for ($i = 0; $i  100; $i++) {}

also try to optimize the operations inside the for loop.
or maybe better to post snippets.

Virgil
http://www.jampmark.com

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



Re: [PHP] Smarty Tips and Techniques

2009-03-19 Thread Virgilio Quilario
 That looks nice, but how do I get to the point where I can understand
 how to use it?

 I have also looked at the Smarty site http://www.smarty.net/, but
 their documents assume significant experience in building and using
 templates.

 Where can I find guidance or tutorials on how to do all of this,
 starting with only a rudimentary knowledge of HTML and PHP. It would be
 best if they also focused on procedural rather than object oriented
 code.

 Bob McConnell


When I started learning smarty, I spent most of my time doing research
and that's really tiresome and it is so hard to find examples.
Experimented a lot and listed those what's possible, then applied them
to my projects.

Now to make them handy I posted them to my site so i can have a look
whenever and wherever.
http://www.jampmark.com/php-programming/16-very-useful-smarty-scripting-tips-and-techniques-to-make-templates-smarter.html

As a first step, maybe you should see the crash course at smarty
http://www.smarty.net/crashcourse.php

Virgil
http://www.jampmark.com

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



Re: [PHP] Looking for a configurable Flash or PHP Live Chat Box or Shout Box With Rooms Optional

2009-03-19 Thread Virgilio Quilario
 Does anyone have a good link to something like this for reasonable
 price or free?

 Configurable meaning skinnable and sizeable?

 Something Ajaxy would be cool but it would need to save state like the
 facebook IM feature on their site.

 Thanks, T

here is a good list of free scripts
http://www.thefreecountry.com/php/live-chat-scripts.shtml

good luck!

Virgil
http://www.jampmark.com

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



[PHP] Smarty Tips and Techniques

2009-03-18 Thread Virgilio Quilario
Hi list,

Just wanna share my collection of Smarty scripting tips and techniques.
Smarty is a template engine for PHP that you can use to separate data
and logic from web design.
This way programmers can work on the php scripts and designers can
work on the templates for the same web site.

Here is the link:
http://www.jampmark.com/php-programming/16-very-useful-smarty-scripting-tips-and-techniques-to-make-templates-smarter.html

Hope you find it useful.

Virgil

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



Re: [PHP] preg_replace() question

2009-03-18 Thread Virgilio Quilario
 1. What is the overhead on preg_replace?

it really depends on your operation. when you think it can be done
using str* functions then go for it as they are much faster than preg*
functions.

 2. Is there a better way to strip spaces and non alpha numerical
 characters from text strings? I suspect not... maybe the Shadow does ???

if those characters are in the middle, preg_replace is the right function.


virgil
http://www.jampmark.com

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



Re: [PHP] Handling (very) large files with PHP

2009-03-11 Thread Virgilio Quilario
 *Handling (very) large files with PHP*

 Hello, I am planning a project in PHP, and I have few unsolved issues that
 I'd like you to help me...

 The project will start by loading a file of about 50GB.
 The file has a many objects with a pattern, for example,


 Name: Joe
 Joe likes to eat
 ---
 Name: Daniel
 Daniel likes to ask question on the PHP Mailing List


 Anyway, so, I am going to convert it into a database, and I insist on using
 PHP for this.

 So the questions are,
 How would I open the file? will fopen fread($file, 1024) will work? if then,
 how would I find the seperator, --, without taking too
 many resources?
 I'll have a dedicated server for this project so I could use exec, so I am
 wondering if I should use exec to split the file?
 How many hours or days do you think it will take me to insert all of the
 data, if I have about 8,000,000,000 (8 billion/milliard) entries (objects)?

 After I insert all the data, I'll have to start working with it as well -
 for example, having a list of all people and what comes after the word
 likes in their entry.

 What do you suggest? I am concerened I might not be able to fully acomplish
 both high speed with working (example above) and both high speed when
 watching the data and adding more works (as stated above) with PHP. What
 do you think?
 Since inserting to the database, after considering it, will probably be with
 C. But if I wish to work with it - will PHP be good?

 What database should I use for so much info?


 Thanks, Daniel


hi Daniel,

Interesting task you got there.
The code below should solve your problem.

$fh = fopen('data.txt', 'r');
$row = array();
while (($line = fgets($fh, 1024)) !== false) {
  if ($line === '---') {
// save $row into database
$row = array();
continue;
  }
  if (strpos($line,'Name: ') !== false) {
$row['name'] = str_replace('Name: ', '', $line);
continue;
  }
  $row['likes'] = str_replace($row['name'] . ' likes ', '', $line);
}
fclose($fh);
your database fields should include
id -- autoincrement, primary
name -- varchar(64)
likes -- text

now you should be able to do simple select query that pulls a list of
names with likes not empty.
please clock it for me.
i would like to know how long it takes but the code should be fast.
thanks and good luck.

Virgil
http://www.jampmark.com

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



Re: [PHP] Silly question - include vs. eval

2009-03-11 Thread Virgilio Quilario
 Hi,

 I wondering what is the difference between include(), and eval(' 
 ?'.file_get_content().' ?php ')?

 If there is something I should be aware, please, let me know.

 Use include since it allows a cache like eAccelerator or APC to work.
 Eval never gets cached. Also, include let's the engine do the opening,
 reading, closing of the file while also parsing and running the contents
 in one fell function call (yes I know it's not a function). What you
 have above, using eval, is a bastardization of cleanliness and
 succinctness of code.

 Cheers,
 Rob.

hi,

eval is useful when your php code is stored in database.
read here http://www.php.net/manual/en/function.eval.php for details.

Virgil
http://www.jampmark.com
Free tips, tutorials, innovative tools and techniques for building and
improving web sites

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



Re: [PHP] This code using _GET exploitable

2009-03-11 Thread Virgilio Quilario
 filtered schreef:
 Hi,

 we have script containing

  ? echo $_GET['studio'] ?

 let say I do:

 example.com/yourscript.php?studio=script type=text/javascriptalert('I am 
 an evil haxor');/script

 excusing the fact that the query is not urlencoded, what happens on your site
 (replace domain and script name to match your site/script)



 and

     ?
         $cam = $_GET['cam'];

         if ($cam == '1') {
             echo 'img src=http://example.com;  /';
         }


 if ($_GET['cam'] === '1')
        echo 'img src=http://example.com; /';

 no need to create the $cam var, and a little better to check for the exact 
 value+type (===)

    ?

 Is this code prone to XSS attacks or for attacking the local webserver
 and if so, how?

 $cam isn't used anywhere else.

use htmlentities() to display $_GET['studio']
like below.

?php echo htmlentities($_GET['studio']); ?

Virgil
http://www.jampmark.com
Free tips, tutorials, innovative tools and techniques for building and
improving web sites.

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



Re: [PHP] PHP/Apache: script unexpectedly invoked multiple times in parallel every 30 secs.

2009-03-11 Thread Virgilio Quilario
 Hi all,

 I wrote a PHP script running in Apache which takes more than 30 seconds to
 complete. It uses set_time_limit() to extend the time it is allowed to run.
 The script generates thumbnails from a list of images. Upon completion, the
 script redirects the browser to another page using HTTP headers.

 On my local machine (Windows + EasyPHP), the script runs as expected and
 completes after a few minutes.

 I observe an unexpected behavior on my production web server:
 - The script runs as expected for the first 30 seconds.
 - After 30 seconds, the same script with the same parameters starts again in
 a new thread/process. The initial thread/process is *not* interrupted, so 2
 threads/processes run in parallel, executing the same sequence of operations
 with a 30 time shift.
 - The same scenario happens every 30 seconds (i.e.: at 030, 100, 130, and
 so on), multiplying the parallel threads/processes.
 - The browser keeps on loading while the above happens.
 - After some time, the browser displays a blank page and all the
 threads/processes stop. I assume this is due to resources exhaustion, but I
 have no means to check this assumption.

 I deduced the above reading a text file in which I log the sequence of
 called functions.

 Unfortunately I have no access *at all* to my production web server
 configuration (shared hosting, no documentation). I cannot even read the
 configuration settings. While I'm considering moving to another host, I'd be
 extremely pleased to have an explanation of the observed behavior.

 I have browsed the mailing list archives and looked for an explanation in
 other forums to no avail. This thread may deal with the same issue but does
 not include any explanation or solution:
 http://www.networkedmediatank.com/showthread.php?tid=17140

 Thanks for reading, and please do not hesitate to ask for further
 explanations if what I'm trying to achieve was not clear!

 Cheers,
 Marc.


hi Marc,

probably your php file on your production server is index.php.
and you must have generated a image tag with empty src like below:
img src=

with src being empty, browsers will load your index.php as if it was
an image url so loading in parallel.
hope this explains your case.

Virgil
http://www.jampmark.com
Free tips, tutorials, innovative tools and techniques for building and
improving web sites.

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



Re: [PHP] PHP includes

2009-03-09 Thread Virgilio Quilario
 I'm working on learning php and have been toying with includes, and I am
 trying to figure the advantages/disadvantages to using them.

 I know that using them eliminates the need to put the files once altered
 as with a template, however, is that the only advantage.

 My particular concerns are with SEO and if the search engines and the bots
 can read the page if it is made completely on includes?

 Any and all comments would be appreciated.


hi Gary,

It doesn't matter to SEO because search engines and the bots reads the
output of your php scripts.
whatever you see when you browse your page, same thing bots would see.

Includes is a way to modularize your scripts instead of monolithic or
repeated codes everywhere in your php file.

Virgil
http://www.jampmark.com

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



Re: [PHP] Line Break Problem

2009-03-09 Thread Virgilio Quilario
 Hi,

  I have a question regarding using line breaks in PHP. I have the code 
 something like:

       echo 1 . \t  . $x . \t . $y . \r\n;

 When I run the code, it looks like a whole blob of text, but when I use View 
 Source, the line breaks are formatted then correctly.
 Anyone can please tell me if this is what this is supposed to be?
 If so, how can I get the user to see the line break as they are, do I have to 
 use br?

 Thanks for your help.

Hi Alice,

I see that you are using a browser to view the result.
Use br / to cause a break at end of every line.

echo 1 . \t  . $x . \t . $y . \r\nbr /;

that way, the lines are properly break even when viewing the HTML source.

Virgil
http://www.jampmark.com

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



Re: [PHP] Opendir on site root directory?

2009-03-09 Thread Virgilio Quilario
   I want to index the files on a website recursively. The program will
 run
  in
   the site root
   directory, which GETCWD reports as D:/Websites/Website_1.  I can open
  any
   file in the root
   directory simply using its file name; Joe.dat, for example, and I can
   opendir for any
   subdirectory; eg
  
          opendir(Subdirectory_1);
  
   but opendir () does not seem to work, and the only way I can find to
  open
   the root
   directory is to give its full path; eg
  
          opendir (D:/Websites/Website_1);
  
   I have got the program working by using the full path to open the
 root
   directory, and then
   using relative paths to open the subdirectories and individual files,
  but
   this seems
   rather a kludge, and I am wondering if there is a way to open the
 root
   directory without
   specifying an absolute path?
  
  
  The current working directory cannot be trusted to be right. The best
  option is to use dirname(__FILE__) and add '/..' as many times as
 needed
  to
  get from the current file to the document root you're after.
 
  It has always worked for me.  But then I never change directory. But
 both
  give a hardware
  dependent answer;
 
  echo 'pCurrent directory is '.__FILE__.', CWD is '.getcwd().'/p';
 gives
 
  Current directory is D:\Websites\Corybas\Cydaldev\Dev\Testbed_2.php, CWD
 is
  D:\Websites\Corybas.
 
 
 Not sure what you mean by a hardware-dependent answer. The current working
 directory for any given script is determined by the web server and so it
 cannot be assumed to be the location of the current script.
 dirname(__FILE__) will give you the directory the current script is in.

 I agree that 'hardware dependent' was not the right word, but what I meant
 was that if I
 am running the local version of my program getcwd() will return
 'D:\Websites\Corybas',
 where as if I am running the remote version it will return
 'home/Corybasftp/www'.


 This should be irrelevant in your code, something you can achieve using
 dirname(__FILE__).

 My webpage is always launched by loading index.php from the root directory,
 and I don't
 think I ever change the working directory, so although the code actually
 being executed at
 any given time is usually in a subdirectory, getcwd() will reliably return
 the (system
 dependent) long definition of the root directory.


 Either I'm not explaining this well enough or you're just not getting it.
 Ignore the current working directory - it's not reliable. If every page is
 created by a single script then the solution is to define a constant at the
 top of that script that gives you the directory that script is in

 define('ROOT_DIR', dirname(__FILE__));

 Then when you need to refer to another file in your directory structure you
 do so relative to the location of index.php. So if you have a directory
 named arse in the same folder as index.php you'd refer to that like so...

 ROOT_DIR.'/arse'

 If that's not clear maybe this will help:
 http://dev.stut.net/php/dirname.php

Based on that the following should work in your particular situation, but

rather than just using this I encourage you to understand why it works...
 opendir(dirname(__FILE__).'/../Cydaldev');

 Looking into this I did find that 'opendir('Albums/../');', where 'Albums'
 can be any
 subdirectory I know to be present, will reliably open the root directory.


 You clearly haven't looked into this at all since you're still not using
 dirname(__FILE__), and if this email complete with the example script above
 doesn't get the point across I give up. Have you even looked up dirname in
 the manual? http://php.net/dirname

 As a result of what seems to me to be an oversight in the design of
 opendir(), in that
 opendir(Fred) and opendir(Fred/Nurg) will open the appropriate sub
 directories but
 opendir() will not open the root directory, I can readily index all the
 subdirectories by
 giving their relative paths, but I have to resort to a kludge to index the
 root directory,
 and another kludge to eliminate this kludge from the index.


 As in the example script I've posted above you can refer to the current
 working directory with a single period (.), but this is still relying on the
 current working directory being what you expect it to be.


 If, as it seems, I have to accept this it is fairly immaterial which kludge
 I actually
 use.


 There is no need to use a kludge. I encourage you to read my replies
 carefully if you're still not getting it.

 -Stuart

 --
 http://stut.net/


Hi Clancy,

I think you want to traverse all files in a directory and its sub directories.

Here is a link to scandir() a php function for reading files and sub
directories of the target directory in your case the root web folder.
It has examples and explanations on how it works.
http://www.php.net/manual/en/function.scandir.php

Virgil
http://www.jampmark.com

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



Re: [PHP] web refreshing problem

2009-03-09 Thread Virgilio Quilario
 Hi,

 my php program does not display current result of submitted form
 instead the previous content is shown until you refresh manually
 (which means resubmitting the form).

 Can someone help me out because, I want to display the result of the
 latest form result and not the old one.

 I am using apache server on windows. Please help.

 have you per chance got all data saved in the session and are using a script
 like

 if( something in session ) {
  show session
 }
 else if( something in post ) {
  add form data to session
 }
 else {
  show only the form
 }

 three common causes are:
 1- you're not actually processing the new form data
 2- your browser isn't sending the form data second time round
 3- your browser is caching the page (very very unlikely)

 regards


Hi Nathan,

Most likely your form is using POST method and your browser is
caching the page.

Virgil
http://www.jampmark.com

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



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread Virgilio Quilario
 I am using a WAMP server for my coding purposes. My MySQL Version is
 5.0.51b, PHP version is 5.2.6 and Apache version is 2.2.8

 I have created a database with one of the tables containing a location of
 the image. Using PHP I am trying to retrieve the location of the image (from
 the mysql db) and display it in a browser. I have, with help from php-db
 mailing list user's help, created a code to do the same. Now, the problem
 is, the code is extracting the location details of the image exactly and it
 is even getting the image details. But it is simply not dispalying the
 image. Instead of displaying the image, it is printing a hell lot of binary
 characters (For example: 2!
 !22ÿÀ   ^          ÿÄ
            ÿĵ             }       !1A  Qa q 2 ‘¡ #B±Á RÑð$3br‚
  %'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ
                     ÿĵ              w      !1  AQ aq 2   B‘¡±Á #3Rð brÑ
 $4á%ñ    '()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤)

 I have tried in two forums and mailing lists but none of them have
 completely answered my question. How do I get rid of these signs and display
 the original image in its place? And to display the image successfully, is
 it really necessary to create the image retrieval and displaying code in a
 seperate PHP file? Any PHP gurus, enthusiasts, newbies out there, Please
 help me out.

 I am posting the code below so that you can directly see what I have done
 till now. The name of the php file is mysqli.php. The location of the image
 is stored to the variable $location. The image retrieval code is present
 towards end of the file.

 Thanks,
 Sashi

 html
 body
 form action=mysqli.php method=post
 br
 div align=center
 Building Name:select name=name
 option value= Select a Building/option
 option value=Williams HallWilliams Hall/option
 option value=Women's Softball FieldWomen's Softball Field/option
 option value=Wright HouseWright House/option
 /select
 /div
 input type=submit /
 /form
 ?php
 // Connects to your Database
 $host=***;
 $user=***;
 $password=***;
 $dbname=***;
 $cxn=mysqli_connect($host, $user, $password, $dbname) ;
 if (!$cxn=mysqli_connect($host, $user, $password, $dbname))
 {
 $error=mysqli_error($cxn);
 echo $error;
 die();
 }
 else
 {
 echo Connection established successfully;
 }
 //Define the variables for Day and Month
 $Today=date(l);
 $Month=date(F);
 $build=$_POST[name];
 $low_speed=2.5;
 $high_speed=4;
 $hour=date(G);
 $minute=date(i);
 if ($minute=00  $minute=14)
 {
 $minute=00;
 }
 elseif ($minute=15  $minute=29)
 {
 $minute=15;
 }
 elseif ($minute=30  $minute=44)
 {
 $minute=30;
 }
 else
 {
 $minute=45;
 }
 $times=$hour:$minute;
 $sql=SELECT buildingname, parking_lot_name, empty_spaces, distance,
 round(distance/($low_speed*60),1) AS low_time,
 round(distance/($high_speed*60),1) AS high_time, Location FROM buildings,
 buildings_lots, parkinglots, occupancy2, Image where
 (buildings.buildingcode=occupancy2.building AND
 buildings.buildingcode=buildings_lots.building_code AND
 parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND
 parkinglots.parking_lot_code=occupancy2.parking_lot AND
 Buildings.BuildingCode=Image.BuildingCode) AND buildingname='$build' AND
 month='$Month' AND day='$Today' AND Time='$times';
 $data = mysqli_query($cxn,$sql);
 if (!$data=mysqli_query($cxn,$sql))
 {
 $error=mysqli_error($cxn);
 echo $error;
 die();
 }
 else
 {
 echo br;
 echo Query sent successfully;
 }
 echo br;
 echo h1 PARKING LOT INFORMATION h1;
 echo table border='1' cellspacing='5' cellpadding='2';
 echo tr\n
 thBuilding/th\n
 thParking Lot/th\n
 thEstimated Number of Empty Spaces/th\n
 thDistance (Feet)/th\n
 thEstimated walking time to the building/th\n
 /tr\n;
 while ($row=mysqli_fetch_array($data))
 {
 extract($row);
 $building = $row[0];
 $parking_lot = $row[1];
 $Number_of_Empty_Spaces = $row[2];
 $Distance = $row[3];
 $time_l = $row[4];
 $time_h=$row[5];
 $location=$row[6];
 echo tr\n
 td$building/td\n
 td$parking_lot/td\n
 td$Number_of_Empty_Spaces/td\n
 td$Distance/td\n
 td$time_h - $time_l mins/td\n
 td$location/td\n
 /tr\n;
 }
 echo /table\n;
 $err=1;
 if ($img = file_get_contents($location, FILE_BINARY))
 {
 if ($img = imagecreatefromstring($img)) $err = 0;
 }
 if ($err)
 {
 header('Content-Type: text/html');
 echo 'htmlbodyp style=font-size:9pxError getting
 image.../p/body/html';
 }
 else
 {
 header('Content-Type: image/jpeg');
 imagejpeg($img);
 echo 'img src=mysqli.php?img=' . $location . ' border=1 height=150
 width=200 alt=' . $build . '';
 imagedestroy($img);
 }
 ?
 /body
 /html


Hi Sashikanth,

here is how to do it.
change
td$location/td\n
into
tdimg src='$location' /td\n

then // to comment the useless php code.

see the changes below:


while ($row=mysqli_fetch_array($data))
{
extract($row);
$building = $row[0];
$parking_lot = $row[1];
$Number_of_Empty_Spaces = 

Re: [PHP] Error in Building an XML File

2009-03-09 Thread Virgilio Quilario
 I am using PHP to build an XML file, but I keep on getting an XML
 error when open the file in Google Chrome.
 -
 This page contains the following errors:

 error on line 30 at column 318: Entity 'iuml' not defined
 Below is a rendering of the page up to the first error.
 

 is this something to do with document encoding?

 I am using these as headers for the script

 header(content-type:text/xml;charset=utf-8);
 header(Content-Disposition:attachment;filename=google_feed.xml);



hi Joe,

the document encoding has nothing to do with the error.
maybe you have  just before the iuml.
make it amp;iuml.
or maybe copy and paste that line here because i suspect there is
something else.

Virgil
http://www.jampmark.com

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



Re: [PHP] web refreshing problem

2009-03-09 Thread Virgilio Quilario
  my php program does not display current result of submitted form
  instead the previous content is shown until you refresh manually
  (which means resubmitting the form).
 
  Can someone help me out because, I want to display the result of the
  latest form result and not the old one.
 
  I am using apache server on windows. Please help.
 
  have you per chance got all data saved in the session and are using a
  script
  like
 
  if( something in session ) {
   show session
  }
  else if( something in post ) {
   add form data to session
  }
  else {
   show only the form
  }
 
  three common causes are:
  1- you're not actually processing the new form data
  2- your browser isn't sending the form data second time round
  3- your browser is caching the page (very very unlikely)
 
  regards
 

 Hi Nathan,

 Most likely your form is using POST method and your browser is
 caching the page.


yes my form is using post method but how do you stop catching the page

hi Andrew,

use the code below. it is from this page
http://www.php.net/header
look for Example #2 Caching directives.

?php
header(Cache-Control: no-cache, must-revalidate); // HTTP/1.1
header(Expires: Sat, 26 Jul 1997 05:00:00 GMT); // Date in the past
?

to be sure, put them as the first 2 lines at the top.

Virgil
http://www.jampmark.com

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



Re: [PHP] Re: PHP Frameworks

2009-03-09 Thread Virgilio Quilario
 m...@hallmarcwebsites.com wrote:
 @todd; Micah - Precisely why I presented the question anew. Not only do I 
 not have enough time to troll through the archives; I was looking for a 
 fresher set of responses based on today's smorgasbord. Thank you for your 
 input; I have looked at both YII and CI and they look promising. I love the 
 statement about PEAR! That gave me a chuckle. With PHP 5.3 around the corner 
 and looking forward to both PHP/MySQL 6; I am ISO a framework that is just 
 as forward looking. I have already worked with Sapphire/SilverStripe for a 
 client of mine and I find it comes with a lot of overhead. It does seem to 
 be a promising future contender.

 Perhaps I should have phrased it a bit more concise: This has been
 discussed many times--often, and RECENTLY. Anyway, since I'm already
 writing this, I'll say that overhead/bloat vs. productivity of the
 developer is a trade-off you're going to have to make for ANY of the
 frameworks out there.


hi,

all php frameworks have overheads which you don't have to worry about.
those overhead codes are there to make things easy for you so you can
focus on building your application.
for me, the most important factor in choosing the right php framework
is the size of its community.
the bigger the better because there will be more people to exchange ideas with.

Virgil
http://www.jampmark.com

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



Re: [PHP] optimizing space for array of booleans

2009-02-23 Thread Virgilio Quilario
 Some languages allows to bit-pack structures to save spaces. Since PHP
 doesn't have native set data type and operations, will array of booleans be
 optimized as such? If not, how can I achieve the same result? I need to save
 about 200 boolean values and I guess it's a good idea to use bitsets.

 Requirements:
 - Easy to use (set, unset, test), so C way to use bitwise operations is
 simply rejected.
  I need something like Pascal's set.
 - Small space (bit level if possible)

 --
 View this message in context: 
 http://www.nabble.com/optimizing-space-for-array-of-booleans-tp22159131p22159131.html
 Sent from the PHP - General mailing list archive at Nabble.com.


hi,

you should not worry about optimizing boolean values unless you would
store them in database.
anyways, use bitwise operators http://ph.php.net/language.operators.bitwise

virgil
http://www.jampmark.com

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



Re: [PHP] PHP - user profile page with pic

2009-02-23 Thread Virgilio Quilario
 ---
 Use FreeOpenSourceSoftwares, Stop piracy, Let the developers live. Get
 a Free CD of Ubuntu mailed to your door without any cost. Visit :
 www.ubuntu.com
 --

 my level of coding is basic. out of the box is fine as long as it is a good
 one. I do know how to connect to database pull and display records as well
 as set up login. But I guess I have to create a session so that when a user
 logs in only his/her information is shown correct?


 Yes, and it would be better for you to have an in depth look into the open
 source projects found. Get to analyse them. So, you'll get familiarized with
 the advanced well known methods. Learning from them you will be able to
 create something better and not reinventing the wheels.

 Lenin



 -Jeff

  The question can be equally rephrased as How an Atom bom/Spaceship be
 created?

 Answer depends on the level of knowledge you have on coding / developing
 sites. Woud you be using any framework? or would you use any readymade
 CMS?
 Or write everything from scratch?

 Question can also be generalized further like would php be your developing
 language? Or you'd develop your own new language out of the box. :)

 ---
 Use FreeOpenSourceSoftwares, Stop piracy, Let the developers live. Get
 a Free CD of Ubuntu mailed to your door without any cost. Visit :
 www.ubuntu.com
 --


  Any ideas or tutorials on how to build a user profile page sort of like
 facebook?

 -Jeff


hi,

i would recommend Joomla or Wordpress both have extensions for user
maintained profiles with pictures.

Virgil
http://www.jampmark.com

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



Re: [PHP] Apache odd behavior

2009-02-17 Thread Virgilio Quilario
 I'm submitting a url like this:

 http://mysite.com/index.php/alfa/bravo/charlie/delta

 The index.php calls has code to decode the url segments
 (alfa/bravo/charlie/delta). It determines that the controller is alfa,
 the method is bravo, and converts charlie and delta to $_GET['charlie']
 = 'delta'. It verifies that the controller and method exist, and calls
 the controller and method.

 This works fine. The right controller gets called and the right method,
 and the GET parameter looks like it should. The method sets some
 variables and then calls a render() function to render the page, which
 is in the doc root of the site.

 The page does get rendered, but without the stylesheet, and none of the
 graphics show up. Why? Because, according to the logs, Apache appears to
 be looking for the images and everything else in the directory
 index.php/alfa/bravo/charlie/delta, which of course doesn't exist.

 No, I don't have an .htaccess file with RewriteEngine on. Apache figures
 out that index.php is the file to look for in the original URL, but
 can't figure out that everything else is relative to that file, not the
 entire URL.

 This method is in use in at least one other MVC framework. What am I
 doing wrong?


hi Paul,

to make your css and images work, do something like this

img src=/image.jpg /

and

link href=/style.css type=text/css rel=stylesheet media=screen /

the slash at the start tells the browser to start looking from the root.

good luck.

Virgil
http://www.jampmark.com

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



Re: [PHP] Opinions Please, Describing PHP as Web Framework of C and C++

2009-02-17 Thread Virgilio Quilario
 Recently we had some serious discussion on local boards.

 I prefer calling PHP as Web Framework of C and C++

 if you had a time for this fruitless discussion. Please send your opinions.


PHP is a server side scripting language for the Web using a C like
language structure and conventions. The engine is built with C that is
true but it is the engine that interprets the scripts not C.
C has nothing to do with the operations of PHP engine.
It is merely a code which is used to generate machine codes for the PHP engine.

Good luck with your fruitless discussion as you like to call it.

Virgil
http://www.jampmark.com

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



Re: [PHP] Full versus relative URLs

2009-02-17 Thread Virgilio Quilario
 Here's a question related to my last post. When specifying a link in a
 HTML file (like to the css or an image file), there are two ways of
 doing it. One is to simply include the relative path to the file
 (relative to the doc root), like:

 /graphics/my_portrait.gif

 Or you can include the full URL, like:

 http://example.com/graphics/my_portrait.gif

 My casual observation seems to indicate that the former will load faster
 than the latter. But has anyone done any benchmarking on it?


Hi Paul,

There is no difference in speed.
The difference is in manageability.
Copying the scripts to another domain and you're using full url for
your src and href when referring to local images or css or pages, will
give you trouble and you must change all of them to your new domain.

Virgil
http://www.jampmark.com

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



Re: [PHP] display_errors and error_reporting not enough?

2009-02-17 Thread Virgilio Quilario
 I want to enable error messages while I'm testing or developing.
 I use php 5.2.4 on ubuntu server.
 These two lines does only print notices.

 ?php
   ini_set('display_errors', 1);
   error_reporting(E_ALL);
 ?

 When I make something wrong like syntax error; I get blank pages.
 Is there something else which I don't know?
 Here is the phpinfo();
 http://77.79.86.103/phpinfo.php
 Googling brings only these two and variations of error_reporting parameters.


hi,

find the errors in your apache error log.
also see error_log in PHP manual for details.

virgil
http://www.jampmark.com

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



Re: [PHP] [Fwd] How to make a secured login form

2009-02-13 Thread Virgilio Quilario
 I have secured the login form for my CMS with a challenge-response thing
 that encrypts both username and password with the
 (login-attempts-counted) challenge (and; here's my problem: a system
 hash) sent by the server (it would end up in your html as a hidden
 inputs, or as part of a json transmission)..

 Since then, i've found these libs that do even longer one-way-crypto:
 http://mediabeez.ws/downloads/sha256.js-php.zip
 The principles i'm about to explain stay the same.

 *but i'd really like to know if my crypto can be improved*

 So instead of the browser getting just a text-field for username and
 password, you also send the challenge (and system_hash) value.
 That's a 100-character random string (include special characters!), then
 sha256-ed (for prettiness mostly i think).

 I really wonder if i can do without the systemhash..

  HTML 
 form id=myForm
   input type=hidden id=system_hash name=system_hash
 value=[SHA256 SORTA-MASTER-KEY__DUNNO-WHAT-TO-DO-WITH-THIS]/
   input type=hidden id=challenge name=challenge
 value=[SHA256RANDOMSTRINGFROMPHP]/
   table
   trtdLogin/tdtdnbsp;/tdtdinput id='login'
 name='login'//td/tr
   trtdPassword/tdtdnbsp;/tdtdinput id='pass'
 name='pass'//td/tr
   /table
 /form


  JS 

   $('#myform').submit (function() {
   var s = ($'system_hash')[0];
   var c = ($'challenge')[0];
   var l = $('#login')[0];
   var p = $('#pass')[0];

   l.value = sha256 (sha256 (l.value + s.value) + c.value);
   p.value = sha256 (sha256 (p.value + s.value) + c.value);

   //Here, submit the form using ajax routines in plain text,
 as both the login name and
   //password are now one-way-encrypted.
   //
   //on the PHP end, authentication is done against a mysql
 table users.
   //
   //in this table i have 3 relevant fields:
   //user_login_name (for administrative and display purposes)
   //user_login_name_hash (==sha256 (user_login_name +
 system_hash))
   //user_password_hash (== passwords aint stored unencrypted
 in my cms, to prevent admin corruption and pw-theft by third parties;
 the password is encrypted by the browser in the new-password-form with
 the system hash before it's ever sent to the server. server Never knows
 about the cleartext password, ever.)
   //
   //when a login-attempt is evaluated, all the records in
 users table have to be traversed (which i admit can get slow on larger
 userbases... help!?! :)
   //for each user in the users table, the loginhash and
 password hash are calculated;
   //$uh = sha256 ($users-rec[user_login_name_hash] .
 $challenge);
   //$pwh = sha256 ($users-rec[user_password_hash] .
 $challenge);
   //and then,
   //if they match the hash strings that were sent (both of
 them),
   //if the number of login-attempts isn't exceeded,
   //if the IP is still the same (as the one who first
 requested the html login form with new challenge value)
   //then, maybe, i'll let 'm log in :)
   });




 phicarre wrote:

 How to secure this jquery+php+ajax login procedure ?

 $('#myform').submit( function()
{
$(this).ajaxSubmit( {
type:'POST', url:'login.php',
success: function(msg)
{
 login ok : how to call the welcome.php ***
},
error: function(request,iderror)
{
alert(iderror +   + request);
}
});
return false;
})


 form id=myForm action= 

Name : input type='text' name='login' size='15' /
divPassword : input type='password' name='passe' size='15' /


 /div


input type=submit value=login class=submit /

 /form

 Login.php check the parameters and reply by echo ok or echo ko

 Logically if the answer is ok we must call a welcome.php module BUT,
 if someone read the client code, he will see the name of the module
 and can hack the server.
 May I wrong ? how to secure this code ?


i think you should drop the IP address out of the equation because
when you're behind a firewall with rotating outgoing IP addresses, you
will never get authenticated.

also, traversing users table is a slow operation as you pointed out.

i guess you should look into two way encryption or use ssl which is
better and easier to implement.

virgil
http://www.jampmark.com

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



Re: [PHP] APC problem with PHP

2009-02-13 Thread Virgilio Quilario

  Hmm, I'll try taking down the optimizer and seeing if it segfaults or
  not. If that's what it is it's a crying shame that apc and
  zend_optimizer can't get along.


 maybe give eaccelerator a shot, i believe theyve got an optimizer in there.
 im not sure how it stacks up to zend's, but it will do both caching and
 optimization, afaik.  also, you will find a not yet stable optimization
 extension haging out in pecl for apc,

 http://pecl.php.net/package/optimizer

 -nathan


 I'd recommend using X-Cache. I've had nothing but good experiences with it.


i would also recommend x-cache.
it's incredibly fast and stable.
i could also cache data on memory with it.
have used it on high traffic sites with no problem ever since.

Virgil
http://www.jampmark.com

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



Re: [PHP] Re: Extract result from a https remote server response

2009-02-13 Thread Virgilio Quilario
 Sorry all, I was testing in a Windows environment.
 I feel like an idiot... :)

 Thanks to all.

 --
 m a r k u s

 Bruno Fajardo wrote:

 Assigning the return of file_get_contents to a variable?
 Didn't get your point...

 2009/2/13 m a r k u s queribus2...@hotmail.com

 Shawn McKenzie wrote:

 Shawn McKenzie wrote:

 m a r k u s wrote:

 Hi all,

 Example :
 https://www.moneybookers.com/app/email_check.pl?email=t...@toto.comcust_id=123546password=123
 The MB server response displayed is : Illegal operation.
 We would like to put the result below in a php variable and process it
 .
 An idea ?

 PS: The server is secured. The php functions like file(),
 file_get_contents(), readfile(), fopen() has been tested.
 Regards

 --

 m a r  k u s

 allow_url_fopen = On

 We have no control of the MB remote server configuration.

 --
 m a r k u s

 --

in your php.ini, set allow_url_fopen = On

then do this:

$contents = 
file_get_contents('https://www.moneybookers.com/app/email_check.pl?email=t...@toto.comcust_id=123546password=123');

if ($contents !== FALSE)
  // $contents now have your data to work on

virgil
http://www.jampmark.com

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



Re: [PHP] Opinions needed

2009-02-13 Thread Virgilio Quilario
 I'm scripting a light-weight, low volume signup registry for a running club.
 Folks sign up to volunteer for events and the like.  There will generally be
 a handful of signup registries at any one time. A typical registry will only
 contain 50 to 100 names.  Each registry is only in existence for a month or
 so.

 I really don't see the advantage of using a real DB [e.g., mySQL,] for this.
 Don't need any special searching, etc.

 Am thinking of using a simple serialized array file for each registry; or,
 using Pear Cache_lite.  Cache_lite has several nice functions I can take
 advantage of.  In spite of its name, it can be configured to be permanent.

 I'd just go ahead and use Cache_lite; but, I'm always reluctant to use a
 Pear package for fear it may not be updated for for future php releases,
 etc. I aways aim to keep maintenance to a minimum.

 Anyone had experience with Cache_Lite? Anyone have an opinion on the
 alternatives or maybe another storage approach?

 Thanks, Al


I think you should fear for updates in Pear because that might break your code.
once you get it working and you're happy with it, try not to update
unless there is a real need.

you should also consider concurrency where multiple users
simultaneously doing logins.
your data file may end up broken.

good luck

Virgil
http://www.jampmark.com

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



Re: [PHP] How can an elephant count for nothing?

2009-02-13 Thread Virgilio Quilario
 While PHP has a lot of nice features, it also has some traps which I am 
 forever falling
 into. One which I find particularly hard to understand is how mixed mode 
 comparisons work.
 For instance

 $string =  'elephant';
 If($string == 0) returns true;
 If($string != 0) returns false;
 If($string === 0) returns false;

 I know that in this case I should use 'If($string == '')', but I still manage 
 to forget.
 Can anyone explain clearly why comparing a string with zero gives this 
 apparently
 anomalous result?


when comparing string with integer, the interpreter first converts
string into an integer before comparison takes place.

Virgil
http://www.jampmark.com

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



Re: [PHP] Simple open source CMS as a starting point

2009-02-13 Thread Virgilio Quilario
 I need simple CMS sistem that I could use as a staring point (to save some
 time in setting up the structure) in developing my own CMS. The code
 should be simple to understand so that I can easily get on and start
 building on it. It would be of great help if it already had features like
 statistics, rss feeds, and multi-language support (visitors can click on
 the flag at the top of the page and have the pages display the content in
 that particular language), but if it doesn't it's okay I would build them.

 For example Joomla seems to be too powerfull, and pretty diffucult to
 understand at the coding level in order to customize it to serve my
 specific needs.

 Does anyone know of any promising open source CMS project that I could use
 in this respect?

 Thanks,
 Dzenan


Are you referring to 5 minute sites?

anyway, try word press.
it is very easy to add custom pages in PHP.
you can also download free modules for rss feeds and multi-language
support with flags at the top.

good luck,

Virgil
http://www.jampmark.com

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



Re: [PHP] Happy 1234567890 day!

2009-02-13 Thread Virgilio Quilario
 http://coolepochcountdown.com/

 On Fri, 2009-02-13 at 13:34 -0500, TG wrote:

 http://timestamp1234567890.com/




Happy cool epoch 1234567890 day!

virgil
http://www.jampmark.com

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



Re: [PHP] PHP OOP

2009-02-12 Thread Virgilio Quilario
Java is really awesome at OOP and it is great for teaching OOP or,
shall we say illustrating OOP.
OOP is a programming technique in general without any bias towards any
programming language.
Good background on OOP concepts is essential in learning language
specific OOP implementation.
So don't worry about languages.
The important thing is, you know what OOP means.

Also you can't compare PHP to other programming languages.
PHP is new and mainly built for the web.
With its raw power, it is simply incomparable.

virgil
http://www.jampmark.com

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



Re: [PHP] (Perl) Regular Expressions - oposite match or get the non-matches of a substring

2009-02-11 Thread Virgilio Quilario
 Hi all,

 I consider myself quite good with Regular Expression, but i could never find
 out how to match something like:

 match this but not this and that

 so i would like to match the first match this (or another this) but not
 not this.

 Seems pretty straight forward but i haven't found a (good) solution yet.
 Please no solutions with extra code, i know how to do that. I need a regular
 expression that can do it, preferably Perl compatible. Surprisingly i
 couldn't figure out how to say '/!(not) this/'. Seems like there must be a
 simple way, but i can't seem to figure it out.

 Tried things like: '/[^n][^o][^t] this/', '/[^not]{3} this/' etc but all of
 those don't work. Looked in various books and websites but didn't find what
 i was looking for...



try this

/match this but (?!not this and that)/

goodluck!

Virgil
http://www.jampmark.com

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



Re: [PHP] Help on caching an object.

2009-02-11 Thread Virgilio Quilario
 My problem is very simple:
 I have an object that's definately called with every page request.
 It's pretty much the same for every unregistered/anonymous user.
 And it's not small. Alot of attributes are being set from DB queries etc.

 Now my idea was to do some sort of caching with PHP to speed things up.
 So I was wondering if anybody had experiences on this ...

 Of course, I considered using serialize(), but it seemed to me as if
 it could cause even more lagging since PHP requires the class to
 unserialize the object correctly. Then I would end up reading the
 class file, reading the searialized object and unserializing it. A 100
 simple DB queries might be done in the same time or at least not much
 slower.

 Could it be that I'm looking at the wrong place? Should it be more
 like caching the queries or something similar?

 Thank you very much for everyone's effort in advance.




serialize is much faster than getting data from database.
i use this approach to unload DB usage and it made big difference.
it would be much more faster if serialized object is saved onto ram
using xcache or similar.

Virgil
http://www.jampmark.com

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



Re: [PHP] Module Structure ideas

2009-02-11 Thread Virgilio Quilario
 Last year I began to sepearte my module files to many files for their
 purposes.

 Last time use use lots of dirs for their types

 someting like

 controllers
  a.cont.php
  b.cont.php
 definition
  a.def.php
  b.def.php
 models
  a.model.php
  b.model.php
 views
  a.view.php
  b.view.php

 Then I realize this model creates confusion when you start to debug a module.

 My next step was putting module files in one dir,
 also I want to load them into text editor with spesific order
 (same to including order).

 and I came up some ting like this

 a.test.def.php
 c.test.mdl.php
 e.test.cnt.php
 g.test.rtr.php
 i.test.view.php
 k.test.dr.js
 m.test.m.js
 o.test.css

 test_app.a.def.php
 test_app.c.mdl.php
 test_app.e.cnt.php
 test_app.g.rtr.php
 test_app.i.view.php
 test_app.k.dr.js
 test_app.m.js
 test_app.o.css

 test.adef.php
 test.cmdl.php
 test.ecnt.php
 test.grtr.php
 test.iview.php
 test.kdr.js
 test.m.js
 test.o.css

 My point of view the 3. option is good for me.

 So I want to ask  this

 (beacause I'm using very closed working model. Just KDE and KATE)

 is kind of file structure may lead any kind of problems in future or
 diffrerent situation ?

 also is there any suggestion to using different methot to archive similar
 goals.


option #3 works for me too small projects without using frameworks.
for big projects, i prefer to organize my script files by type:
/models
/controllers
/views

i don't have problems with jumping around folder to folder because i
keep files open in separate windows.

Virgil
http://www.jampmark.com

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