Re: [PHP] ?=$var?
Larry Martell wrote: Continuing in my effort to port an app from PHP version 5.1.6 to 5.3.3, the app uses this construct all over the place when building links: ?=$var? I never could find any documentation for this, but I assumed it was some conditional thing - use $var if it's defined, otherwise use nothing. In 5.1.6 it seems to do just that. But in 5.3.3 I'm not getting the value of $var even when it is defined. Has this construct been deprecated? Is there now some other way to achieve this? There WAS a period when ?= was linked to short opening tag setting, which cause a number of headaches, but currently the two are now isolated! -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ?=$var?
On Wed, Apr 17, 2013 at 5:02 PM, Micky Hulse rgmi...@gmail.com wrote: On Wed, Apr 17, 2013 at 3:59 PM, Micky Hulse rgmi...@gmail.com wrote: You might need to turn on the short tag option in your conf file. Sorry, ini file, not conf. Been a long day. :D I guess I should have asked if short tags are turned on for your 5.3.3? That was it. Thanks!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ?=$var?
On Thu, Apr 18, 2013 at 8:36 AM, Larry Martell la...@software-horizons.com wrote: That was it. Thanks!! Np. Glad it helped. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ?=$var?
Continuing in my effort to port an app from PHP version 5.1.6 to 5.3.3, the app uses this construct all over the place when building links: ?=$var? I never could find any documentation for this, but I assumed it was some conditional thing - use $var if it's defined, otherwise use nothing. In 5.1.6 it seems to do just that. But in 5.3.3 I'm not getting the value of $var even when it is defined. Has this construct been deprecated? Is there now some other way to achieve this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ?=$var?
It should still work. You might need to turn on the short tag option in your conf file. http://stackoverflow.com/a/2185331/922323 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ?=$var?
On Wed, Apr 17, 2013 at 3:59 PM, Micky Hulse rgmi...@gmail.com wrote: You might need to turn on the short tag option in your conf file. Sorry, ini file, not conf. Been a long day. :D I guess I should have asked if short tags are turned on for your 5.3.3? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] ?=$var?
It is the equivalent of ?php echo $var; ? it's just easier to type and read IMHO. For a while people were freaking out that they thought it would be deprecated, but that is not (nor ever will be) the case. -Original Message- From: Larry Martell [mailto:larry.mart...@gmail.com] Sent: Wednesday, April 17, 2013 3:51 PM To: PHP General Subject: [PHP] ?=$var? Continuing in my effort to port an app from PHP version 5.1.6 to 5.3.3, the app uses this construct all over the place when building links: ?=$var? I never could find any documentation for this, but I assumed it was some conditional thing - use $var if it's defined, otherwise use nothing. In 5.1.6 it seems to do just that. But in 5.3.3 I'm not getting the value of $var even when it is defined. Has this construct been deprecated? Is there now some other way to achieve this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ?=$var?
Ah, I see now. Sorry, I must have read the original question wrong. There's a good thread on stack about short tags: Are PHP short tags acceptable to use? http://stackoverflow.com/questions/200640/are-php-short-tags-acceptable-to-use Which kinda links to the docs: PHP tags http://www.php.net/manual/en/language.basic-syntax.phptags.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] $$var
Dear All, I was reading the php manual for session_register, and I found the following line there : - $_SESSION[$var] = $$var; Why do I need $$ there ? Can someone explain? Thank you, Ashim
Re: [PHP] $$var
Hi Ashim, These are called Variable Variables. Ideally they should be avoided, as they introduce unnecessary legibility issues. This is what it does in a nutshell, it's actually quite simple: $foo = 'bar'; $bar = 'foobar'; echo $$foo;//This prints foobar What it does is, take the value of $foo (which is 'bar') and if a variable exists by that name, it will go forth and print the value of $bar; In this case foobar. On Sun, Mar 6, 2011 at 11:12 PM, Ashim Kapoor ashimkap...@gmail.com wrote: Dear All, I was reading the php manual for session_register, and I found the following line there : - $_SESSION[$var] = $$var; Why do I need $$ there ? Can someone explain? Thank you, Ashim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $$var
Hi Ashim, These are called Variable Variables. Ideally they should be avoided, as they introduce unnecessary legibility issues. This is what it does in a nutshell, it's actually quite simple: $foo = 'bar'; $bar = 'foobar'; echo $$foo;//This prints foobar What it does is, take the value of $foo (which is 'bar') and if a variable exists by that name, it will go forth and print the value of $bar; In this case foobar. Alright Russel, Thank you, Ashim.
Re: [PHP] $$var
Just being curious, I have a question. How many times PHP interpreter will replace this variables? I mean how deep it will be? If I use variable variables like $$a how long it will be evaluated? -- Shiplu Mokadd.im My talks, http://talk.cmyweb.net Follow me, http://twitter.com/shiplu Innovation distinguishes between follower and leader
Re: [PHP] $$var
∞ 2011/3/6 shiplu shiplu@gmail.com Just being curious, I have a question. How many times PHP interpreter will replace this variables? I mean how deep it will be? If I use variable variables like $$a how long it will be evaluated? -- Shiplu Mokadd.im My talks, http://talk.cmyweb.net Follow me, http://twitter.com/shiplu Innovation distinguishes between follower and leader
Re: [PHP] $$var
At 6:42 PM +0530 3/6/11, Ashim Kapoor wrote: Dear All, I was reading the php manual for session_register, and I found the following line there : - $_SESSION[$var] = $$var; Why do I need $$ there ? Can someone explain? Thank you, Ashim Ashim: You don't need to user session_register(). Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $$var
If $a = 'foo' and $$a = nothing (i.e. no value assigned to $foo) you will get an error if you tried to use this to do something else. On Sun, Mar 6, 2011 at 3:21 PM, tedd tedd.sperl...@gmail.com wrote: At 6:42 PM +0530 3/6/11, Ashim Kapoor wrote: Dear All, I was reading the php manual for session_register, and I found the following line there : - $_SESSION[$var] = $$var; Why do I need $$ there ? Can someone explain? Thank you, Ashim Ashim: You don't need to user session_register(). Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Mujtaba
Re: [PHP] $$var
As per my experience so far, there is no such depth limit existing. The only limit is imposed by the system resources (like script execution time etc.) but not by PHP. Cheers NetEmp On Sun, Mar 6, 2011 at 8:42 PM, shiplu shiplu@gmail.com wrote: Just being curious, I have a question. How many times PHP interpreter will replace this variables? I mean how deep it will be? If I use variable variables like $$a how long it will be evaluated? -- Shiplu Mokadd.im My talks, http://talk.cmyweb.net Follow me, http://twitter.com/shiplu Innovation distinguishes between follower and leader
[PHP] ?=$var? on OS X
I've got a new OS X box and for some reason ?=$var? doesn't work like it does on all my other OS X boxes - anyone know a quick reason why not? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ?=$var? on OS X
Brian Dunning wrote: I've got a new OS X box and for some reason ?=$var? doesn't work like it does on all my other OS X boxes - anyone know a quick reason why not? Check your php.ini for short_open_tags. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ?=$var? on OS X
On 27/11/06, Brian Dunning [EMAIL PROTECTED] wrote: I've got a new OS X box and for some reason ?=$var? doesn't work like it does on all my other OS X boxes - anyone know a quick reason why not? Exactly for that reason I don't recommend that you use it. Just use ?php print $var; ? as it's portable and doesn't add that much typing- certainly not enough to justify the headache. Dotan Cohen http://what-is-what.com/what_is/webpage.html http://lyricslist.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ?=$var? on OS X
Dotan Cohen wrote: On 27/11/06, Brian Dunning [EMAIL PROTECTED] wrote: I've got a new OS X box and for some reason ?=$var? doesn't work like it does on all my other OS X boxes - anyone know a quick reason why not? Exactly for that reason I don't recommend that you use it. Just use ?php print $var; ? as it's portable and doesn't add that much typing- certainly not enough to justify the headache. Good suggestion but it doesn't help if it's not his software that he needs to get running ;) -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ?=$var? on OS X
On 27/11/06, Chris [EMAIL PROTECTED] wrote: Dotan Cohen wrote: On 27/11/06, Brian Dunning [EMAIL PROTECTED] wrote: I've got a new OS X box and for some reason ?=$var? doesn't work like it does on all my other OS X boxes - anyone know a quick reason why not? Exactly for that reason I don't recommend that you use it. Just use ?php print $var; ? as it's portable and doesn't add that much typing- certainly not enough to justify the headache. Good suggestion but it doesn't help if it's not his software that he needs to get running ;) Actually, it does. He can global replace ?= with ?php print and be done with it. Then he could let the author of this non-portable software know that his 'shortcut' makes using the software difficult. Especially if it's not his own code (ie, code meant to be used by others) it should not depend upon short tags. Dotan Cohen http://dotancohen.com/ http://what-is-what.com/what_is/website.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ?=$var? on OS X
Dotan Cohen wrote: On 27/11/06, Chris [EMAIL PROTECTED] wrote: Dotan Cohen wrote: On 27/11/06, Brian Dunning [EMAIL PROTECTED] wrote: I've got a new OS X box and for some reason ?=$var? doesn't work like it does on all my other OS X boxes - anyone know a quick reason why not? Exactly for that reason I don't recommend that you use it. Just use ?php print $var; ? as it's portable and doesn't add that much typing- certainly not enough to justify the headache. Good suggestion but it doesn't help if it's not his software that he needs to get running ;) Actually, it does. He can global replace ?= with ?php print and be done with it. Then he could let the author of this non-portable software know that his 'shortcut' makes using the software difficult. Especially if it's not his own code (ie, code meant to be used by others) it should not depend upon short tags. Well he could also change it with a htaccess :P php_flag short_open_tags on -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ?=$var? on OS X
On 27/11/06, Chris [EMAIL PROTECTED] wrote: Dotan Cohen wrote: On 27/11/06, Chris [EMAIL PROTECTED] wrote: Dotan Cohen wrote: On 27/11/06, Brian Dunning [EMAIL PROTECTED] wrote: I've got a new OS X box and for some reason ?=$var? doesn't work like it does on all my other OS X boxes - anyone know a quick reason why not? Exactly for that reason I don't recommend that you use it. Just use ?php print $var; ? as it's portable and doesn't add that much typing- certainly not enough to justify the headache. Good suggestion but it doesn't help if it's not his software that he needs to get running ;) Actually, it does. He can global replace ?= with ?php print and be done with it. Then he could let the author of this non-portable software know that his 'shortcut' makes using the software difficult. Especially if it's not his own code (ie, code meant to be used by others) it should not depend upon short tags. Well he could also change it with a htaccess :P php_flag short_open_tags on If it's for many files and he doesn't know perl (I don't either, but I know that perl can search/replace many files with ease), then he could override the php.ini settings in .htaccess. That, however, doesn't solve the root problem: the use of short tags. If he needs the fix for only one file, then open it in vi (or whatever gui app Macs use :) and have at it. Dotan Cohen http://what-is-what.com/what_is/html_email.html http://song-lirics.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Var within a var
Hi All Im trying to store a document template in mysql that has php var names within it and then find it in the datebase and print it out with the var names replaced with the var values. e.g i have this stored Dear $title $name we would like to.. I declare the vars $title and $name $title = 'Mr'; $name = 'Test'; //retrieve the stored template $query = select template from letters; $result = mysqli_query($dblink,$query); if($row = mysqli_fetch_array($result)){ print $row['template']; } i would expect that to print: Dear Mr Test we would like to.. but it doesnt it prints out Dear $title $name we would like to.. can someone point out where i am going wrong? Thanks for any help in advance! Cheers Bob - Yahoo! Photos NEW, now offering a quality print service from just 8p a photo.
Re: [PHP] Var within a var
This one time, at band camp, bob pilly [EMAIL PROTECTED] wrote: Hi All Im trying to store a document template in mysql that has php var names within it and then find it in the datebase and print it out with the var names replaced with the var values. eval() Kevin -- Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] var references question
Greetings, This is a little difficult to explain. So, below is an example I will work from. Forgive my ignorance here. I am a java developer using php4 and trying to figure out a particular scenario. In the following example when I run the myscript.php I pass the $myarr into the addVal function of the MyClass class. The var_dump in the addVal function appropriately displays all of the elements of the array a,b,c and d. However, the var_dump that is done in the script immediately following the addVal method call displays only elements a,b and c with NO d. From what I can see, php does not retain the same reference to the array object when it passes it into the function. It appears that it clones the array and retains only the changes within the scope of the function. In java I am used to creating an array and passing it into a method which accomplishes operations against the array. The passed in array is also modified because it is a reference to the same array object. Is there a way to accomplish this behavior in php 4? For example: myscript.php . $myarr = array(); $myarr[valuea]=a; $myarr[valueb]=b; $myarr[valuec]=c; $myclass = new MyClass(); $myclass-addVal($myarr); var_dump($myarr); . ===end myclass.php class MyClass { function addVal($myarr){ $myarr[valued] = d; var_dump($myarr); } } ===end Thanks, Brandon
Re: [PHP] var references question
* Thus wrote Brandon Goodin: Greetings, In the following example when I run the myscript.php I pass the $myarr into the addVal function of the MyClass class. The var_dump in the addVal function appropriately displays all of the elements of the array a,b,c and d. However, the var_dump that is done in the script immediately following the addVal method call displays only elements a,b and c with NO d. From what I can see, php does not retain the same reference to the array object when it passes it into the function. It appears that it clones the array and retains only the changes within the scope of the function. In java I am used to creating an array and passing it into a method which accomplishes operations against the array. The passed in array is also modified because it is a reference to the same array object. PHP pass by value by default, you want to pass by reference, see: http://php.net/functions.arguments.php Curt -- The above comments may offend you. flame at will. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] var references
I have the following: ?php include('../../../db2.php'); $blat = $tue_5a; $result = mysql_query(SELECT * FROM classes WHERE c_d_tue='1' AND c_s_tue_1_hr='5' AND c_s_tue_1_dn='am'); while($row = mysql_fetch_array($result)) { switch($blat) { case tue_5a: $min_1 = $row[29]; break; } ? class title:brinput type=text value=? echo $row[c_title]; ?/inputbr class minute:brinput type=text value=? echo $min_1; ?/inputbr class description:brtextarea? echo $row[c_desc]; ?/textareabr ? } ? Why can I not refence the row[29] from min_1? ive tried various ways and nothing shows up unless i actually put the assoc array value. Any ideas? It should display 50. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] var references
Arthur Pelkey mailto:[EMAIL PROTECTED] on Friday, February 06, 2004 9:46 AM said: $blat = $tue_5a; [snip] while($row = mysql_fetch_array($result)) { switch($blat) { case tue_5a: $min_1 = $row[29]; break; } [snip] Why can I not refence the row[29] from min_1? ive tried various ways and nothing shows up unless i actually put the assoc array value. Any ideas? i think you forgot your $ in front of the tue_5a in 'case tue_5a'? otherwise the way you are using tue_5a the second time, appears to be a constant and not a string or a regular variable. hth, chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] var references
Thanks!, my syntax was a bit off, havn't had much sleep, but it kept slipping by me ;) Chris W. Parker wrote: Arthur Pelkey mailto:[EMAIL PROTECTED] on Friday, February 06, 2004 9:46 AM said: $blat = $tue_5a; [snip] while($row = mysql_fetch_array($result)) { switch($blat) { case tue_5a: $min_1 = $row[29]; break; } [snip] Why can I not refence the row[29] from min_1? ive tried various ways and nothing shows up unless i actually put the assoc array value. Any ideas? i think you forgot your $ in front of the tue_5a in 'case tue_5a'? otherwise the way you are using tue_5a the second time, appears to be a constant and not a string or a regular variable. hth, chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] /VAR is driving me crazy
Hi Does anyone have an idea what is so special about the string /VAR ? If i create a form that submits to a php file and in the form i put the string /VAR anywhere in the text or just /VAR I get an 404 error from apache on an existing file. If i take the same form and remove the /VAR string all is ok. I'm not sure if this is an apache issue or PHP. Did anyone encounter such a behavior? Sincerely berber Visit http://www.weberdev.com/ http://www.weberblog.com/ Today!!! To see where PHP might take you tomorrow. Share your code : http://addexample.weberdev.com Search for PHP Code from your browser http://toolbar.weberdev.com Share your thoughts : http://www.weberblog.com/submit.php?type=story -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] /VAR is driving me crazy
Boaz Yahav wrote: Hi Does anyone have an idea what is so special about the string /VAR ? If i create a form that submits to a php file and in the form i put the string /VAR anywhere in the text or just /VAR I get an 404 error from apache on an existing file. If i take the same form and remove the /VAR string all is ok. I'm not sure if this is an apache issue or PHP. Did anyone encounter such a behavior? The only thing I can think of is that if you're using GET as your form method and end up with something like: www.domain.com/file.php?v=/VAR then maybe for some odd reason you're web server is actually looking for a path of file.php?v= and VAR instead of realizing the /VAR is in a query string. That shouldn't be happening, though. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] /VAR is driving me crazy - SOLVED
Actually i just found the problem. My sysadmin recently added MOD Security and one of the lines that my conf file had was : SecFilter /var Security people can drive me crazy :) Sincerely berber Visit http://www.weberdev.com/ http://www.weberblog.com/ Today!!! To see where PHP might take you tomorrow. Share your code : http://addexample.weberdev.com Search for PHP Code from your browser http://toolbar.weberdev.com Share your thoughts : http://www.weberblog.com/submit.php?type=story -Original Message- From: John W. Holmes [mailto:[EMAIL PROTECTED] Sent: Friday, January 16, 2004 5:07 PM To: Boaz Yahav Cc: [EMAIL PROTECTED] Subject: Re: [PHP] /VAR is driving me crazy Boaz Yahav wrote: Hi Does anyone have an idea what is so special about the string /VAR ? If i create a form that submits to a php file and in the form i put the string /VAR anywhere in the text or just /VAR I get an 404 error from apache on an existing file. If i take the same form and remove the /VAR string all is ok. I'm not sure if this is an apache issue or PHP. Did anyone encounter such a behavior? The only thing I can think of is that if you're using GET as your form method and end up with something like: www.domain.com/file.php?v=/VAR then maybe for some odd reason you're web server is actually looking for a path of file.php?v= and VAR instead of realizing the /VAR is in a query string. That shouldn't be happening, though. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals - www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] var check not working...
For some reason this will not work... my $_POST variables check for no form variables and display a form... if they choose an item from a select box it queries the database for a field matching the $_post var and builds a new form creating 8 separate $_post variables to check for.. so far it works except when selecting an item from the select box it will only display the first form when there are $_post vars present. I think I am missing something, could someone look over my code? Thanks in advance, Jas function vlans_dhcp() { $lvl = base64_decode($_SESSION['lvl']); if ($lvl != admin) { $_SESSION['lvl'] = base64_encode($lvl); $_SESSION['msg'] = $dberrors[12]; call_user_func(db_logs); } elseif ($lvl == admin) { $_SESSION['lvl'] = base64_encode($lvl); if (($_POST == ) || (!isset($_POST['dhcp_vlans'])) || (!isset($_POST['sub'])) || (!isset($_POST['msk'])) || (!isset($_POST['dns01'])) || (!isset($_POST['dns02'])) || (!isset($_POST['rtrs'])) || (!isset($_POST['vlans']))) { create 1st form with dhcp_vlans as $_post var; } elseif (($_POST != ) || (isset($_POST['dhcp_vlans'])) || ($_POST['dhcp_vlans'] != --) || (!isset($_POST['sub'])) || (!isset($_POST['msk'])) || (!isset($_POST['dns01'])) || (!isset($_POST['dns02'])) || (!isset($_POST['rtrs'])) || (!isset($_POST['vlans']))) { create 2nd form based on dhcp_vlans $_post var and create 8 different $_post vars...; } elseif (($_POST != ) || (!isset($_POST['dhcp_vlans'])) || (isset($_POST['id'])) || (isset($_POST['sub'])) || (isset($_POST['msk'])) || (isset($_POST['dns01'])) || (isset($_POST['dns02'])) || (isset($_POST['rtrs'])) || (isset($_POST['rnge'])) || (isset($_POST['vlans']))) { now put 8 $_post vars in database...; } else { $_SESSION['lvl'] = base64_encode($lvl); header(Location: help.php); } } else { $_SESSION['lvl'] = base64_encode($lvl); $_SESSION['msg'] = $dberrors[12]; call_user_func(db_logs); } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Trying to submit form to frame and pass php var
Hi, you cannot invoke php functions from javascript. You have to pass on any relevent variables (which can be done with hidden input fields) with your POST/GET data to the script for processing on the server. [EMAIL PROTECTED] wrote: Hello I was wondering if someone could help me out. Trying to submit form to frame and pass php var at the same time. script language=JavaScript!-- function submitform(){ top.admin.document.adminform.submit(); } //--/script and... frameset rows=538,83 cols=* frame src=admin.php?order=1 name=admin id=admin frame src=status.php name=status scrolling=auto id=status /frameset Link look like: a href=javascript:submitform(); target=_parentDelete/a What I need to do though, is run this exact script while passing ($delete=yes) as php at the same time? Basically, run the form and if delete=yes then use the following form tag : form name=adminform method=post action=setup.php?delete=yes target=_parent Any ideas? Thanks Brandon -- http://www.radinks.com/upload Drag and Drop File Uploader. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Trying to submit form to frame and pass php var
Hello I was wondering if someone could help me out. Trying to submit form to frame and pass php var at the same time. script language=JavaScript!-- function submitform(){ top.admin.document.adminform.submit(); } //--/script and... frameset rows=538,83 cols=* frame src=admin.php?order=1 name=admin id=admin frame src=status.php name=status scrolling=auto id=status /frameset Link look like: a href=javascript:submitform(); target=_parentDelete/a What I need to do though, is run this exact script while passing ($delete=yes) as php at the same time? Basically, run the form and if delete=yes then use the following form tag : form name=adminform method=post action=setup.php?delete=yes target=_parent Any ideas? Thanks Brandon
[PHP] var static
I want to obtain only one instance of one class. In other to do that, I call to a static method, that creates the instance(if it doesnt exit) or returns the reference of the instance. The call to the static method is the next: $conexiondb=db::getInstancia(); Well, but if I call to db::getInstancia() another time, I obtain another new object :-( The code of the db class is the next (it is a Singleton Pattern, but it doesnt work) class db{ var $_miInstancia; function db (){ // funcion que se conecta con la BBDD static $miInstancia; $this-_miInstancia=$miInstancia; $result = @mysql_pconnect(inforalv, discoteca, password); if (!$result) return false; if ([EMAIL PROTECTED](discoteca)) return false; } function getInstancia(){ if (!isset($this)) $_miInstancia=new db(); return $_miInstancia; } } I think that the problem is that the var _miInstance is not static and I dont know how to do it. Could you please tell me if there is anything wrong? Thanks. Alvaro -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] var static
I want to obtain only one instance of one class. In other to do that, I call to a static method, that creates the instance(if it doesnt exit) or returns the reference of the instance. The call to the static method is the next: $conexiondb=db::getInstancia(); Well, but if I call to db::getInstancia() another time, I obtain another new object :-( The code of the db class is the next (it is a Singleton Pattern, but it doesnt work) class db{ var $_miInstancia; function db (){ // funcion que se conecta con la BBDD static $miInstancia; $this-_miInstancia=$miInstancia; $result = @mysql_pconnect(inforalv, discoteca, password); if (!$result) return false; if ([EMAIL PROTECTED](discoteca)) return false; } function getInstancia(){ if (!isset($this)) $_miInstancia=new db(); return $_miInstancia; } } I think that the problem is that the var _miInstance is not static and I dont know how to do it. Could you please tell me if there is anything wrong? Thanks. Alvaro -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] var static
Although PHP supports static variables in functions (see here), it has no support for static variables in classes. http://www.php.net/manual/en/language.variables.scope.php (espero que te sirva) saludos aniceto lópez :: DYNAMICAL.BIZ web development host services Barcelona - Spain -Mensaje original- Asunto: [PHP] var static I want to obtain only one instance of one class. In other to do that, I call to a static method, that creates the instance(if it doesnt exit) or returns the reference of the instance. The call to the static method is the next: $conexiondb=db::getInstancia(); Well, but if I call to db::getInstancia() another time, I obtain another new object :-( The code of the db class is the next (it is a Singleton Pattern, but it doesnt work) class db{ var $_miInstancia; function db (){ // funcion que se conecta con la BBDD static $miInstancia; $this-_miInstancia=$miInstancia; $result = @mysql_pconnect(inforalv, discoteca, password); if (!$result) return false; if ([EMAIL PROTECTED](discoteca)) return false; } function getInstancia(){ if (!isset($this)) $_miInstancia=new db(); return $_miInstancia; } } I think that the problem is that the var _miInstance is not static and I dont know how to do it. Could you please tell me if there is anything wrong? Thanks. Alvaro -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] var static
Hi, Friday, August 29, 2003, 3:01:45 AM, you wrote: AM I want to obtain only one instance of one class. In other to do that, I call AM to a static method, that creates the instance(if it doesnt exit) or returns AM the reference of the instance. AM The call to the static method is the next: AM$conexiondb=db::getInstancia(); AM Well, but if I call to db::getInstancia() another time, I obtain another new AM object :-( AM The code of the db class is the next (it is a Singleton Pattern, but it AM doesnt work) AM class db{ AMvar $_miInstancia; AMfunction db (){ AM // funcion que se conecta con la BBDD AM static $miInstancia; AM $this-_miInstancia=$miInstancia; AM $result = @mysql_pconnect(inforalv, discoteca, password); AM if (!$result) AMreturn false; AM if ([EMAIL PROTECTED](discoteca)) AMreturn false; AM} AM function getInstancia(){ AMif (!isset($this)) AM $_miInstancia=new db(); AMreturn $_miInstancia; AM } AM } AM I think that the problem is that the var _miInstance is not static and I AM dont know how to do it. AM Could you please tell me if there is anything wrong? AM Thanks. AM Alvaro static calls to a class will never have $this set so you have to set your reference globally something like this: ?php $_miInstancia = array(); class db{ var $c; function db ($count=false){ global $_miInstancia; $_miInstancia['db'] = $this; if($count)$this-c = $count; // funcion que se conecta con la BBDD $result = @mysql_pconnect(inforalv, discoteca, password); if (!$result) return false; if ([EMAIL PROTECTED](discoteca)) return false; } function getInstancia($count=false){ global $_miInstancia; if (!isset($_miInstancia['db'])){ new db($count); } return $_miInstancia; } } $conexiondb = db::getInstancia(1); print_r($conexiondb); $conexiondb2 = db::getInstancia(); print_r($conexiondb2); ? (The $count was just to prove we only have the one instance) -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] var static
I've found the solution myself. The db class is the next: class db{ function db (){ // funcion que se conecta con la BBDD $result = @mysql_pconnect(inforalv, discoteca, password); if (!$result) return false; if ([EMAIL PROTECTED](discoteca)) return false; } function getInstancia(){ static $miInstancia; if (!get_class($miInstancia) == 'db') $miInstancia=new db(); return $miInstancia; } and the call to this class is the next: $conexiondb1=db::getInstancia(); $conexiondb2=db::getInstancia(); In the second call I obtain the same object. Muchas gracias por vuestra ayuda Alvaro Dynamical.Biz [EMAIL PROTECTED] escribió en el mensaje news:[EMAIL PROTECTED] Although PHP supports static variables in functions (see here), it has no support for static variables in classes. http://www.php.net/manual/en/language.variables.scope.php (espero que te sirva) saludos aniceto lópez :: DYNAMICAL.BIZ web development host services Barcelona - Spain -Mensaje original- Asunto: [PHP] var static I want to obtain only one instance of one class. In other to do that, I call to a static method, that creates the instance(if it doesnt exit) or returns the reference of the instance. The call to the static method is the next: $conexiondb=db::getInstancia(); Well, but if I call to db::getInstancia() another time, I obtain another new object :-( The code of the db class is the next (it is a Singleton Pattern, but it doesnt work) class db{ var $_miInstancia; function db (){ // funcion que se conecta con la BBDD static $miInstancia; $this-_miInstancia=$miInstancia; $result = @mysql_pconnect(inforalv, discoteca, password); if (!$result) return false; if ([EMAIL PROTECTED](discoteca)) return false; } function getInstancia(){ if (!isset($this)) $_miInstancia=new db(); return $_miInstancia; } } I think that the problem is that the var _miInstance is not static and I dont know how to do it. Could you please tell me if there is anything wrong? Thanks. Alvaro -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] var static
Globals!? YUCK :) A better solution IMHO that maintains encapsulation, is to use a static var in a function: function getClassVar( $name ) { return getAndSetClassVar( $name, false ); } function setClassVar( $name, $value ) { return getAndSetClassVar( $name, true, $value ); } function getAndSetClassVar( $name, $set, $value ) { static $classVars = array(); if( !$set ) { return $classVars[$name]; } $classVars[$name] = $value; return $value; } Admittedly this is slower than using a global, but it doesn't pollute the global scope and ensures you'll never have naming conflicts. HTH, Rob. On Thu, 2003-08-28 at 13:48, Tom Rogers wrote: static calls to a class will never have $this set so you have to set your reference globally something like this: ?php $_miInstancia = array(); class db{ var $c; function db ($count=false){ global $_miInstancia; $_miInstancia['db'] = $this; if($count)$this-c = $count; // funcion que se conecta con la BBDD $result = @mysql_pconnect(inforalv, discoteca, password); if (!$result) return false; if ([EMAIL PROTECTED](discoteca)) return false; } function getInstancia($count=false){ global $_miInstancia; if (!isset($_miInstancia['db'])){ new db($count); } return $_miInstancia; } } $conexiondb = db::getInstancia(1); print_r($conexiondb); $conexiondb2 = db::getInstancia(); print_r($conexiondb2); ? (The $count was just to prove we only have the one instance) -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- .-. | Worlds of Carnage - http://www.wocmud.org | :-: | Come visit a world of myth and legend where | | fantastical creatures come to life and the | | stuff of nightmares grasp for your soul.| `-' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] var static
If I were you, I would use the following: if (!is_a ($miInstancia, 'db')) $miInstancia=new db(); That way you can ensure that the variable has been instantiated and is an instance of the db class.. But it may not really matter.. Jordan S. Jones Alvaro Martinez wrote: I've found the solution myself. The db class is the next: class db{ function db (){ // funcion que se conecta con la BBDD $result = @mysql_pconnect(inforalv, discoteca, password); if (!$result) return false; if ([EMAIL PROTECTED](discoteca)) return false; } function getInstancia(){ static $miInstancia; if (!get_class($miInstancia) == 'db') $miInstancia=new db(); return $miInstancia; } and the call to this class is the next: $conexiondb1=db::getInstancia(); $conexiondb2=db::getInstancia(); In the second call I obtain the same object. Muchas gracias por vuestra ayuda Alvaro Dynamical.Biz [EMAIL PROTECTED] escribió en el mensaje news:[EMAIL PROTECTED] Although PHP supports static variables in functions (see here), it has no support for static variables in classes. http://www.php.net/manual/en/language.variables.scope.php (espero que te sirva) saludos aniceto lópez :: DYNAMICAL.BIZ web development host services Barcelona - Spain -Mensaje original- Asunto: [PHP] var static I want to obtain only one instance of one class. In other to do that, I call to a static method, that creates the instance(if it doesnt exit) or returns the reference of the instance. The call to the static method is the next: $conexiondb=db::getInstancia(); Well, but if I call to db::getInstancia() another time, I obtain another new object :-( The code of the db class is the next (it is a Singleton Pattern, but it doesnt work) class db{ var $_miInstancia; function db (){ // funcion que se conecta con la BBDD static $miInstancia; $this-_miInstancia=$miInstancia; $result = @mysql_pconnect(inforalv, discoteca, password); if (!$result) return false; if ([EMAIL PROTECTED](discoteca)) return false; } function getInstancia(){ if (!isset($this)) $_miInstancia=new db(); return $_miInstancia; } } I think that the problem is that the var _miInstance is not static and I dont know how to do it. Could you please tell me if there is anything wrong? Thanks. Alvaro -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Evaluate PHP var in stored sql statement?
Thanks for your help Maxim. I've got quite a bit to learn. PHP is far more challenging than Cold Fusion. --Noah - Original Message - From: Maxim Maletsky [EMAIL PROTECTED] To: Noah [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, January 24, 2003 11:02 AM Subject: Re: [PHP] Evaluate PHP var in stored sql statement? eval takes the string and executes PHP in that string. So, eval(\$myrow[2] = \$myrow[2]\;); is equivalent to: $myrow[2] = $myrow[2]; I'd reccomend you using single quotes and then escape only backslashes and single quotes within a string -- Maxim Maletsky [EMAIL PROTECTED] Noah [EMAIL PROTECTED] wrote... : Don't quite understand why this works, but it does: /* Escape quotes in sql_query so our header_id gets evaluated */ eval(\$myrow[2] = \$myrow[2]\;); What's the deal with the leading backslash in ' eval(\$myrow[2] '? Does eval() tell php to evaluate the string as php code; i.e. text without quotes? Thanks for the help... --Noah - Original Message - From: Maxim Maletsky [EMAIL PROTECTED] To: CF High [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, January 24, 2003 9:59 AM Subject: Re: [PHP] Evaluate PHP var in stored sql statement? use eval() www.php.net/eval -- Maxim Maletsky [EMAIL PROTECTED] CF High [EMAIL PROTECTED] wrote... : Hey all. I need to find out how to get PHP to evaluate a PHP variable stored in our MySql database. Currently the variable is being read as a string; i.e. select * from table where column = $myrow[0] -- instead of evaluating $myrow[0] as a variable. The SQL statement is retrieved in the first call to dbConnect (see code below) dbConnect(SELECT header_id, header, sql_query FROM cat_headers WHERE section_id = $_REQUEST[section_id] order by header); $set = $result; /* Give initial result set a unique name */ while ($myrow = mysql_fetch_row($set)) { echo(Display the header title here); dbConnect($myrow[2]); /* $myrow[2] is the sql_query gotten from the first dbConnect() call */ $set1 = $result;/* Give next result set a unique name */ while ($myrow = mysql_fetch_row($set1)) { echo(Display category rows here); } } -- Any leads/suggestions much appreciated.. --Noah -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Evaluate PHP var in stored sql statement?
no, much less instead --- Maxim Maletsky [EMAIL PROTECTED] On Sat, 25 Jan 2003 09:18:47 -0800 Noah [EMAIL PROTECTED] wrote: Thanks for your help Maxim. I've got quite a bit to learn. PHP is far more challenging than Cold Fusion. --Noah - Original Message - From: Maxim Maletsky [EMAIL PROTECTED] To: Noah [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, January 24, 2003 11:02 AM Subject: Re: [PHP] Evaluate PHP var in stored sql statement? eval takes the string and executes PHP in that string. So, eval(\$myrow[2] = \$myrow[2]\;); is equivalent to: $myrow[2] = $myrow[2]; I'd reccomend you using single quotes and then escape only backslashes and single quotes within a string -- Maxim Maletsky [EMAIL PROTECTED] Noah [EMAIL PROTECTED] wrote... : Don't quite understand why this works, but it does: /* Escape quotes in sql_query so our header_id gets evaluated */ eval(\$myrow[2] = \$myrow[2]\;); What's the deal with the leading backslash in ' eval(\$myrow[2] '? Does eval() tell php to evaluate the string as php code; i.e. text without quotes? Thanks for the help... --Noah - Original Message - From: Maxim Maletsky [EMAIL PROTECTED] To: CF High [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, January 24, 2003 9:59 AM Subject: Re: [PHP] Evaluate PHP var in stored sql statement? use eval() www.php.net/eval -- Maxim Maletsky [EMAIL PROTECTED] CF High [EMAIL PROTECTED] wrote... : Hey all. I need to find out how to get PHP to evaluate a PHP variable stored in our MySql database. Currently the variable is being read as a string; i.e. select * from table where column = $myrow[0] -- instead of evaluating $myrow[0] as a variable. The SQL statement is retrieved in the first call to dbConnect (see code below) dbConnect(SELECT header_id, header, sql_query FROM cat_headers WHERE section_id = $_REQUEST[section_id] order by header); $set = $result; /* Give initial result set a unique name */ while ($myrow = mysql_fetch_row($set)) { echo(Display the header title here); dbConnect($myrow[2]); /* $myrow[2] is the sql_query gotten from the first dbConnect() call */ $set1 = $result;/* Give next result set a unique name */ while ($myrow = mysql_fetch_row($set1)) { echo(Display category rows here); } } -- Any leads/suggestions much appreciated.. --Noah -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Evaluate PHP var in stored sql statement?
Hm.. Guess I'll find out as I go deeper into PHP --Noah - Original Message - From: Maxim Maletsky [EMAIL PROTECTED] To: Noah [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Saturday, January 25, 2003 9:47 AM Subject: Re: [PHP] Evaluate PHP var in stored sql statement? no, much less instead --- Maxim Maletsky [EMAIL PROTECTED] On Sat, 25 Jan 2003 09:18:47 -0800 Noah [EMAIL PROTECTED] wrote: Thanks for your help Maxim. I've got quite a bit to learn. PHP is far more challenging than Cold Fusion. --Noah - Original Message - From: Maxim Maletsky [EMAIL PROTECTED] To: Noah [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, January 24, 2003 11:02 AM Subject: Re: [PHP] Evaluate PHP var in stored sql statement? eval takes the string and executes PHP in that string. So, eval(\$myrow[2] = \$myrow[2]\;); is equivalent to: $myrow[2] = $myrow[2]; I'd reccomend you using single quotes and then escape only backslashes and single quotes within a string -- Maxim Maletsky [EMAIL PROTECTED] Noah [EMAIL PROTECTED] wrote... : Don't quite understand why this works, but it does: /* Escape quotes in sql_query so our header_id gets evaluated */ eval(\$myrow[2] = \$myrow[2]\;); What's the deal with the leading backslash in ' eval(\$myrow[2] '? Does eval() tell php to evaluate the string as php code; i.e. text without quotes? Thanks for the help... --Noah - Original Message - From: Maxim Maletsky [EMAIL PROTECTED] To: CF High [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, January 24, 2003 9:59 AM Subject: Re: [PHP] Evaluate PHP var in stored sql statement? use eval() www.php.net/eval -- Maxim Maletsky [EMAIL PROTECTED] CF High [EMAIL PROTECTED] wrote... : Hey all. I need to find out how to get PHP to evaluate a PHP variable stored in our MySql database. Currently the variable is being read as a string; i.e. select * from table where column = $myrow[0] -- instead of evaluating $myrow[0] as a variable. The SQL statement is retrieved in the first call to dbConnect (see code below) dbConnect(SELECT header_id, header, sql_query FROM cat_headers WHERE section_id = $_REQUEST[section_id] order by header); $set = $result; /* Give initial result set a unique name */ while ($myrow = mysql_fetch_row($set)) { echo(Display the header title here); dbConnect($myrow[2]); /* $myrow[2] is the sql_query gotten from the first dbConnect() call */ $set1 = $result;/* Give next result set a unique name */ while ($myrow = mysql_fetch_row($set1)) { echo(Display category rows here); } } -- Any leads/suggestions much appreciated.. --Noah -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Evaluate PHP var in stored sql statement?
Hey all. I need to find out how to get PHP to evaluate a PHP variable stored in our MySql database. Currently the variable is being read as a string; i.e. select * from table where column = $myrow[0] -- instead of evaluating $myrow[0] as a variable. The SQL statement is retrieved in the first call to dbConnect (see code below) dbConnect(SELECT header_id, header, sql_query FROM cat_headers WHERE section_id = $_REQUEST[section_id] order by header); $set = $result; /* Give initial result set a unique name */ while ($myrow = mysql_fetch_row($set)) { echo(Display the header title here); dbConnect($myrow[2]); /* $myrow[2] is the sql_query gotten from the first dbConnect() call */ $set1 = $result;/* Give next result set a unique name */ while ($myrow = mysql_fetch_row($set1)) { echo(Display category rows here); } } -- Any leads/suggestions much appreciated.. --Noah -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Evaluate PHP var in stored sql statement?
use eval() www.php.net/eval -- Maxim Maletsky [EMAIL PROTECTED] CF High [EMAIL PROTECTED] wrote... : Hey all. I need to find out how to get PHP to evaluate a PHP variable stored in our MySql database. Currently the variable is being read as a string; i.e. select * from table where column = $myrow[0] -- instead of evaluating $myrow[0] as a variable. The SQL statement is retrieved in the first call to dbConnect (see code below) dbConnect(SELECT header_id, header, sql_query FROM cat_headers WHERE section_id = $_REQUEST[section_id] order by header); $set = $result; /* Give initial result set a unique name */ while ($myrow = mysql_fetch_row($set)) { echo(Display the header title here); dbConnect($myrow[2]); /* $myrow[2] is the sql_query gotten from the first dbConnect() call */ $set1 = $result;/* Give next result set a unique name */ while ($myrow = mysql_fetch_row($set1)) { echo(Display category rows here); } } -- Any leads/suggestions much appreciated.. --Noah -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Evaluate PHP var in stored sql statement?
Don't quite understand why this works, but it does: /* Escape quotes in sql_query so our header_id gets evaluated */ eval(\$myrow[2] = \$myrow[2]\;); What's the deal with the leading backslash in ' eval(\$myrow[2] '? Does eval() tell php to evaluate the string as php code; i.e. text without quotes? Thanks for the help... --Noah - Original Message - From: Maxim Maletsky [EMAIL PROTECTED] To: CF High [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, January 24, 2003 9:59 AM Subject: Re: [PHP] Evaluate PHP var in stored sql statement? use eval() www.php.net/eval -- Maxim Maletsky [EMAIL PROTECTED] CF High [EMAIL PROTECTED] wrote... : Hey all. I need to find out how to get PHP to evaluate a PHP variable stored in our MySql database. Currently the variable is being read as a string; i.e. select * from table where column = $myrow[0] -- instead of evaluating $myrow[0] as a variable. The SQL statement is retrieved in the first call to dbConnect (see code below) dbConnect(SELECT header_id, header, sql_query FROM cat_headers WHERE section_id = $_REQUEST[section_id] order by header); $set = $result; /* Give initial result set a unique name */ while ($myrow = mysql_fetch_row($set)) { echo(Display the header title here); dbConnect($myrow[2]); /* $myrow[2] is the sql_query gotten from the first dbConnect() call */ $set1 = $result;/* Give next result set a unique name */ while ($myrow = mysql_fetch_row($set1)) { echo(Display category rows here); } } -- Any leads/suggestions much appreciated.. --Noah -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Evaluate PHP var in stored sql statement?
eval takes the string and executes PHP in that string. So, eval(\$myrow[2] = \$myrow[2]\;); is equivalent to: $myrow[2] = $myrow[2]; I'd reccomend you using single quotes and then escape only backslashes and single quotes within a string -- Maxim Maletsky [EMAIL PROTECTED] Noah [EMAIL PROTECTED] wrote... : Don't quite understand why this works, but it does: /* Escape quotes in sql_query so our header_id gets evaluated */ eval(\$myrow[2] = \$myrow[2]\;); What's the deal with the leading backslash in ' eval(\$myrow[2] '? Does eval() tell php to evaluate the string as php code; i.e. text without quotes? Thanks for the help... --Noah - Original Message - From: Maxim Maletsky [EMAIL PROTECTED] To: CF High [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, January 24, 2003 9:59 AM Subject: Re: [PHP] Evaluate PHP var in stored sql statement? use eval() www.php.net/eval -- Maxim Maletsky [EMAIL PROTECTED] CF High [EMAIL PROTECTED] wrote... : Hey all. I need to find out how to get PHP to evaluate a PHP variable stored in our MySql database. Currently the variable is being read as a string; i.e. select * from table where column = $myrow[0] -- instead of evaluating $myrow[0] as a variable. The SQL statement is retrieved in the first call to dbConnect (see code below) dbConnect(SELECT header_id, header, sql_query FROM cat_headers WHERE section_id = $_REQUEST[section_id] order by header); $set = $result; /* Give initial result set a unique name */ while ($myrow = mysql_fetch_row($set)) { echo(Display the header title here); dbConnect($myrow[2]); /* $myrow[2] is the sql_query gotten from the first dbConnect() call */ $set1 = $result;/* Give next result set a unique name */ while ($myrow = mysql_fetch_row($set1)) { echo(Display category rows here); } } -- Any leads/suggestions much appreciated.. --Noah -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Evaluate PHP var in stored sql statement?
From: Noah [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, January 24, 2003 4:39 PM Subject: Re: [PHP] Evaluate PHP var in stored sql statement? eval(\$myrow[2] = \$myrow[2]\;); What's the deal with the leading backslash in ' eval(\$myrow[2] '? It's escaping the $ so you keep the literal on the left hand side of the expression. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Var question
I am building a form that posts to itself. I have the following to detect the submit button being clicked: If($_POST[go] == add link) I am getting a warning that says 'go' is undefined. How do I define this? Thanks, Clint -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Var question
You can just check for if(isset($_POST['go'])) You don't really care what the value is since it's just a button. ---John Holmes... - Original Message - From: Clint Tredway [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, October 24, 2002 9:33 AM Subject: [PHP] Var question I am building a form that posts to itself. I have the following to detect the submit button being clicked: If($_POST[go] == add link) I am getting a warning that says 'go' is undefined. How do I define this? Thanks, Clint -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Var question
is go a variable that is passed via post? I guess yes but you get this error without submitting yet. There are three solutions: 1. Change your error reporting level to 55: error_reporting(55). This will stop warning your undefined variables. 2. Prefix the variable with an at-mark: @$_POST['go']. This is a quickie. 3. Most elegant way: add one more check: if(isset($_POST['go']) and $_POST['go'] == 'add link'). -- Maxim Maletsky [EMAIL PROTECTED] www.PHPBeginner.com // PHP for Beginners www.maxim.cx // my Home // my Wish List: ( Get me something! ) http://www.amazon.com/exec/obidos/registry/2IXE7SMI5EDI3 Clint Tredway [EMAIL PROTECTED] wrote... : I am building a form that posts to itself. I have the following to detect the submit button being clicked: If($_POST[go] == add link) I am getting a warning that says 'go' is undefined. How do I define this? Thanks, Clint -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Var question
Thanks guys.. I am moving away from ColdFusion to PHP and so I still forget about the isset() function. -Original Message- From: 1LT John W. Holmes [mailto:holmes072000;charter.net] Sent: Thursday, October 24, 2002 8:53 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [PHP] Var question You can just check for if(isset($_POST['go'])) You don't really care what the value is since it's just a button. ---John Holmes... - Original Message - From: Clint Tredway [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, October 24, 2002 9:33 AM Subject: [PHP] Var question I am building a form that posts to itself. I have the following to detect the submit button being clicked: If($_POST[go] == add link) I am getting a warning that says 'go' is undefined. How do I define this? Thanks, Clint -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] var-vars question
Hi folks, Linux, PHP3 I have the following problem: I have an object, which creates a form, wherein there are selects, which names accord to values in the database. But I didn´t get it to have a variable var, I´m sure it´s just a small thing, but I cannot see it Any suggestions ? TIA Oliver echo 'form name=g94 action='.$to_go.' method=get'; // Already tried post, no difference echo 'table border=1 width=100% cellpadding=1 cellspacing=1'; while($da=$MKA - getDbAns()) // This gives back an array named $da while there are answers { $xwert=$da[1]; // $da[1] contains abc the var $xwert will be abc // now I´d like to see the value of $abc but there´s nothing in echo 'trtd '.$$xwert.'/tdtd'; // set the new select named abc echo 'select name='.$da[1].''; // forget the rest, just for understanding what while does for($i=0; $i 11 ; $i++) { if(isset($$da[1])) // just for testing { echo option selected .$i./option; } else { echo option.$i./option; } } // end for echo '/select'; echo '/td'; echo 'td'.$da[1].'/td'; echo 'td'.$da[2].'/td'; echo 'td align=right'.$da[3].' EUR/td'; echo '/tr'; } // end while echo '/table'; echo 'brbrinput type=submit value=CalC !'; echo /form; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] $var , '$var'
hi. what is the difference between $var and '$var' ?/ thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] $var , '$var'
In what context? print $var; // prints the value of $var print $var; // prints the value of $var print '$var'; // prints $var /* Chris Lambert, CTO - [EMAIL PROTECTED] WhiteCrown Networks - More Than White Hats Web Application Security - www.whitecrown.net */ - Original Message - From: nafiseh saberi [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, August 19, 2001 2:33 AM Subject: [PHP] $var , '$var' | | hi. | what is the difference between $var and '$var' ?/ | thanks. | | -- | PHP General Mailing List (http://www.php.net/) | To unsubscribe, e-mail: [EMAIL PROTECTED] | For additional commands, e-mail: [EMAIL PROTECTED] | To contact the list administrators, e-mail: [EMAIL PROTECTED] | | | -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] $var , '$var'
nothing, execpt, think there would be about 0.1 time difference... :D I use $var = $blah.bleh'.$foo because syntax highlighting looks better :D - James ReDucTor Mitchelll - Original Message - From: nafiseh saberi [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, August 19, 2001 4:33 PM Subject: [PHP] $var , '$var' hi. what is the difference between $var and '$var' ?/ thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: javascript var on a php var...
Romeo Manzur wrote: hi, I want to know how could I save a javascript variable on a php variable??? Thanks... It depends how the user will get to the php page: 1. Form If the user is about to submit a form and you want some Javascript variable from your page to end up as a php variable after the form is submitted then: Create a hidden form variable e.g. INPUT TYPE=HIDDEN NAME=myvariable Set this formvariable to your Javascript variable in the Javascript e.g. document.form.myvariable.value = myjavascriptvariable; After submission $myvariable will be a php variable in the target page with the value you gave it. 2. Link If you want to set a php variable in a page which the user will get to by a link, then you need to add a GET query to the link e.g. your Javascript will have something like this: document.myhref.location = document.myhref.location+?myvariable=+myjavascriptvariable; i.e. the link becomes myoriginallink?myvariable=... php will automatically become up the value you specify and set $myvariable to that value. George -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] javascript var on a php var...
hi, I want to know how could I save a javascript variable on a php variable??? Thanks... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] javascript var on a php var...
window.location = 'http://url?yourVar=' + yourVar; -Original Message- From: Romeo Manzur [mailto:[EMAIL PROTECTED]] Sent: 5 iulie 2001 07:56 To: [EMAIL PROTECTED] Subject: [PHP] javascript var on a php var... hi, I want to know how could I save a javascript variable on a php variable??? Thanks... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] var question
Add an "=" on the end of your url. Viola. -- Plutarck Should be working on something... ...but forgot what it was. ""Jeroen Geusebroek"" [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi Guys, I have a question about the way PHP handles var/strings. Let's say i have this URL: http://foo.bar.com/?login. And in my script i have this code: if($login) { echo "blab"; } or if(isset($login)) { echo "blab"; } It always returns FALSE. I think that is because the string is empty. Shouldn't PHP, even if a var is empty, put it in his var-list? Is there another way to do what i want? Thanks, Jeroen Geusebroek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] var question
Actually, I meant the instrument LOL ;) So as I would pronounce it IRL, "vee-O-luh". I use to spell it wrong, and was notified of it, but I've decided to just use viola on purpose. I actually litterally pronounce it "viola". Some would argue that the majority of people think I just do it to annoy them. I just like the way "viola" sounds :) Plutarck Should be working on something... ...but forgot what it was. - Original Message - From: "Brian Clark" [EMAIL PROTECTED] To: "Plutarck" [EMAIL PROTECTED] Sent: Monday, 16. April 2001 16:54 Subject: Re: [PHP] var question Hi Plutarck, @ 5:43:35 PM on 4/16/2001, Plutarck wrote: Add an "=" on the end of your url. Viola. Heheh, I think you meant Voila which is like "there you are" in French? Viola is either a) Any of the numerous plants of the genus Viola, or b) Slightly larger than a violin, tuned a fifth lower. ;-) -Brian _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] var question
Note: Yes, I meant string instrument. Any references to YoYo Ma will be dealt with swiftly and severly. -- Plutarck Should be working on something... ...but forgot what it was. ""Plutarck"" [EMAIL PROTECTED] wrote in message 9bfp5e$169$[EMAIL PROTECTED]">news:9bfp5e$169$[EMAIL PROTECTED]... Add an "=" on the end of your url. Viola. -- Plutarck Should be working on something... ...but forgot what it was. ""Jeroen Geusebroek"" [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi Guys, I have a question about the way PHP handles var/strings. Let's say i have this URL: http://foo.bar.com/?login. And in my script i have this code: if($login) { echo "blab"; } or if(isset($login)) { echo "blab"; } It always returns FALSE. I think that is because the string is empty. Shouldn't PHP, even if a var is empty, put it in his var-list? Is there another way to do what i want? Thanks, Jeroen Geusebroek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] var question
You can also look at environment variable $QUERY_STRING. For example, if ($HTTP_SERVER_VARS['QUERY_STRING'] == 'login') { ...do log in procedure If register_globals is on, all you need is if ($QUERY_STRING == 'login') If you might be passing other parameters in the URL, and want to ignore case, you could use something like: if (eregi('login', $QUERY_STRING)) { This would match www.blah.com?login www.blah.com?LogIn www.blah.com?loginuser=herman_hollerith but it would also match www.blah.com?sloginthemud www.blah.com?login0 So, a little regular expression twiddling might be in order. For more info, see: http://www.php.net/manual/en/language.variables.predefined.php http://www.php.net/manual/en/ref.regex.php http://www.php.net/manual/en/ref.pcre.php -steve At 02:43 PM 4/16/01 , Plutarck wrote: Add an "=" on the end of your url. Viola. -- Plutarck Should be working on something... ...but forgot what it was. ""Jeroen Geusebroek"" [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi Guys, I have a question about the way PHP handles var/strings. Let's say i have this URL: http://foo.bar.com/?login. And in my script i have this code: if($login) { echo "blab"; } or if(isset($login)) { echo "blab"; } It always returns FALSE. I think that is because the string is empty. Shouldn't PHP, even if a var is empty, put it in his var-list? Is there another way to do what i want? Thanks, Jeroen Geusebroek ++ | Steve Edberg University of California, Davis | | [EMAIL PROTECTED] (530)754-9127 | | http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ | +-- Gort, Klaatu barada nikto! --+ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] VAR and variables
At 10:50 AM + 1/29/01, Tim Ward wrote: -Original Message- From: Steve Edberg [mailto:[EMAIL PROTECTED]] Sent: 25 January 2001 22:02 To: Matt; [EMAIL PROTECTED] Subject: Re: [PHP] VAR and variables At 3:00 PM -0600 1/25/01, Matt wrote: I have a question that may seem kind of silly, but I'm curious... When using PHP why would one use "var" to define a variable as opposed to just regularly creating it? Because that's the way it is ;). The var is part of the syntax of a class definition; it isn't used anywhere else. I don't know the actual deep reason for having it, as far as the parser is concerned, but it does make it clear - at least to me - what the class variables are. class definitions are the fundamental building blocks of object orientated programming. They define an object type which your object is an example of. The defined variables should be regarded as properties of the class rather than variables in the usual sense. If you're going to be strict about it you should not even refer to them directly outside the class definition but use methods to access and change them. Yes --- I was referring to the use of the keyword 'var' here (as opposed to nothing, or some _other_ construct), which I think was the original question. You can also initialize the variable here, too: var $a = 5; not any more you can't ... use the constructor According to the docs, you can still use a _constant_ initializer in PHP4 (I use them in 4.0.4), just not a variable one. From http://www.php.net/manual/en/language.oop.php: Note: In PHP 4, only constant initializers for var variables are allowed. Use constructors for non-constant initializers. Of course, this might not be the official OOP usage, but this is PHP's way (I'd call it Pseudo-OOP, but the acronym for that isn't all that pleasant ;) - steve -- +--- "They've got a cherry pie there, that'll kill ya" --+ | Steve Edberg University of California, Davis | | [EMAIL PROTECTED] Computer Consultant | | http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ | +-- FBI Special Agent Dale Cooper ---+ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]