php-general Digest 14 Feb 2011 15:49:40 -0000 Issue 7181

Topics (messages 311272 through 311277):

Re: php-general Digest 14 Feb 2011 03:32:02 -0000 Issue 7180
        311272 by: Florin Jurcovici
        311274 by: Thijs Lensselink

Re: using BOTH GET and POST in the same page.
        311273 by: Paul M Foster

Re: Simplifying MySql queries
        311275 by: Simcha Younger

extract price by preg_match_all
        311276 by: Tontonq Tontonq

Re: Help! Made a boo-boo encrypting credit cards
        311277 by: Brian Dunning

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
Hi.

>> Me stupid, my bad.
>>
>> Turns out the bug isn't in my code, but in the debugger. I'm working
>> with the trial version of Zend Studio. When inside the call to the
>> static method, everything is undefined. If I look at variables using
>> the Expressions view, I can see their values, and they _are_ defined.
>
> Maybe the "break at first line" switch is on in the debug config. If you
> step through you should see all variables. Two things i can think of.
>
> 1. Your breakpoints are set before the var us initialised
> 2. something wrong with your IDE/debugger setup
Nope. Bug in xdebug for Ubuntu documented here:
https://bugs.launchpad.net/ubuntu/+source/xdebug/+bug/545502

The bug comments also contain a link to a debian package which, when
installed, elliminates the bug. Did so, now I have a very nicely
working PHP development environment, which stops at breakpoints
(missing breakpoints was another issue, but that one came from
configuration) and shows the values of variables during debugging.
Only, not showing values of variables is something you definitely
don't expect from a debugger, so initially I didn't even think of the
possibility of a debugger bug.

br,

flj

--- End Message ---
--- Begin Message ---
On 02/14/2011 05:53 AM, Florin Jurcovici wrote:
> Hi.
> 
>>> Me stupid, my bad.
>>>
>>> Turns out the bug isn't in my code, but in the debugger. I'm working
>>> with the trial version of Zend Studio. When inside the call to the
>>> static method, everything is undefined. If I look at variables using
>>> the Expressions view, I can see their values, and they _are_ defined.
>>
>> Maybe the "break at first line" switch is on in the debug config. If you
>> step through you should see all variables. Two things i can think of.
>>
>> 1. Your breakpoints are set before the var us initialised
>> 2. something wrong with your IDE/debugger setup
> Nope. Bug in xdebug for Ubuntu documented here:
> https://bugs.launchpad.net/ubuntu/+source/xdebug/+bug/545502
> 
> The bug comments also contain a link to a debian package which, when
> installed, elliminates the bug. Did so, now I have a very nicely
> working PHP development environment, which stops at breakpoints
> (missing breakpoints was another issue, but that one came from
> configuration) and shows the values of variables during debugging.
> Only, not showing values of variables is something you definitely
> don't expect from a debugger, so initially I didn't even think of the
> possibility of a debugger bug.

I had no idea you were using Xdebug. When you said Zend Studio i assumed
you were using the standard Zend debugger. My bad.

Been trying to get Xdebug working in combination with Zend Studio 8. The
two seem to talk to each other. But Zend Studio doesn't display any
data, no breakpoints, etc

i compiled from source since i am using Zend Server. No luck. So back to
the Zend Debugger for now.

> 
> br,
> 
> flj
> 


--- End Message ---
--- Begin Message ---
On Sun, Feb 13, 2011 at 02:25:45PM -0500, tedd wrote:

> At 10:53 AM +0530 2/12/11, Ashim Kapoor wrote:
> >Dear All,
> >
> >I am reading "PHP5 and MySQL Bible". Chapter 7 of the book says that PHP can
> >use GET and POST in the SAME page! Also it says that we can use the SAME
> >variables in GET and POST variable sets and that conflict resolution is done
> >by variable_order option in php.ini Can some one write a small program to
> >illustrate the previous ideas?  It is not clear to me as to how to implement
> >this.
> >
> >Many thanks,
> >Ashim.
> 
> Ashim:
> 
> What others have not addressed is that the form used to send
> variables will send only GET OR POST method variables, but not both
> at the same time.
> 
> Using REQUEST will show the values of the variables sent, but will
> not show what method was used (not addressing COOKIE) and that is the
> reason why it's not the best idea to use REQUEST.
> 
> Furthermore, as you point out, conflict resolution is done in
> accordance with variable order as set in the php.ini file and that
> can be different between different environments. As such, a script
> can act differently and there in lies the problem.
> 
> Now, I have used scripts that may receive POST or GET variables and
> act accordingly, but you will never (except possibly AJAX) have a
> situation where a script will receive both sets of variables at the
> same time. So, I don't think one can write a small simple script that
> can demonstrate this.

I'm sure I must be misunderstanding something here. The following is a
script which will show both GET and POST being received by the script,
and with the same variable names but different values:

=-=-=-=-=-=-=-=-=-

<?php
print "GET:<br/>\n";
print_r($_GET);
print "<br/>\n";
print "POST:<br/>\n";
print_r($_POST);
 
?>

<form method="post">
<input type="text" name="alfa"/>
<input type="submit" name="submit"
value="submit"/>
</form>

=-=-=-=-=-=-=-=-=-=

Call this script via test.php?alfa=1234
Call it the first time this way and leave that in the location bar of
your browser. Now fill in the value in the blank with the value 4567.
Press the "submit" button. You will see that $_POST['alfa'] returns
4567, while $_GET['alfa'] returns 1234.

It sounds like you're saying this isn't possible, yet it is. So what am
I missing? Is there an error in my code?

Paul

-- 
Paul M. Foster
http://noferblatz.com


--- End Message ---
--- Begin Message ---
On Sat, 12 Feb 2011 22:40:27 +0200
Andre Polykanine <[email protected]> wrote:

> Hi all,
> I'm using in my PHP script the following four MySql queries:
> $q1=mysql_query("SELECT     *    FROM    `CandidateQuestions`    WHERE
> `Category`='1' ORDER BY RAND() LIMIT 1");
> $q2=mysql_query("SELECT     *    FROM    `CandidateQuestions`    WHERE
> `Category`='2' ORDER BY RAND() LIMIT 1");
> $q3=mysql_query("SELECT     *    FROM    `CandidateQuestions`    WHERE
> `Category`='3' ORDER BY RAND() LIMIT 1");
> $q4=mysql_query("SELECT     *    FROM    `CandidateQuestions`    WHERE
> `Category`='4' ORDER BY RAND() LIMIT 1");
> 
> and  here  goes the question: is there a way to make these four in one
> so  strictly  one  random  question  is  selected from all of the four
> categories?
> Thanks!

select * from (select * from `CandidateQuestions` order by rand() ) t group by 
`Category`;


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


-- 
Simcha Younger <[email protected]>

--- End Message ---
--- Begin Message ---
example data:

<div class="picboxfooter">
  <span class="newprice"><span class="productOldPrice">old price 829,00
&euro;</span><br />your price 58,90 &euro; *</span>
</div>

another :
  <span class="newprice"> 9,90 &euro; *</span>

i want to extract 829,.00 & 58,90 from first source , 9,90 from the second

i tried many way like preg_match_all('/<span
class="newprice">(\$[0-9,]+(\.[0-9]{2})?)<\/span>/',$data,$prices);
it doesn't work

--- End Message ---
--- Begin Message ---
On Feb 13, 2011, at 12:44 AM, Richard Quadling wrote:

> You are
> using addslashes($_POST['cc_number']). Considering a credit card
> number is purely numeric, the addslashes would seem to be redundant as
> you don't need to escape numbers.

I do that routinely to all input fields as one additional layer of protection 
against injection attacks.


> And you can run a Luhn10 check
> against the card number to make sure it is valid before storing it.

I do that as well.


--- End Message ---

Reply via email to