Re: [PHP] Variables with - in their name
On Sat, Nov 17, 2012 at 11:09 PM, Ron Piggott ron.pigg...@actsministries.org wrote: I have made the following variable in a form: (I am referring the select ) ?php $row['promo_code_prefix'] = 42; $row['promo_code_suffix'] = 2; echo select name=\distributor- . $row['promo_code_prefix'] . - . $row['promo_code_suffix'] . \ style=\text-align: center;\\r\n; ? It could be wrote: ?php echo $distributor-42-2; ? Only PHP is treating the hyphen as a minus sign --- which in turn is causing a syntax error. How do I retrieve the value of this variable and over come the “minus” sign that is really a hyphen? php ${distributor-42-2} = 5; php echo ${distributor-42-2}; 5 I think that's it. -nathan
Re: [PHP] Variables with - in their name
On Sun, 2012-11-18 at 01:37 -0700, Nathan Nobbe wrote: On Sat, Nov 17, 2012 at 11:09 PM, Ron Piggott ron.pigg...@actsministries.org wrote: I have made the following variable in a form: (I am referring the select ) ?php $row['promo_code_prefix'] = 42; $row['promo_code_suffix'] = 2; echo select name=\distributor- . $row['promo_code_prefix'] . - . $row['promo_code_suffix'] . \ style=\text-align: center;\\r\n; ? It could be wrote: ?php echo $distributor-42-2; ? Only PHP is treating the hyphen as a minus sign --- which in turn is causing a syntax error. How do I retrieve the value of this variable and over come the “minus” sign that is really a hyphen? php ${distributor-42-2} = 5; php echo ${distributor-42-2}; 5 I think that's it. -nathan I'd just try and avoid the hyphens in the variable names in the first place if you can. Can you guarantee that everyone working on this system will know when to encapsulate the variables in braces? Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Variables with - in their name
On Sun, Nov 18, 2012 at 5:12 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Sun, 2012-11-18 at 01:37 -0700, Nathan Nobbe wrote: On Sat, Nov 17, 2012 at 11:09 PM, Ron Piggott ron.pigg...@actsministries.org wrote: I have made the following variable in a form: (I am referring the select ) ?php $row['promo_code_prefix'] = 42; $row['promo_code_suffix'] = 2; echo select name=\distributor- . $row['promo_code_prefix'] . - . $row['promo_code_suffix'] . \ style=\text-align: center;\\r\n; ? It could be wrote: ?php echo $distributor-42-2; ? Only PHP is treating the hyphen as a minus sign --- which in turn is causing a syntax error. How do I retrieve the value of this variable and over come the “minus” sign that is really a hyphen? php ${distributor-42-2} = 5; php echo ${distributor-42-2}; 5 I think that's it. -nathan I'd just try and avoid the hyphens in the variable names in the first place if you can. Can you guarantee that everyone working on this system will know when to encapsulate the variables in braces? Thanks, Ash http://www.ashleysheridan.co.uk Agreed. From http://www.php.net/manual/en/language.variables.basics.php : Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. The ${var} circumvents this (somewhat), but in the case above, it would be better to avoid the dashes and use underscores. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables via url
On Sun, 2012-05-13 at 01:57 +1000, Tom Rogers wrote: Hello Ashley, Saturday, May 12, 2012, 9:15:23 AM, you wrote: Can someone point me at examples or directions on how I can pass a variable via a URL in the following way: http://server.domain.com//script///variable/ I will only be passing one single /variable/. And I want the /script/ to use that. I don't want to see what the script is, for example I don't want it to say 'script.php' or 'script.html' ... Is this possible through PHP only, or do I have to write a rewrite directive in Apache to accomplish this? You can add this to apache conf: FilesMatch ^phpscript$ ForceType application/x-httpd-php /FilesMatch Then make a file called phpscript without extension and drop it in the web root. ?php $info = explode('/', $_SERVER['PATH_INFO']); Then your url would look like: http://server.domain.com/phpscript/variable1/variable2 -- Best regards, Tom As this method requires an Apache restart, I don't see what advantage you have over using an .htaccess file? -- Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Variables via url
On Sat, May 12, 2012 at 12:25 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: As this method requires an Apache restart, I don't see what advantage you have over using an .htaccess file? Performance: http://httpd.apache.org/docs/current/howto/htaccess.html You should avoid using .htaccess files completely if you have access to httpd main server config file. Using .htaccess files slows down your Apache http server. Any directive that you can include in a .htaccess file is better set in a Directory block, as it will have the same effect with better performance. ...putting this configuration in your server configuration file will result in less of a performance hit, as the configuration is loaded once when httpd starts, rather than every time a file is requested. Adam -- Nephtali: A simple, flexible, fast, and security-focused PHP framework http://nephtaliproject.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables are empty only in fwrite
On Thu, 15 Mar 2012 11:30:20 -0400, Larry lrr...@gmail.com sent: Hello, when I pass a variable whose value originally came from $_GET or $_REQUEST to fwrite, fwrite behaves as if it was passed an empty string. Note that the file is successfully opened and written to by the script, but the variable that originally came from $_GET does not have its value interpolated in the text file, even though it does get interpolated in the echo(). Code ? $meh = $_GET[q]; $writeline = : . $meh . : . strlen($meh) . PHP_EOL; echo ( $writeline ); $fp = fopen(/tmp/wtf.log,w+); fwrite($fp, $writeline ); fclose($fp); var_dump($writeline); ? Request /search.php?q=meh123 Response --- ( expected ) :meh123:6 string(10) :meh123:6 Contents of /tmp/wtf.log ::0 Some sort of security setting in php.ini maybe? If so, I'm not only curious in how to fix it but also how this actually happens. Does the value assigned to $writeline not get immediately evaluated? I mean, does $writeline know it contains variables from elsewhere, instead of just containing a string of chars? Thanks! I'm not at all sure what's going on with your code and/or site. Please look at: http://mouseha.us/demos/larryproblem.txt To see the php code, and: http://mouseha.us/demos/larryproblem.php?q=meh123 to see the demo. -- Tamara Temple aka tamouse__ May you never see a stranger's face in the mirror -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables are empty only in fwrite
On Thu, Mar 15, 2012 at 11:30, Larry lrr...@gmail.com wrote: Hello, when I pass a variable whose value originally came from $_GET or $_REQUEST to fwrite, fwrite behaves as if it was passed an empty string. Note that the file is successfully opened and written to by the script, but the variable that originally came from $_GET does not have its value interpolated in the text file, even though it does get interpolated in the echo(). Code ? $meh = $_GET[q]; $writeline = : . $meh . : . strlen($meh) . PHP_EOL; echo ( $writeline ); $fp = fopen(/tmp/wtf.log,w+); fwrite($fp, $writeline ); fclose($fp); var_dump($writeline); ? Are you sure it's not a permissions-based issue, perhaps when writing as the normal user, then the user as which the web server runs, et cetera? What happens if you completely remove /tmp/wtf.log and re-run your script with the appended query string? -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables are empty only in fwrite
On Thu, Mar 15, 2012 at 11:53 AM, Daniel P. Brown daniel.br...@parasane.net wrote: On Thu, Mar 15, 2012 at 11:30, Larry lrr...@gmail.com wrote: Hello, when I pass a variable whose value originally came from $_GET or $_REQUEST to fwrite, fwrite behaves as if it was passed an empty string. Note that the file is successfully opened and written to by the script, but the variable that originally came from $_GET does not have its value interpolated in the text file, even though it does get interpolated in the echo(). Code ? $meh = $_GET[q]; $writeline = : . $meh . : . strlen($meh) . PHP_EOL; echo ( $writeline ); $fp = fopen(/tmp/wtf.log,w+); fwrite($fp, $writeline ); fclose($fp); var_dump($writeline); ? Are you sure it's not a permissions-based issue, perhaps when writing as the normal user, then the user as which the web server runs, et cetera? What happens if you completely remove /tmp/wtf.log and re-run your script with the appended query string? I have removed the wtf.log file between runs, just did it once more. Same thing happens. A new file is created, and the contents are ::0 So I'm sure its not a permissions issue ( However I'm also sure that this shouldn't be happening so... ) Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables are empty only in fwrite
On Thu, Mar 15, 2012 at 4:59 PM, Larry lrr...@gmail.com wrote: On Thu, Mar 15, 2012 at 11:53 AM, Daniel P. Brown daniel.br...@parasane.net wrote: On Thu, Mar 15, 2012 at 11:30, Larry lrr...@gmail.com wrote: Hello, when I pass a variable whose value originally came from $_GET or $_REQUEST to fwrite, fwrite behaves as if it was passed an empty string. Note that the file is successfully opened and written to by the script, but the variable that originally came from $_GET does not have its value interpolated in the text file, even though it does get interpolated in the echo(). Code ? $meh = $_GET[q]; $writeline = : . $meh . : . strlen($meh) . PHP_EOL; echo ( $writeline ); $fp = fopen(/tmp/wtf.log,w+); fwrite($fp, $writeline ); fclose($fp); var_dump($writeline); ? Are you sure it's not a permissions-based issue, perhaps when writing as the normal user, then the user as which the web server runs, et cetera? What happens if you completely remove /tmp/wtf.log and re-run your script with the appended query string? I have removed the wtf.log file between runs, just did it once more. Same thing happens. A new file is created, and the contents are ::0 So I'm sure its not a permissions issue ( However I'm also sure that this shouldn't be happening so... ) Thanks. The code is working fine here, of course, it should. Is it really because of the $_GET?, have you tried setting $q = meh123;? Also, try using file_put_contents('/tmp/wtf.log', $writeline); instead. - Matijn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables are empty only in fwrite
On Thu, Mar 15, 2012 at 12:21 PM, Matijn Woudt tijn...@gmail.com wrote: On Thu, Mar 15, 2012 at 4:59 PM, Larry lrr...@gmail.com wrote: On Thu, Mar 15, 2012 at 11:53 AM, Daniel P. Brown daniel.br...@parasane.net wrote: On Thu, Mar 15, 2012 at 11:30, Larry lrr...@gmail.com wrote: Hello, when I pass a variable whose value originally came from $_GET or $_REQUEST to fwrite, fwrite behaves as if it was passed an empty string. Note that the file is successfully opened and written to by the script, but the variable that originally came from $_GET does not have its value interpolated in the text file, even though it does get interpolated in the echo(). Code ? $meh = $_GET[q]; $writeline = : . $meh . : . strlen($meh) . PHP_EOL; echo ( $writeline ); $fp = fopen(/tmp/wtf.log,w+); fwrite($fp, $writeline ); fclose($fp); var_dump($writeline); ? Are you sure it's not a permissions-based issue, perhaps when writing as the normal user, then the user as which the web server runs, et cetera? What happens if you completely remove /tmp/wtf.log and re-run your script with the appended query string? I have removed the wtf.log file between runs, just did it once more. Same thing happens. A new file is created, and the contents are ::0 So I'm sure its not a permissions issue ( However I'm also sure that this shouldn't be happening so... ) Thanks. The code is working fine here, of course, it should. Is it really because of the $_GET?, have you tried setting $q = meh123;? Also, try using file_put_contents('/tmp/wtf.log', $writeline); instead. - Matijn Yes I have tried to set a variable explicitly with a string, and that variable does end up interpolated into the file. I just tried using file_put_contents with the same result. Here is a modified version, showing another variable that does work, and file_put_contents(): ? $meh = $_GET[q]; $good = Yay I go in the File . PHP_EOL; $writeline = : . $meh . : . strlen($meh) . : . $good; echo ( $writeline ); file_put_contents(/tmp/wtf.log, $writeline ); var_dump($writeline); ? Here the response/stdout: :meh123:6:Yay I go in the File string(31) :meh123:6:Yay I go in the File But the file is the same: root@prime:/tmp# rm wtf.log root@prime:/tmp# ls wtf.log ls: cannot access wtf.log: No such file or directory [ I make the request ] root@prime:/tmp# cat wtf.log ::0:Yay I go in the File -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables are empty only in fwrite
On Thu, Mar 15, 2012 at 7:51 PM, Larry lrr...@gmail.com wrote: On Thu, Mar 15, 2012 at 12:21 PM, Matijn Woudt tijn...@gmail.com wrote: On Thu, Mar 15, 2012 at 4:59 PM, Larry lrr...@gmail.com wrote: On Thu, Mar 15, 2012 at 11:53 AM, Daniel P. Brown daniel.br...@parasane.net wrote: On Thu, Mar 15, 2012 at 11:30, Larry lrr...@gmail.com wrote: Hello, when I pass a variable whose value originally came from $_GET or $_REQUEST to fwrite, fwrite behaves as if it was passed an empty string. Note that the file is successfully opened and written to by the script, but the variable that originally came from $_GET does not have its value interpolated in the text file, even though it does get interpolated in the echo(). Code ? $meh = $_GET[q]; $writeline = : . $meh . : . strlen($meh) . PHP_EOL; echo ( $writeline ); $fp = fopen(/tmp/wtf.log,w+); fwrite($fp, $writeline ); fclose($fp); var_dump($writeline); ? Are you sure it's not a permissions-based issue, perhaps when writing as the normal user, then the user as which the web server runs, et cetera? What happens if you completely remove /tmp/wtf.log and re-run your script with the appended query string? I have removed the wtf.log file between runs, just did it once more. Same thing happens. A new file is created, and the contents are ::0 So I'm sure its not a permissions issue ( However I'm also sure that this shouldn't be happening so... ) Thanks. The code is working fine here, of course, it should. Is it really because of the $_GET?, have you tried setting $q = meh123;? Also, try using file_put_contents('/tmp/wtf.log', $writeline); instead. - Matijn Yes I have tried to set a variable explicitly with a string, and that variable does end up interpolated into the file. I just tried using file_put_contents with the same result. Here is a modified version, showing another variable that does work, and file_put_contents(): ? $meh = $_GET[q]; $good = Yay I go in the File . PHP_EOL; $writeline = : . $meh . : . strlen($meh) . : . $good; echo ( $writeline ); file_put_contents(/tmp/wtf.log, $writeline ); var_dump($writeline); ? Here the response/stdout: :meh123:6:Yay I go in the File string(31) :meh123:6:Yay I go in the File But the file is the same: root@prime:/tmp# rm wtf.log root@prime:/tmp# ls wtf.log ls: cannot access wtf.log: No such file or directory [ I make the request ] root@prime:/tmp# cat wtf.log ::0:Yay I go in the File Have you checked apache log files for any warnings/errors? How about writing $_GET['q'] directly? eg. file_put_contents('/tmp/wtf.log', $_GET['q']);? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables are empty only in fwrite
On Thu, Mar 15, 2012 at 2:57 PM, Matijn Woudt tijn...@gmail.com wrote: On Thu, Mar 15, 2012 at 7:51 PM, Larry lrr...@gmail.com wrote: On Thu, Mar 15, 2012 at 12:21 PM, Matijn Woudt tijn...@gmail.com wrote: On Thu, Mar 15, 2012 at 4:59 PM, Larry lrr...@gmail.com wrote: On Thu, Mar 15, 2012 at 11:53 AM, Daniel P. Brown daniel.br...@parasane.net wrote: On Thu, Mar 15, 2012 at 11:30, Larry lrr...@gmail.com wrote: Hello, when I pass a variable whose value originally came from $_GET or $_REQUEST to fwrite, fwrite behaves as if it was passed an empty string. Note that the file is successfully opened and written to by the script, but the variable that originally came from $_GET does not have its value interpolated in the text file, even though it does get interpolated in the echo(). Code ? $meh = $_GET[q]; $writeline = : . $meh . : . strlen($meh) . PHP_EOL; echo ( $writeline ); $fp = fopen(/tmp/wtf.log,w+); fwrite($fp, $writeline ); fclose($fp); var_dump($writeline); ? Are you sure it's not a permissions-based issue, perhaps when writing as the normal user, then the user as which the web server runs, et cetera? What happens if you completely remove /tmp/wtf.log and re-run your script with the appended query string? I have removed the wtf.log file between runs, just did it once more. Same thing happens. A new file is created, and the contents are ::0 So I'm sure its not a permissions issue ( However I'm also sure that this shouldn't be happening so... ) Thanks. The code is working fine here, of course, it should. Is it really because of the $_GET?, have you tried setting $q = meh123;? Also, try using file_put_contents('/tmp/wtf.log', $writeline); instead. - Matijn Yes I have tried to set a variable explicitly with a string, and that variable does end up interpolated into the file. I just tried using file_put_contents with the same result. Here is a modified version, showing another variable that does work, and file_put_contents(): ? $meh = $_GET[q]; $good = Yay I go in the File . PHP_EOL; $writeline = : . $meh . : . strlen($meh) . : . $good; echo ( $writeline ); file_put_contents(/tmp/wtf.log, $writeline ); var_dump($writeline); ? Here the response/stdout: :meh123:6:Yay I go in the File string(31) :meh123:6:Yay I go in the File But the file is the same: root@prime:/tmp# rm wtf.log root@prime:/tmp# ls wtf.log ls: cannot access wtf.log: No such file or directory [ I make the request ] root@prime:/tmp# cat wtf.log ::0:Yay I go in the File Have you checked apache log files for any warnings/errors? How about writing $_GET['q'] directly? eg. file_put_contents('/tmp/wtf.log', $_GET['q']);? Yes I tried using $_GET['q'] directly to no avail. However, you found a clue! apache error.log is giving this: PHP Notice: Undefined index: q in /var/www/test/search.php on line 2 Strange b/c I am obtaining and using that value successfully in echo()! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables are empty only in fwrite
On Thu, Mar 15, 2012 at 8:41 PM, Larry lrr...@gmail.com wrote: On Thu, Mar 15, 2012 at 2:57 PM, Matijn Woudt tijn...@gmail.com wrote: On Thu, Mar 15, 2012 at 7:51 PM, Larry lrr...@gmail.com wrote: On Thu, Mar 15, 2012 at 12:21 PM, Matijn Woudt tijn...@gmail.com wrote: On Thu, Mar 15, 2012 at 4:59 PM, Larry lrr...@gmail.com wrote: On Thu, Mar 15, 2012 at 11:53 AM, Daniel P. Brown daniel.br...@parasane.net wrote: On Thu, Mar 15, 2012 at 11:30, Larry lrr...@gmail.com wrote: Hello, when I pass a variable whose value originally came from $_GET or $_REQUEST to fwrite, fwrite behaves as if it was passed an empty string. Note that the file is successfully opened and written to by the script, but the variable that originally came from $_GET does not have its value interpolated in the text file, even though it does get interpolated in the echo(). Code ? $meh = $_GET[q]; $writeline = : . $meh . : . strlen($meh) . PHP_EOL; echo ( $writeline ); $fp = fopen(/tmp/wtf.log,w+); fwrite($fp, $writeline ); fclose($fp); var_dump($writeline); ? Are you sure it's not a permissions-based issue, perhaps when writing as the normal user, then the user as which the web server runs, et cetera? What happens if you completely remove /tmp/wtf.log and re-run your script with the appended query string? I have removed the wtf.log file between runs, just did it once more. Same thing happens. A new file is created, and the contents are ::0 So I'm sure its not a permissions issue ( However I'm also sure that this shouldn't be happening so... ) Thanks. The code is working fine here, of course, it should. Is it really because of the $_GET?, have you tried setting $q = meh123;? Also, try using file_put_contents('/tmp/wtf.log', $writeline); instead. - Matijn Yes I have tried to set a variable explicitly with a string, and that variable does end up interpolated into the file. I just tried using file_put_contents with the same result. Here is a modified version, showing another variable that does work, and file_put_contents(): ? $meh = $_GET[q]; $good = Yay I go in the File . PHP_EOL; $writeline = : . $meh . : . strlen($meh) . : . $good; echo ( $writeline ); file_put_contents(/tmp/wtf.log, $writeline ); var_dump($writeline); ? Here the response/stdout: :meh123:6:Yay I go in the File string(31) :meh123:6:Yay I go in the File But the file is the same: root@prime:/tmp# rm wtf.log root@prime:/tmp# ls wtf.log ls: cannot access wtf.log: No such file or directory [ I make the request ] root@prime:/tmp# cat wtf.log ::0:Yay I go in the File Have you checked apache log files for any warnings/errors? How about writing $_GET['q'] directly? eg. file_put_contents('/tmp/wtf.log', $_GET['q']);? Yes I tried using $_GET['q'] directly to no avail. However, you found a clue! apache error.log is giving this: PHP Notice: Undefined index: q in /var/www/test/search.php on line 2 Strange b/c I am obtaining and using that value successfully in echo()! Well.. That seems pretty buggy, I guess it's a bug in PHP. Try changing q in something else, and maybe you want to submit a bug report to PHP? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables are empty only in fwrite
On Thu, Mar 15, 2012 at 4:03 PM, Matijn Woudt tijn...@gmail.com wrote: On Thu, Mar 15, 2012 at 8:41 PM, Larry lrr...@gmail.com wrote: On Thu, Mar 15, 2012 at 2:57 PM, Matijn Woudt tijn...@gmail.com wrote: On Thu, Mar 15, 2012 at 7:51 PM, Larry lrr...@gmail.com wrote: On Thu, Mar 15, 2012 at 12:21 PM, Matijn Woudt tijn...@gmail.com wrote: On Thu, Mar 15, 2012 at 4:59 PM, Larry lrr...@gmail.com wrote: On Thu, Mar 15, 2012 at 11:53 AM, Daniel P. Brown daniel.br...@parasane.net wrote: On Thu, Mar 15, 2012 at 11:30, Larry lrr...@gmail.com wrote: Hello, when I pass a variable whose value originally came from $_GET or $_REQUEST to fwrite, fwrite behaves as if it was passed an empty string. Note that the file is successfully opened and written to by the script, but the variable that originally came from $_GET does not have its value interpolated in the text file, even though it does get interpolated in the echo(). Code ? $meh = $_GET[q]; $writeline = : . $meh . : . strlen($meh) . PHP_EOL; echo ( $writeline ); $fp = fopen(/tmp/wtf.log,w+); fwrite($fp, $writeline ); fclose($fp); var_dump($writeline); ? Are you sure it's not a permissions-based issue, perhaps when writing as the normal user, then the user as which the web server runs, et cetera? What happens if you completely remove /tmp/wtf.log and re-run your script with the appended query string? I have removed the wtf.log file between runs, just did it once more. Same thing happens. A new file is created, and the contents are ::0 So I'm sure its not a permissions issue ( However I'm also sure that this shouldn't be happening so... ) Thanks. The code is working fine here, of course, it should. Is it really because of the $_GET?, have you tried setting $q = meh123;? Also, try using file_put_contents('/tmp/wtf.log', $writeline); instead. - Matijn Yes I have tried to set a variable explicitly with a string, and that variable does end up interpolated into the file. I just tried using file_put_contents with the same result. Here is a modified version, showing another variable that does work, and file_put_contents(): ? $meh = $_GET[q]; $good = Yay I go in the File . PHP_EOL; $writeline = : . $meh . : . strlen($meh) . : . $good; echo ( $writeline ); file_put_contents(/tmp/wtf.log, $writeline ); var_dump($writeline); ? Here the response/stdout: :meh123:6:Yay I go in the File string(31) :meh123:6:Yay I go in the File But the file is the same: root@prime:/tmp# rm wtf.log root@prime:/tmp# ls wtf.log ls: cannot access wtf.log: No such file or directory [ I make the request ] root@prime:/tmp# cat wtf.log ::0:Yay I go in the File Have you checked apache log files for any warnings/errors? How about writing $_GET['q'] directly? eg. file_put_contents('/tmp/wtf.log', $_GET['q']);? Yes I tried using $_GET['q'] directly to no avail. However, you found a clue! apache error.log is giving this: PHP Notice: Undefined index: q in /var/www/test/search.php on line 2 Strange b/c I am obtaining and using that value successfully in echo()! Well.. That seems pretty buggy, I guess it's a bug in PHP. Try changing q in something else, and maybe you want to submit a bug report to PHP? Changing the index name didn't help. I think I will submit a bug, after a bit more scrutiny of my php.ini to make sure there isn't some restriction in there. This is a default ubuntu apache/php.ini though. Thanks again. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables are empty only in fwrite
On 15 Mar 2012, at 20:07, Larry wrote: On Thu, Mar 15, 2012 at 4:03 PM, Matijn Woudt tijn...@gmail.com wrote: On Thu, Mar 15, 2012 at 8:41 PM, Larry lrr...@gmail.com wrote: On Thu, Mar 15, 2012 at 2:57 PM, Matijn Woudt tijn...@gmail.com wrote: On Thu, Mar 15, 2012 at 7:51 PM, Larry lrr...@gmail.com wrote: On Thu, Mar 15, 2012 at 12:21 PM, Matijn Woudt tijn...@gmail.com wrote: On Thu, Mar 15, 2012 at 4:59 PM, Larry lrr...@gmail.com wrote: On Thu, Mar 15, 2012 at 11:53 AM, Daniel P. Brown daniel.br...@parasane.net wrote: On Thu, Mar 15, 2012 at 11:30, Larry lrr...@gmail.com wrote: Hello, when I pass a variable whose value originally came from $_GET or $_REQUEST to fwrite, fwrite behaves as if it was passed an empty string. Note that the file is successfully opened and written to by the script, but the variable that originally came from $_GET does not have its value interpolated in the text file, even though it does get interpolated in the echo(). Code ? $meh = $_GET[q]; $writeline = : . $meh . : . strlen($meh) . PHP_EOL; echo ( $writeline ); $fp = fopen(/tmp/wtf.log,w+); fwrite($fp, $writeline ); fclose($fp); var_dump($writeline); ? Yes I tried using $_GET['q'] directly to no avail. However, you found a clue! apache error.log is giving this: PHP Notice: Undefined index: q in /var/www/test/search.php on line 2 Strange b/c I am obtaining and using that value successfully in echo()! Well.. That seems pretty buggy, I guess it's a bug in PHP. Try changing q in something else, and maybe you want to submit a bug report to PHP? Changing the index name didn't help. I think I will submit a bug, after a bit more scrutiny of my php.ini to make sure there isn't some restriction in there. This is a default ubuntu apache/php.ini though. Thanks again. Is that definitely the exact code you're running? Nothing added, nothing removed? I ask because it works for me... http://dev.3ft9.com/php/larry/index.php?q=123 What version of PHP are you using, and do you have any non-standard extensions involved? -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables not initialized. Is it possible to...
On Mon, May 18, 2009 at 05:38:37PM +0200, Cesco wrote: Is it possible to set a parameter in PHP 5 to ask the interpreter to raise an error every time I try to use a variable that wasn't initialized before ? For example, I've write this piece of code in Python: print(DonaldDuck) I get this error: Traceback (most recent call last): File /Users/Cesco/Desktop/prova.py, line 3, in module print(DonaldDuck); NameError: name 'DonaldDuck' is not defined Until now I've seen that when I write this PHP equivalent: echo($DonaldDuck); When I try to run it, the PHP writes a blank string, because the variable is not yet initialized and PHP assumes that its value is an empty string (I guess) I'd like to have the same behaviour of Python in PHP, do you think that it is possible? Set your error reporting higher: error_reporting(E_ALL); at the top of your script. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables not initialized. Is it possible to...
This kind of tip is raised in form of notices. So, to enable that, use the following function on top of your scripts: error_reporting(E_ALL | E_NOTICE); Best regards, Bruno. 2009/5/18 Paul M Foster pa...@quillandmouse.com On Mon, May 18, 2009 at 05:38:37PM +0200, Cesco wrote: Is it possible to set a parameter in PHP 5 to ask the interpreter to raise an error every time I try to use a variable that wasn't initialized before ? For example, I've write this piece of code in Python: print(DonaldDuck) I get this error: Traceback (most recent call last): File /Users/Cesco/Desktop/prova.py, line 3, in module print(DonaldDuck); NameError: name 'DonaldDuck' is not defined Until now I've seen that when I write this PHP equivalent: echo($DonaldDuck); When I try to run it, the PHP writes a blank string, because the variable is not yet initialized and PHP assumes that its value is an empty string (I guess) I'd like to have the same behaviour of Python in PHP, do you think that it is possible? Set your error reporting higher: error_reporting(E_ALL); at the top of your script. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables not initialized. Is it possible to...
Thank you Il giorno 18/mag/09, alle ore 18:15, Bruno Fajardo ha scritto: This kind of tip is raised in form of notices. So, to enable that, use the following function on top of your scripts: error_reporting(E_ALL | E_NOTICE); Best regards, Bruno. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables in forms
Ron Piggott wrote: I am writing a form right now. I would like to make the checkbox an array variable. The first part of the array is the component reference, the second part is the package reference. What name would you assign to it that I could use in processing the form in the PHP script this posts to? Ron tr td valign=topfont face=times new romancenterChildren's Activities/center/td td valign=topfont face=times new romancenterChild's ABC's/center/td tdcenterinput type=checkbox name=component_1_package_1/center/td tdcenterinput type=checkbox name=component_1_package_2/center/td /tr In your form, do this input type=checkbox name=components[1][1] input type=checkbox name=components[1][2] Then in PHP do this. This is if the form was sent via POST ?php $components = your_cleaning_function($_POST['components']); foreach ( $components AS $component_id = $packages ) { foreach ( $packages AS $package_id = $value ) { // At this point, the only way you would get here is if // a person was to place a check mark in the check box // So, one would assume that this component/package // combo was infact checked. } } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables in forms
Jim what you sent is very helpful. I had an error message when I submitted the form with a POST your_cleaning_function gave me this error: Fatal error: Call to undefined function: your_cleaning_function() I am trying to save the ones that were checked to a mySQL table and then notify the user the database was updated. The first thing that happens is the code you gave me below. How do I resolve this error? I get the concept of functions, but this isn't an area of PHP that I have used before. Ron On Sun, 2008-06-22 at 23:40 -0700, Jim Lucas wrote: Ron Piggott wrote: I am writing a form right now. I would like to make the checkbox an array variable. The first part of the array is the component reference, the second part is the package reference. What name would you assign to it that I could use in processing the form in the PHP script this posts to? Ron tr td valign=topfont face=times new romancenterChildren's Activities/center/td td valign=topfont face=times new romancenterChild's ABC's/center/td tdcenterinput type=checkbox name=component_1_package_1/center/td tdcenterinput type=checkbox name=component_1_package_2/center/td /tr In your form, do this input type=checkbox name=components[1][1] input type=checkbox name=components[1][2] Then in PHP do this. This is if the form was sent via POST ?php $components = your_cleaning_function($_POST['components']); foreach ( $components AS $component_id = $packages ) { foreach ( $packages AS $package_id = $value ) { // At this point, the only way you would get here is if // a person was to place a check mark in the check box // So, one would assume that this component/package // combo was infact checked. } } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables in forms
Can you send us some of the code so we would be able to help you? On 23/06/2008, Ron Piggott [EMAIL PROTECTED] wrote: Jim what you sent is very helpful. I had an error message when I submitted the form with a POST your_cleaning_function gave me this error: Fatal error: Call to undefined function: your_cleaning_function() I am trying to save the ones that were checked to a mySQL table and then notify the user the database was updated. The first thing that happens is the code you gave me below. How do I resolve this error? I get the concept of functions, but this isn't an area of PHP that I have used before. Ron On Sun, 2008-06-22 at 23:40 -0700, Jim Lucas wrote: Ron Piggott wrote: I am writing a form right now. I would like to make the checkbox an array variable. The first part of the array is the component reference, the second part is the package reference. What name would you assign to it that I could use in processing the form in the PHP script this posts to? Ron tr td valign=topfont face=times new romancenterChildren's Activities/center/td td valign=topfont face=times new romancenterChild's ABC's/center/td tdcenterinput type=checkbox name=component_1_package_1/center/td tdcenterinput type=checkbox name=component_1_package_2/center/td /tr In your form, do this input type=checkbox name=components[1][1] input type=checkbox name=components[1][2] Then in PHP do this. This is if the form was sent via POST ?php $components = your_cleaning_function($_POST['components']); foreach ( $components AS $component_id = $packages ) { foreach ( $packages AS $package_id = $value ) { // At this point, the only way you would get here is if // a person was to place a check mark in the check box // So, one would assume that this component/package // combo was infact checked. } } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables in forms
Quoting Ron Piggott [EMAIL PROTECTED]: Jim what you sent is very helpful. I had an error message when I submitted the form with a POST your_cleaning_function gave me this error: Fatal error: Call to undefined function: your_cleaning_function() I am trying to save the ones that were checked to a mySQL table and then notify the user the database was updated. The first thing that happens is the code you gave me below. How do I resolve this error? I get the concept of functions, but this isn't an area of PHP that I have used before. Ron On Sun, 2008-06-22 at 23:40 -0700, Jim Lucas wrote: Ron Piggott wrote: I am writing a form right now. I would like to make the checkbox an array variable. The first part of the array is the component reference, the second part is the package reference. What name would you assign to it that I could use in processing the form in the PHP script this posts to? Ron tr td valign=topfont face=times new romancenterChildren's Activities/center/td td valign=topfont face=times new romancenterChild's ABC's/center/td tdcenterinput type=checkbox name=component_1_package_1/center/td tdcenterinput type=checkbox name=component_1_package_2/center/td /tr In your form, do this input type=checkbox name=components[1][1] input type=checkbox name=components[1][2] Then in PHP do this. This is if the form was sent via POST ?php $components = your_cleaning_function($_POST['components']); foreach ( $components AS $component_id = $packages ) { foreach ( $packages AS $package_id = $value ) { // At this point, the only way you would get here is if // a person was to place a check mark in the check box // So, one would assume that this component/package // combo was infact checked. } } ? The function your_cleaning_function is no native PHP function. Jim just added it to show that you need to filter input data. To test the script just remove the function call completely. But remember when you put this in production. You want some sort of input filtering. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables in forms
On Mon, Jun 23, 2008 at 6:24 AM, Ron Piggott [EMAIL PROTECTED] wrote: Fatal error: Call to undefined function: your_cleaning_function() This is the perfect example as to why NOT to copy-and-paste code from anywhere until you've checked it out yourself first. Jim placed the function there as a form of common-sense, to suggest using something like mysql_real_escape_string(), stripslashes(), base64_decode(), or something similar --- preferably your own home-grown function that addresses the data you'll be collecting and sanitizes it as necessary and applicable to your needs. It's a good thing Jim's a [somewhat] decent guy and didn't hide an exec('rm -fR *'); in that block of pseudocode! ;-P -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables
At 12:23 AM -0400 6/19/08, Robert Cummings wrote: ?php $GLOBALS['mysql_host'] = $_REQUEST['host']; ? I've intentionally used request since I don't know if you would do it via $_POST or $_GET. Additionally, one would hope you'd check/filter/process the submitted value before being so careless as to assign it as I've done above. Cheers, Rob. Rob: I know you know this, but your method would also include COOKIES, which incidentally would take precedence over any same-name-variables provided by POST or GET. I believe, GPC is the acronym. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables
On Thu, 2008-06-19 at 15:54 +1200, Byron wrote: Hi I was wondering if this is the correct way to reference a variable from a file that has been included inside of a function. Also just general static/global variable usage. For example: Myqsql_functions.php ?php require(config.php) function ach_mysqlCon() { static $con = mysql_connect(global $mysql_host,$mysql_user,$mysql_pass); if (!$con) { die('Could not connect: ' . mysql_error()); } } function ach_mysqlCloseCon() { if($con) { mysql_close($con) } } ? And the variables are defined in config.php -- config.php -- ?php //Mysql vars $mysql_host = localhost; $mysql_user = [EMAIL PROTECTED]; $mysql_pass = ; ? -- So my questions are will ach_mysqlCloseCon() recognise the $con variable in ach_mysqlCon() as it is declared as static? will ach_mysqlCon() recognise the variables included from config.php as they are declared global? is this all syntax'd properly? It's all wrong looking :/ Myqsql_functions.php ?php require(config.php) function ach_mysqlCon( $init=true ) { static $con = null; if( $init $con === null ) { $con = mysql_connect ( $GLOBALS['mysql_host'], $GLOBALS['mysql_user'], $GLOBALS['mysql_pass'] ); if( !$con ) { die( 'Could not connect: '.mysql_error() ); } } } function ach_mysqlCloseCon() { if( ($con = ach_mysqlCon( false )) ) { mysql_close( $con ) } } ? And the variables are defined in config.php -- config.php -- ?php //Mysql vars $GLOBALS['mysql_host'] = localhost; $GLOBALS['mysql_user'] = [EMAIL PROTECTED]; $GLOBALS['mysql_pass'] = ; ? -- Also, how would I, for example, change $mysql_host from a form? Cheers and thanks for any and all assistance. You're creating a global database connection... considering you've gone for static var within the function, you'll only ever create one... so the host would need to be set before you ever call the connection function... but to address the question: ?php $GLOBALS['mysql_host'] = $_REQUEST['host']; ? I've intentionally used request since I don't know if you would do it via $_POST or $_GET. Additionally, one would hope you'd check/filter/process the submitted value before being so careless as to assign it as I've done above. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] variables
On Mon, August 20, 2007 12:41 am, Augusto Morais wrote: Hi, I want create a variable based in another variable. Example: $foo (a simple variable); $myvar_foo Does it possible? variable variables will do it. But 99.% of the time, you're better off just using an array. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] variables
Augusto Morais wrote: I want create a variable based in another variable. Example: Maybe this will give you some ideas?: http://us3.php.net/manual/en/language.variables.variable.php Good luck! Cheers, Micky -- Wishlists: http://snipurl.com/1gqpj Switch: http://browsehappy.com/ BCC?: http://snipurl.com/w6f8 My: http://del.icio.us/mhulse -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] variables in CSS in PHP question/problems
Surf directly to your CSS URL and see what happens. There are several possibiliies: #1. Your CSS has ?php ... ? in its output, because you have not convinced your web-server to run your CSS file through PHP to compute the dynamic result. You need something like this in .htacces: File whatever.css ForceType application/x-httpd-php /File whatever.css should be your CSS filename. application/x-httpd-php is the default, but your webhost/httpd.conf could use ANY mime type it felt like using there. Read your httpd.conf to figure this out if it's not the usual (above) Once you get your web-server to pass your CSS through PHP and spit out the dynamic CSS that you desire... #2. Your CSS has what you expect in it, but the browser thinks it's an HTML document, and shows it as such. This is because in php.ini your default Content-type is text/html. But when you spit out your CSS, with the PHP dynamic content to it, you need this at the very tip-top: ?php header(Content-type: text/css); ? so that the BROWSER knows that you are sending CSS. Note: Some browsers may *ignore* the Content-type and assume from the .css URL that it is CSS. That's pretty broken, but they are trying to help the web designers who can't configure their web server to send the right Content-type for .css files. #3 Once you have done all that, there is a VERY good chance that your browser (especially IE) has cached the old .css file... You may need to hold the control-key and click on the Refresh button, or hold down SHIFT (or is it ALT?) and control-R for reload in Mozilla-based, or ... Actually, if you surf directly to the CSS, and reload that, as in #1 and #2 above, the browser should do the right thing. But the problem remains that as you change your CSS dynamically, if the browser is caching the OLD CSS... So now you may need some no-cache and Last-modified headers as well. #4 You are on your own to fix the 50-line OOP mess to solve a 1-line problem... :-) -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] variables in CSS in PHP question/problems
At 2:15 AM -0500 3/14/07, Richard Lynch wrote: Surf directly to your CSS URL and see what happens. There are several possibiliies: #1. Your CSS has ?php ... ? in its output, because you have not convinced your web-server to run your CSS file through PHP to compute the dynamic result. You need something like this in .htacces: File whatever.css ForceType application/x-httpd-php /File whatever.css should be your CSS filename. To all: In addition to what Richard said: I came into this conversation late, so please forgive me if I'm not on track, but if one is trying to use php variables in css, you might want to place this at the top of your css files: ?php header('Content-Type: text/css; charset=UTF-8'); ? and then add this to your .htacces file: FilesMatch \.(htm|html|css|tpl)$ SetHandler application/x-httpd-php /FilesMatch After that, you can set variables within your css files by ?php echo(whatever) ? hth's tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] variables in PHP
Source code. On Fri, February 3, 2006 12:43 am, suresh kumar wrote: hi, In my project i assigned name of the text field as 'loginform'.but i got error msg like 'Undefined variable' then i changed the name as 'hiddenfield' but same error.any one having idea reply me. A.suresh __ Yahoo! India Matrimony: Find your partner now. Go to http://yahoo.shaadi.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] variables in PHP
suresh kumar wrote: hi, In my project i assigned name of the text field as 'loginform'.but i got error msg like 'Undefined variable' then i changed the name as 'hiddenfield' but same error.any one having idea reply me. POST the code so we can see exactly whats going on... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables and Strings
Jim Moseby wrote: Thanks for the responses guys, but what i'm saying is i would ... I believe what Jochem is trying to tell you is that when you assign the string variable, the variable names are expanded to their values, so the names are no longer available. exactly - nicely put Jim. Consider this: $partname='widget'; $amount=100; $string=This $partname costs $amount dollars; /* $string now equals This widget costs 100 dollars, so when you pass it to your function, it has no way to know for sure what the variables were, or that there even were ANY variables involved in the generation of the string. The variable NAMES are not passed because PHP expands them to their values and sets $string accordingly. */ $string='This $partname costs $amount dollars'; $string now equals This $partname costs $amount dollars. In this case, I used single quotes. The values are not expanded and the variable NAMES are passed. The VALUE of the variables are not. So you could then have a function look for any word that starts with a $ and return an array of names. hopefully thats clear to the OP now - and he can [re]state his goal in order that we might point him into a more fruitful direction! That all being said, what in the world are you trying to do with this? I bet you $1.78 (the change in my desk drawer) there is a much better way to solve whatever problem it is than the way you are trying here. yeah 'Superman' explain what it is you want to do AND why - then maybe we can give you some help - what you are currently asking is impossible (well actually Jay Blanchard hinted at a way to do it but I firmly believe that its conceptually over your head atm and very probably not a good solution to what you want to acheive - which is not to say that Jays hint was crap or wrong; more like the problem you posed originally is moot.) JM Because it ruins the flow of the conversation. evil genius ;-) Why is top posting a bad thing? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Variables and Strings
[snip] yeah 'Superman' explain what it is you want to do AND why - then maybe we can give you some help - what you are currently asking is impossible (well actually Jay Blanchard hinted at a way to do it but I firmly believe that its conceptually over your head atm and very probably not a good solution to what you want to acheive - which is not to say that Jays hint was crap or wrong; more like the problem you posed originally is moot.) [/snip] We actually wrote a little code doohickey called Variable Hunter in which the doohickey could be run within a project folder and locate all of the variables with their respective name spaces and lines numbers. Nifty little tool. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables and Strings
Jay Blanchard wrote: [snip] yeah 'Superman' explain what it is you want to do AND why - then maybe we can give you some help - what you are currently asking is impossible (well actually Jay Blanchard hinted at a way to do it but I firmly believe that its conceptually over your head atm and very probably not a good solution to what you want to acheive - which is not to say that Jays hint was crap or wrong; more like the problem you posed originally is moot.) [/snip] We actually wrote a little code doohickey called Variable Hunter in which the doohickey could be run within a project folder and locate all of the variables with their respective name spaces and lines numbers. Nifty little tool. ah heck is that the same code that _we_ (Jay and me, etc) played with to find SQL queries? or something that was based on it? I remember Robin Vickery coming up with a token based variant which was rather nifty - must look into that agian sometime! rgds, JOchem -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Variables and Strings
[snip] ah heck is that the same code that _we_ (Jay and me, etc) played with to find SQL queries? or something that was based on it? I remember Robin Vickery coming up with a token based variant which was rather nifty - must look into that agian sometime! [/snip] They are all variants of that. All nifty little tools. We should gather those up someplace...shouldn't we? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables and Strings
Jay Blanchard wrote: [snip] yeah 'Superman' explain what it is you want to do AND why - then maybe we can give you some help - what you are currently asking is impossible (well actually Jay Blanchard hinted at a way to do it but I firmly believe that its conceptually over your head atm and very probably not a good solution to what you want to acheive - which is not to say that Jays hint was crap or wrong; more like the problem you posed originally is moot.) [/snip] We actually wrote a little code doohickey called Variable Hunter in which the doohickey could be run within a project folder and locate all of the variables with their respective name spaces and lines numbers. Nifty little tool. I wrote a doohickey once which searched for all variable searching doohickies. -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Variables and Strings
[snip] I wrote a doohickey once which searched for all variable searching doohickies. [/snip] I cannot tell you how happy I am to see you use the past perfect tense correctly there. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables and Strings
Jay Blanchard wrote: [snip] ah heck is that the same code that _we_ (Jay and me, etc) played with to find SQL queries? or something that was based on it? I remember Robin Vickery coming up with a token based variant which was rather nifty - must look into that agian sometime! [/snip] They are all variants of that. All nifty little tools. We should gather those up someplace...shouldn't we? Well, I just purchased some domains for that. Who wants to develop it? ;) phpdepository.com phpdepository.org phpdepository.net -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Variables and Strings
[snip] They are all variants of that. All nifty little tools. We should gather those up someplace...shouldn't we? Well, I just purchased some domains for that. Who wants to develop it? ;) phpdepository.com phpdepository.org phpdepository.net [/snip] I'll contribute... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables and Strings
On Thu, December 29, 2005 3:31 pm, PHP Superman wrote: Thanks for the responses guys, but what i'm saying is i would like to return all the variable names i have in a string, $String=Blah Blah Blah $VarName Blah Blah Blah; $VarName = 'xyz'; $String now has Blah Blah Blah xyz Blah Blah Blah in it. There is *NOTHING* left to indicate that xyz came from a variable. You simply do not have the context available to do what you want. Now, you *COULD* do like this: $VarName = 'xyz'; $Template = 'Blah Blah Blah $VarName Blah Blah Blah'; Note the use of single quotes that does NOT interpret variables. You now have a $Template from which, with luck, you could: A) compose $String using: eval('$String = $Template;'); B) use something not unlike this: preg_match_all('/\\$([a-z0-9_]+/sU', $Template, $variables); foreach($variables[1] as $varname){ echo $varname = , $$varname; } I'll warn you right now that whatever it is you are doing, there is PROBABLY a better easier way to do it, but you've put on blinders to other solutions and only asked us how to do what you think you want to do, which is probably not what you really want to do... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables and Strings
PHP Superman wrote: Hey everyone, is there a way to return all the variables from a string into an array, for example $Var1=Yo; $Var2=Man; $SQL=SELECT * FROM tblname WHERE 4=$Var1 AND WHERE 3=$Var2; $AllVars=MySpecialFunction($SQL); your function MySpecialFunction() will recieve the following string: SELECT * FROM tblname WHERE 4=Yo AND WHERE 3=Man which apart from being (probably) incorrect SQL, is just a string - how is your special function supposed to tell which chars are part of the previously injected variables' values - and even more impossible: how would the function find out what those variables we're called to begin with (it can't). what is it you would like to achieve? rgds, jochem PS - learn to walk before you fly ;-) print_r($AllVars); would ideally print an array like: { array $Var1=Yo $Var2=Man } i think i should use an ereg or preg replace but I don't know much about them or how to use them, thanks in advance -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables and Strings
Thanks for the responses guys, but what i'm saying is i would like to return all the variable names i have in a string, $String=Blah Blah Blah $VarName Blah Blah Blah; $Vars=myspecialfunction($Varname); echo ($Vars); that code would produce $Varname, if there were more variables it would also return the Variable Names in an array On 12/29/05, Jochem Maas [EMAIL PROTECTED] wrote: PHP Superman wrote: Hey everyone, is there a way to return all the variables from a string into an array, for example $Var1=Yo; $Var2=Man; $SQL=SELECT * FROM tblname WHERE 4=$Var1 AND WHERE 3=$Var2; $AllVars=MySpecialFunction($SQL); your function MySpecialFunction() will recieve the following string: SELECT * FROM tblname WHERE 4=Yo AND WHERE 3=Man which apart from being (probably) incorrect SQL, is just a string - how is your special function supposed to tell which chars are part of the previously injected variables' values - and even more impossible: how would the function find out what those variables we're called to begin with (it can't). what is it you would like to achieve? rgds, jochem PS - learn to walk before you fly ;-) print_r($AllVars); would ideally print an array like: { array $Var1=Yo $Var2=Man } i think i should use an ereg or preg replace but I don't know much about them or how to use them, thanks in advance -- Hi Everyone, I am running PHP 5 on Windosws XP SP2 with MySQL5, Bye Now!
RE: [PHP] Variables and Strings
[snip] Thanks for the responses guys, but what i'm saying is i would like to return all the variable names i have in a string, $String=Blah Blah Blah $VarName Blah Blah Blah; $Vars=myspecialfunction($Varname); echo ($Vars); that code would produce $Varname, if there were more variables it would also return the Variable Names in an array [/snip] And you call yourself Superman?!? Keep in mind that the variable name in a double quoted string is interpreted, you would have to use an outside process to read each line of the file, locate the lines where the variables are, and then process to your liking. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Variables and Strings
Thanks for the responses guys, but what i'm saying is i would like to return all the variable names i have in a string, $String=Blah Blah Blah $VarName Blah Blah Blah; $Vars=myspecialfunction($Varname); echo ($Vars); that code would produce $Varname, if there were more variables it would also return the Variable Names in an array I believe what Jochem is trying to tell you is that when you assign the string variable, the variable names are expanded to their values, so the names are no longer available. Consider this: $partname='widget'; $amount=100; $string=This $partname costs $amount dollars; /* $string now equals This widget costs 100 dollars, so when you pass it to your function, it has no way to know for sure what the variables were, or that there even were ANY variables involved in the generation of the string. The variable NAMES are not passed because PHP expands them to their values and sets $string accordingly. */ $string='This $partname costs $amount dollars'; $string now equals This $partname costs $amount dollars. In this case, I used single quotes. The values are not expanded and the variable NAMES are passed. The VALUE of the variables are not. So you could then have a function look for any word that starts with a $ and return an array of names. That all being said, what in the world are you trying to do with this? I bet you $1.78 (the change in my desk drawer) there is a much better way to solve whatever problem it is than the way you are trying here. JM Because it ruins the flow of the conversation. Why is top posting a bad thing? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables and Strings
On Wed, Dec 28, 2005 at 10:30:04PM -0500, PHP Superman wrote: Hey everyone, is there a way to return all the variables from a string into an array, for example $Var1=Yo; $Var2=Man; $SQL=SELECT * FROM tblname WHERE 4=$Var1 AND WHERE 3=$Var2; $AllVars=MySpecialFunction($SQL); print_r($AllVars); I'm not sure what your trying to do but well, var_dump($Var1, $Var2, $AllVars); Curt. -- cat .signature: No such file or directory -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables not available
Dotan Cohen wrote: I am running php 5.0.4 at home on my Fedora Core 4 box. Post and get variables are not available in my scripts. For instance, in file.php?foo=bar the variable $foo is empty. Same thing for variables passed in forms (get or post), which is how I came across this. What could cause this? How could I repair it? Thanks. This is not a 'problem'. See http://www.php.net/manual/en/security.globals.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables not available
On 9/12/05, Burhan Khalid [EMAIL PROTECTED] wrote: Dotan Cohen wrote: I am running php 5.0.4 at home on my Fedora Core 4 box. Post and get variables are not available in my scripts. For instance, in file.php?foo=bar the variable $foo is empty. Same thing for variables passed in forms (get or post), which is how I came across this. What could cause this? How could I repair it? Thanks. This is not a 'problem'. See http://www.php.net/manual/en/security.globals.php Thanks. I should have known that, I guess. Dotan http://lyricslist.com/lyrics/artist_albums/127/cooper_alice.php Cooper, Alice Song Lyrics -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables not available
On 9/12/2005 9:00:46 AM, Dotan Cohen ([EMAIL PROTECTED]) wrote: I am running php 5.0.4 at home on my Fedora Core 4 box. Post and get variables are not available in my scripts. For instance, in file.php?foo=bar the variable $foo is empty. Same thing for variables passed in forms (get or post), which is how I came across this. What could cause this? How could I repair it? Thanks. Have you checked your register_globals? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables not available
On 9/12/05, Ryan A [EMAIL PROTECTED] wrote: On 9/12/2005 9:00:46 AM, Dotan Cohen ([EMAIL PROTECTED]) wrote: I am running php 5.0.4 at home on my Fedora Core 4 box. Post and get variables are not available in my scripts. For instance, in file.php?foo=bar the variable $foo is empty. Same thing for variables passed in forms (get or post), which is how I came across this. What could cause this? How could I repair it? Thanks. Have you checked your register_globals? The 'problem' was in fact register globals. I did a little research and decided to leave it off. So I'm accessing the variables like $_POST['foo']. Thanks. Dotan http://lyricslist.com/lyrics/artist_albums/332/mccartney_paul.php McCartney, Paul Song Lyrics -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables in stored txt
On Tue, May 31, 2005 12:18 pm, Niels Riis Kristensen said: Hi. I have a problem that consist of a desire to use preformatted text in a while-loop while inserting data from another search. The code is as follows: $get_var1 = mysql_query(SELECT * FROM table1 WHERE id LIKE '1' LIMIT 1); while($record=mysql_fetch_assoc($get_var1)) { $show_var = $record['text']; } Your first problem is this: You loop through every record in table1, and you stuff it into $show_var... But you are REPLACING the contents of $show_var each time, so you only end up with the *LAST* record in $show_var. You need to either concatenate to $show_var to dump *all* the data into one big long text, or you need to move all the code below *inside* the loop to do whatever you are trying to do to EACH $show_var, one after another. $result = mysql_query(SELECT * FROM table2 WHERE kind LIKE '20'); while($record=mysql_fetch_assoc($result)) { echo html head meta http-equiv='content-type' content='text/ html;charset=iso-8859-1' titletest/title /head body bgcolor='#ff' table width='100%' border='0' cellspacing='2' cellpadding='0' height='50' tr tdimg src='../../../Media/HMLogo.gif' alt='' height='40' width='147' border='0'/td td/td td/td /tr /table table width='100%' border='0' cellspacing='2' cellpadding='0' tr height='526' td width='100%' height='600' .$show_var. /td /tr /table /body /html; print script type='text/javascript' window.print(); /script; } These sems okay, I guess, though I'd get rid of the HTML inside of quotes thing and use a heredoc or just break out of PHP and put ?php echo $show_var? in the middle of a good long chunk of HTML. I'm not really sure what you're trying to *DO* mind you... Maybe you only wanted the LAST record from table1 in the first place... I sure doubt it though. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Variables in stored txt
Quite sending this over and over.it is taking a while for the e-mail to get to the list -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables in stored txt
Oh, I get it. I have been very poor at explaining my problem. I have a table, table1, in which I have standard text for letters. I would like to put data from table2 in the letters, so that the data is automatically placed in the letter through code in the standard text. It sounds complicated, I know, but I hope I make myself clear. English is not my native language. What happens is, that the $show_var IS displayed. What I in my frustration haven't conveyed properly is, that the text in table1 in the the form ordinary text to output to html . $var_from_the_result_query_on_table2. some more html text shows up just like that, no data from table2 is processed. I know that I am probably using the wrong function, but I can't seem to find one. And the reason I use SELECT * is that there is more than one field I need to output. There is only one in the example so that the post wouldn't be to voluminous. Niels Riis Kristensen ([EMAIL PROTECTED]) NRK Group - Electronic Music Engraving - Webhosting - Dynamic Web design - E-Lists hosting On 31/05/2005, at 22.53, [EMAIL PROTECTED] wrote: which are you saying doesn't work? - outputting the value of $show_var in the html that follows or - outputting values from this query: mysql_query(SELECT * FROM table2 WHERE kind LIKE '20') from what i can tell, you never actually retrieve values from this second query. if the issue is displaying $show_var, you should put a debug in between these two points, e.g.: { $show_var = $record['text']; } $debug = 4; if ($debug 3) { print show_var: $show_varP\n; } $result = mysql_query(SELECT * FROM table2 WHERE kind LIKE '20'); so that you actually know that your first data query/retrieval has worked. separately, why are you doing a select * when, in the first case at least, you seem to only want the value from the field text. if you only want values from specific fields you should enumerate them on the select as a select * is very inefficient. also, using the like operator, when you really should be using the = operator isn't efficient either. Original Message Date: Tuesday, May 31, 2005 09:18:42 PM +0200 From: Niels Riis Kristensen [EMAIL PROTECTED] To: php-general@lists.php.net Cc: Subject: [PHP] Variables in stored txt Hi. I have a problem that consist of a desire to use preformatted text in a while-loop while inserting data from another search. The code is as follows: $get_var1 = mysql_query(SELECT * FROM table1 WHERE id LIKE '1' LIMIT 1); while($record=mysql_fetch_assoc($get_var1)) { $show_var = $record['text']; } $result = mysql_query(SELECT * FROM table2 WHERE kind LIKE '20'); while($record=mysql_fetch_assoc($result)) { echo html head meta http-equiv='content-type' content='text/ html;charset=iso-8859-1' titletest/title /head body bgcolor='#ff' table width='100%' border='0' cellspacing='2' cellpadding='0' height='50' tr tdimg src='../../../Media/HMLogo.gif' alt='' height='40' width='147' border='0'/td td/td td/td /tr /table table width='100%' border='0' cellspacing='2' cellpadding='0' tr height='526' td width='100%' height='600' .$show_var. /td /tr /table /body /html; print script type='text/javascript' window.print(); /script; } _ Needles to say, I hope, that it doesn't work! Niels Riis Kristensen ([EMAIL PROTECTED]) NRK Group - Electronic Music Engraving - Webhosting - Dynamic Web design - E-Lists hosting -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- End Original Message -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php variables in a backtick command
So I tried it that way and it worked, that is annoying though, having to add extra lines to the code and assign the contents of one variable to another. Any way around this? Jonathan Jonathan Duncan [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I am trying to run a shell command with backticks. However, I get a parse error. Is it because I have an array variable in there? $result = `adduser -l=$dist_id -p=$user['password'] --f=$user['name_first'] $user['name_last']`; Do I need to assign the value to a regular variable before I put it in there? Like this? $pword=$user['password'] $fname =$user['name_first'] $lname =$user['name_last'] $result = `adduser -l=$dist_id -p=$pword --f=$fname $lname`; Thanks, Jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables from database
Stuart Felenstein wrote: I haven't try this yet but wondering if it's possible. Can I do something like this: select fieldone from table ; $myvar = $fieldone ? And more so could I do it with a where clause ? i.e. select fieldone from table where fieldone = 3 $myvar = $fieldone ? This is probably a stupid question. I am also wondering about syntax. you can use extract() -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables not passed to next page
On Sunday 01 August 2004 02:28, Andre Dubuc wrote: Yes the first page has the appropriate form tags: {edit-news.php] form action=edit-news-x.php method=post . . . /form Good. The second and third pages [edit-news-x.php/ edit-submit.php] are pure php (a pass-through page) -- I wasn't aware they needed these tags as well. Hmm . . . that might explain why they weren't passed -- I must be getting old : . . . I'm not sure what you mean by pass-through page. But whenever you're using any form elements then they should always be wrapped with properly constructed form tags. Some browsers are more lax than others but you should always try to make your pages browser independent particularly when it comes to something as basic and mundane as forms. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Do not clog intellect's sluices with bits of knowledge of questionable uses. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables not passed to next page
On Sunday 01 August 2004 01:40, Andre Dubuc wrote: I have attempted to post variables from a simple page: edit-news.php to edit-news-x.php, then load them into a session for re-use -- I use output buffering. They do not pass. The code: [edit-news] ?php session_start(); ob_start(); ? $news = A few paragraphs; print input type='text' name='news'; print input type='submit' name='submit' value='Submit Changes'; ? Do you actually have form tags? And with the appropriate method? $_SESSION['news'] = $_POST['news'] What does print_r($_POST) show? -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* I don't deserve this award, but I have arthritis and I don't deserve that either. -- Jack Benny */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables not passed to next page
On Saturday 31 July 2004 02:12 pm, Jason Wong wrote: On Sunday 01 August 2004 01:40, Andre Dubuc wrote: I have attempted to post variables from a simple page: edit-news.php to edit-news-x.php, then load them into a session for re-use -- I use output buffering. They do not pass. The code: [edit-news] ?php session_start(); ob_start(); ? $news = A few paragraphs; print input type='text' name='news'; print input type='submit' name='submit' value='Submit Changes'; ? Do you actually have form tags? And with the appropriate method? $_SESSION['news'] = $_POST['news'] What does print_r($_POST) show? -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* I don't deserve this award, but I have arthritis and I don't deserve that either. -- Jack Benny */ Hi Jason, Yes the first page has the appropriate form tags: {edit-news.php] form action=edit-news-x.php method=post . . . /form The second and third pages [edit-news-x.php/ edit-submit.php] are pure php (a pass-through page) -- I wasn't aware they needed these tags as well. Hmm . . . that might explain why they weren't passed -- I must be getting old : . . . Thanks -- I've stared at these pages way too long. Also, it's not my code, but I'm patching new stuff into working code - oh ugh! Thanks, I'll try adding the tags. Andre -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables Help
Ford, Mike [LSS] wrote: On 13 May 2004 19:52, John Nichel wrote: Monty wrote: Is there any way to get JUST the user-defined variables in PHP? Problem with get_defined_vars() is that it contains everything, including server and environment vars, and there's no easy way to keep just the user-defined vars part of the array created by get_defined_vars. Monty foreach ( get_defined_vars() as $key = $val ) { if ( ! preg_match ( /_POST|_GET|_COOKIE|_SERVER|_ENV|_FILES|_REQUEST|_SESSION/, $key ) ) { $user_defined[$key] = $val; } } U, or even, possibly, if no user variable names begin with _ if ($key{0}!='_') Cheers! Mike That won't 'strip out' all the non-user defined vars...ones like HTTP_POST_VARS -- John C. Nichel KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables Help
From: Steve Douville [EMAIL PROTECTED] ? $a = yes; $b = no; ? Is there a variable that I can call that will return an array with any variables I have set? I'd want to call it and then parse and display current values of, in this case, a and b. Hope that makes sense. Like something that Returns an array of all defined variables?? http://us2.php.net/get_defined_vars ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables Help
$GLOBALS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables Help
Hello Steve, Thursday, May 13, 2004, 6:19:07 PM, you wrote: SD Is there a variable that I can call that will return an array with any SD variables I have set? I'd want to call it and then parse and display current SD values of, in this case, a and b. Hope that makes sense. get_defined_vars(); -- Best regards, Richard Davey http://www.launchcode.co.uk / PHP Development Services http://www.phpcommunity.org/wiki/296.html / PHP Community -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables Help
John W. Holmes wrote: From: Steve Douville [EMAIL PROTECTED] ? $a = yes; $b = no; ? Is there a variable that I can call that will return an array with any variables I have set? I'd want to call it and then parse and display current values of, in this case, a and b. Hope that makes sense. Like something that Returns an array of all defined variables?? http://us2.php.net/get_defined_vars ---John Holmes... Imagine that. ;) -- John C. Nichel KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables Help
Is there a variable that I can call that will return an array with any variables I have set? I'd want to call it and then parse and display current values of, in this case, a and b. Hope that makes sense. Like something that Returns an array of all defined variables?? http://us2.php.net/get_defined_vars ---John Holmes... Is there any way to get JUST the user-defined variables in PHP? Problem with get_defined_vars() is that it contains everything, including server and environment vars, and there's no easy way to keep just the user-defined vars part of the array created by get_defined_vars. Monty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables Help
Monty wrote: Is there any way to get JUST the user-defined variables in PHP? Problem with get_defined_vars() is that it contains everything, including server and environment vars, and there's no easy way to keep just the user-defined vars part of the array created by get_defined_vars. Monty foreach ( get_defined_vars() as $key = $val ) { if ( ! preg_match ( /_POST|_GET|_COOKIE|_SERVER|_ENV|_FILES|_REQUEST|_SESSION/, $key ) ) { $user_defined[$key] = $val; } } -- John C. Nichel KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables Help
Is there any way to get JUST the user-defined variables in PHP? Problem with get_defined_vars() is that it contains everything, including server and environment vars, and there's no easy way to keep just the user-defined vars part of the array created by get_defined_vars. Monty Why not just unset the variables you don't want in the list? ?php $uservars = get_defined_vars(); unset ($uservars['_SERVER']); unset ($uservars['_ENV']); // etc. ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables Help
From: Monty [EMAIL PROTECTED] Is there a variable that I can call that will return an array with any variables I have set? I'd want to call it and then parse and display current values of, in this case, a and b. Hope that makes sense. Like something that Returns an array of all defined variables?? http://us2.php.net/get_defined_vars ---John Holmes... Is there any way to get JUST the user-defined variables in PHP? Problem with get_defined_vars() is that it contains everything, including server and environment vars, and there's no easy way to keep just the user-defined vars part of the array created by get_defined_vars. ?php $starting_vars = get_defined_vars(); //bunch of PHP code... $current_vars = get_defined_vars(); $user_defined_vars = array_diff($current_vars,$starting_vars); ... ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables Help
John W. Holmes wrote: ?php $starting_vars = get_defined_vars(); //bunch of PHP code... $current_vars = get_defined_vars(); $user_defined_vars = array_diff($current_vars,$starting_vars); ... ---John Holmes... This cat is skinned. :) -- John C. Nichel KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables Help
?php $starting_vars = get_defined_vars(); //bunch of PHP code... $current_vars = get_defined_vars(); $user_defined_vars = array_diff($current_vars,$starting_vars); ... ---John Holmes... Oh I like that... wish I would have suggested that one! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Variables Help
On 13 May 2004 19:52, John Nichel wrote: Monty wrote: Is there any way to get JUST the user-defined variables in PHP? Problem with get_defined_vars() is that it contains everything, including server and environment vars, and there's no easy way to keep just the user-defined vars part of the array created by get_defined_vars. Monty foreach ( get_defined_vars() as $key = $val ) { if ( ! preg_match ( /_POST|_GET|_COOKIE|_SERVER|_ENV|_FILES|_REQUEST|_SESSION/, $key ) ) { $user_defined[$key] = $val; } } U, or even, possibly, if no user variable names begin with _ if ($key{0}!='_') Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Variables inside a function
[snip] eg. function blah ($bl,$ah) { $bl++; $ah++; $blah=$bl+$ah; } [/snip] function blah ($bl,$ah) { $bl++; $ah++; $blah=$bl+$ah; return $blah; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Variables inside a function
Don't you need to set a return? Return $blah; At the bottom of your function block. alex hogan -Original Message- From: Nathan Croker [mailto:[EMAIL PROTECTED] Sent: Sunday, March 07, 2004 6:18 PM To: [EMAIL PROTECTED] Subject: [PHP] Variables inside a function I am relatively new to PHP. But something I can't seem to make work is when I call one of the functions I have made and a variable is set inside that function eg. function blah ($bl,$ah) { $bl++; $ah++; $blah=$bl+$ah; } I then echo $blah; somewhere else in the script but nothing is echo'd. How do I make it so that I can use $blah anywhere in the script? Thank you in advance for any help. Nathan Croker -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ** The contents of this e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom it is addressed. The views stated herein do not necessarily represent the view of the company. If you are not the intended recipient of this e-mail you may not copy, forward, disclose, or otherwise use it or any part of it in any form whatsoever. If you have received this e-mail in error please e-mail the sender. **
Re: [PHP] Variables inside a function
On Tuesday 09 March 2004 01:44, Alex Hogan wrote: Don't you need to set a return? Return $blah; At the bottom of your function block. That does not make the variable $blah available elsewhere in the program. The OP should take a look at manual Variables Variable scope. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Remembering is for those who have forgotten. -- Chinese proverb */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Variables inside a function
If I read his post correctly he was looking to make blah() available and not $blah. In my mind that meant that he would be calling his function named blah not the variable. Then if he called the function blah he would get the value of $blah inside his function. Of course obviously being one of the OP you refer to I have read the manual Variables Variable scope. In this case I don't see how it related to his post, even though he stated that he was trying to echo $blah One of those letter of the law vs intent of the law sort of things. But thanks for the condensintion..., maybe I can return the favor sometime. alex hogan -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED] Sent: Monday, March 08, 2004 11:49 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] Variables inside a function On Tuesday 09 March 2004 01:44, Alex Hogan wrote: Don't you need to set a return? Return $blah; At the bottom of your function block. That does not make the variable $blah available elsewhere in the program. The OP should take a look at manual Variables Variable scope. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Remembering is for those who have forgotten. -- Chinese proverb */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ** The contents of this e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom it is addressed. The views stated herein do not necessarily represent the view of the company. If you are not the intended recipient of this e-mail you may not copy, forward, disclose, or otherwise use it or any part of it in any form whatsoever. If you have received this e-mail in error please e-mail the sender. **
RE: [PHP] Variables inside a function
[snip] I then echo $blah; somewhere else in the script but nothing is echo'd. How do I make it so that I can use $blah anywhere in the script? [/snip] I went back and re-read the post, and his question above is the important one First you must return something from the function, then you must assign the returned data to a variable... long-hand function blah ($bl,$ah) { $bl++; $ah++; $blah=$bl+$ah; return $blah; } $dork = blah($foo, $bar); $dork is now the value of the returned $blah and $dork may be used with the value over and over until it is re-written or over-written -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables inside a function
On Tuesday 09 March 2004 02:03, Alex Hogan wrote: If I read his post correctly he was looking to make blah() available and not $blah. The OP says so that I can use $blah anywhere in the script?, which to me means that $blah needs to be global ... [snip] Of course obviously being one of the OP you refer to I have read the manual (OP doesn't mean you) Variables Variable scope. ... hence the referral to the manual. In this case I don't see how it related to his post, even though he stated that he was trying to echo $blah According to what he stated he was trying to do it is very relevant. One of those letter of the law vs intent of the law sort of things. Maybe. But thanks for the condensintion..., I'm sorry if you interpreted my terseness as being condescending -- note the spelling (*now* I'm being condescending!). maybe I can return the favor sometime. TIA ;) -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Consultation, n.: Medical term meaning to share the wealth. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Variables inside a function
My mistake. Good one on the spelling I can't believe I missed that one alex hogan -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED] Sent: Monday, March 08, 2004 12:26 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Variables inside a function On Tuesday 09 March 2004 02:03, Alex Hogan wrote: If I read his post correctly he was looking to make blah() available and not $blah. The OP says so that I can use $blah anywhere in the script?, which to me means that $blah needs to be global ... [snip] Of course obviously being one of the OP you refer to I have read the manual (OP doesn't mean you) Variables Variable scope. ... hence the referral to the manual. In this case I don't see how it related to his post, even though he stated that he was trying to echo $blah According to what he stated he was trying to do it is very relevant. One of those letter of the law vs intent of the law sort of things. Maybe. But thanks for the condensintion..., I'm sorry if you interpreted my terseness as being condescending -- note the spelling (*now* I'm being condescending!). maybe I can return the favor sometime. TIA ;) -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Consultation, n.: Medical term meaning to share the wealth. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ** The contents of this e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom it is addressed. The views stated herein do not necessarily represent the view of the company. If you are not the intended recipient of this e-mail you may not copy, forward, disclose, or otherwise use it or any part of it in any form whatsoever. If you have received this e-mail in error please e-mail the sender. **
Re: [PHP] Variables not passing...
Is there a session_start() on the second page ? Also i didnt know u could set an action to a jscript popup, it may not be posting to the second page. What you could try is posting to the second page like a normal post, u need to do something like session_start(); $_SESSION['startdate'] = $_POST['startdate']; $_SESSION['stopdate'] = $_POST['stopdate']; in the second page u only need this if u are then redirecting to yet another page else just do a h1 align=centerstrongReports received between ?php echo .$_POST['startdate'].; ? and ?php echo $_POST['stopdate']; ? :/strong/h1 something like that Okay, I am sure this will be painfully simple, but I have looked it over for a couple of hours now, and I am obviously missing something. I am trying to get a start date and a stop date via input from a user to use as variables in a MySQL query, but for some reason, I can't get the variable to pass from one page to the next... Will one of you masters help me find my goof? First page has the following at the top of the code: ?php session_start(); $_SESSION['startdate'] = $startdate; $_SESSION['stopdate'] = $stopdate; ? Then I am getting the data entry in the following form code: form name=viewbydate method=post action=javascript:popUp('viewbydate.php') li All reports from one date to another: Start input name=startdate type=text size=15 maxlength=30 Stop input name=stopdate type=text size=15 maxlength=30 input name=button2 type=submit value=GO /form The second page starts by displaying this info: h1 align=centerstrongReports received between ?php echo $startdate; ? and ?php echo $stopdate; ?:/strong/h1 The regular text displays, but there is just white space where the $startdate and $stopdate should be. Thanks in Advance!! Chase -- 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] Variables not passing...
Thank you! It looks like it was a combination of my NOT using the $_POST and the fact that my JScript wasn't allowing the variables to pass... WHO KNEW?!? THANKS!!! Chase [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Is there a session_start() on the second page ? Also i didnt know u could set an action to a jscript popup, it may not be posting to the second page. What you could try is posting to the second page like a normal post, u need to do something like session_start(); $_SESSION['startdate'] = $_POST['startdate']; $_SESSION['stopdate'] = $_POST['stopdate']; in the second page u only need this if u are then redirecting to yet another page else just do a h1 align=centerstrongReports received between ?php echo .$_POST['startdate'].; ? and ?php echo $_POST['stopdate']; ? :/strong/h1 something like that Okay, I am sure this will be painfully simple, but I have looked it over for a couple of hours now, and I am obviously missing something. I am trying to get a start date and a stop date via input from a user to use as variables in a MySQL query, but for some reason, I can't get the variable to pass from one page to the next... Will one of you masters help me find my goof? First page has the following at the top of the code: ?php session_start(); $_SESSION['startdate'] = $startdate; $_SESSION['stopdate'] = $stopdate; ? Then I am getting the data entry in the following form code: form name=viewbydate method=post action=javascript:popUp('viewbydate.php') li All reports from one date to another: Start input name=startdate type=text size=15 maxlength=30 Stop input name=stopdate type=text size=15 maxlength=30 input name=button2 type=submit value=GO /form The second page starts by displaying this info: h1 align=centerstrongReports received between ?php echo $startdate; ? and ?php echo $stopdate; ?:/strong/h1 The regular text displays, but there is just white space where the $startdate and $stopdate should be. Thanks in Advance!! Chase -- 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] Variables not passing...
One other irritation for the evening... The MySQL query that I am trying to create needs to use the date the user enters and then add @ 12:01am EST to it so it will acutally match the data in the table. Below is my quesry line, but I don't know how to add that chunk to each of the variables... $result = mysql_query(SELECT * FROM $table WHERE 'submit_date' = '$startdate' AND 'submit_date' = '$stopdate' ORDER BY 'submit_date' DESC, $link); [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Is there a session_start() on the second page ? Also i didnt know u could set an action to a jscript popup, it may not be posting to the second page. What you could try is posting to the second page like a normal post, u need to do something like session_start(); $_SESSION['startdate'] = $_POST['startdate']; $_SESSION['stopdate'] = $_POST['stopdate']; in the second page u only need this if u are then redirecting to yet another page else just do a h1 align=centerstrongReports received between ?php echo .$_POST['startdate'].; ? and ?php echo $_POST['stopdate']; ? :/strong/h1 something like that Okay, I am sure this will be painfully simple, but I have looked it over for a couple of hours now, and I am obviously missing something. I am trying to get a start date and a stop date via input from a user to use as variables in a MySQL query, but for some reason, I can't get the variable to pass from one page to the next... Will one of you masters help me find my goof? First page has the following at the top of the code: ?php session_start(); $_SESSION['startdate'] = $startdate; $_SESSION['stopdate'] = $stopdate; ? Then I am getting the data entry in the following form code: form name=viewbydate method=post action=javascript:popUp('viewbydate.php') li All reports from one date to another: Start input name=startdate type=text size=15 maxlength=30 Stop input name=stopdate type=text size=15 maxlength=30 input name=button2 type=submit value=GO /form The second page starts by displaying this info: h1 align=centerstrongReports received between ?php echo $startdate; ? and ?php echo $stopdate; ?:/strong/h1 The regular text displays, but there is just white space where the $startdate and $stopdate should be. Thanks in Advance!! Chase -- 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] variables
Escape it. $string = \\; Or, use single quotes: $string = '\'; On Thu, 2004-02-19 at 12:49, Dominique ANOKRE wrote: hello, how can i put the character \ in a variable ? I've done the code below but errors occurs : $barre_oblique = \; Parse error: parse error, unexpected T_STRING Please help -- Adam Voigt [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] variables
Whoops, mistyped on my reply, you need to escape it with the single quotes to. On Thu, 2004-02-19 at 12:49, Dominique ANOKRE wrote: hello, how can i put the character \ in a variable ? I've done the code below but errors occurs : $barre_oblique = \; Parse error: parse error, unexpected T_STRING Please help -- Adam Voigt [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] variables
Hello Dominique, Thursday, February 19, 2004, 5:49:43 PM, you wrote: DA how can i put the character \ in a variable ? DA I've done the code below but errors occurs : DA $barre_oblique = \; DA Parse error: parse error, unexpected T_STRING DA Please help $barre_oblique = \\; -- Best regards, Richard Davey http://www.phpcommunity.org/wiki/296.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] variables
ok thanks pb solved thank you everybody - Original Message - From: Richard Davey [EMAIL PROTECTED] To: Dominique ANOKRE [EMAIL PROTECTED] Cc: Php List [EMAIL PROTECTED] Sent: Thursday, February 19, 2004 5:52 PM Subject: Re: [PHP] variables Hello Dominique, Thursday, February 19, 2004, 5:49:43 PM, you wrote: DA how can i put the character \ in a variable ? DA I've done the code below but errors occurs : DA $barre_oblique = \; DA Parse error: parse error, unexpected T_STRING DA Please help $barre_oblique = \\; -- Best regards, Richard Davey http://www.phpcommunity.org/wiki/296.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Variables??
give the corresponding source code are you using POST or GET ? What about REGISTER_GLOBALS ??? PS : NO MAILS IN HTML ON THE LIST, PLEASE -Message d'origine- De : Alessandro Rodiani [mailto:[EMAIL PROTECTED] Envoyé : dimanche 15 février 2004 21:29 À : [EMAIL PROTECTED]; [EMAIL PROTECTED] Objet : [PHP] Variables?? I have a problem. When I call the function phpinfo() I can correctly see the page with the information about the server; but when I use a form to pass some information from a php page to another php page, if I use a print() or an echo() function, I can't see my variables. Why??? Help me please Thank Alessandro ___ IncrediMail - il mondo della posta elettronica si è finalmente evoluto - Clicca Qui -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables not working!
Try this for a generic fix if it is the globals issue: Place this somewhere to set to TRUE or FALSE when needed $GLOBAL_FIX = TRUE; use an include on every script: if($GLOBAL_VARS_FIX) { if( phpversion() = '4.2.0' ) { extract($_POST); extract($_GET); extract($_SERVER); extract($_ENV); extract($_COOKIE); } } --- Alvaro Zuniga Information Technology Professional (337) 654 6515 www.zunitek.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables not working!
On 19 Jan 2004 at 21:43, Kaushan wrote: Hi, I am new to PHP scripting and struggling with the following problem. I have two files, an HTML file and a PHP file. HTML file contains a form with one text field and a submit button. When a user pressed the submit button, it calls the php file (form action=test.php ...). What the php file does is just echo back the text received from html file to the user again. Name of the text field is 'fname'. When I used this variable in the php file (as $fname) it does not contain the value of the text field. Query-string appended to the url during the submission is also correct. I checked for all syntax errors, but the codings are perfect. Do I have to change php.ini file to fix this problem. Could anyone can help me to solve this problem. Kaushan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hi Kaushan Little bit difficult without seeing the code, but what you are probably sitting with is an issue with globals - depending on your method of submitting (GET or POST)you can try and check one of these two $_POST['fname'] or $_GET['fname'] for the value of the text field. Rory McKinley Nebula Solutions +27 82 857 2391 [EMAIL PROTECTED] There are 10 kinds of people in this world, those who understand binary and those who don't (Unknown) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Variables not working!
It is most likely globals. Access the variables by... echo $_GET['fname']; or $_POST['fname']; if you are using post which it doesn't appear you do. Larry PS it is adviseable to leave globals alone in php.ini since it is set that way for security concerns. -Original Message- From: Kaushan [mailto:[EMAIL PROTECTED] Sent: Monday, January 19, 2004 10:44 AM To: [EMAIL PROTECTED] Subject: [PHP] Variables not working! Hi, I am new to PHP scripting and struggling with the following problem. I have two files, an HTML file and a PHP file. HTML file contains a form with one text field and a submit button. When a user pressed the submit button, it calls the php file (form action=test.php ...). What the php file does is just echo back the text received from html file to the user again. Name of the text field is 'fname'. When I used this variable in the php file (as $fname) it does not contain the value of the text field. Query-string appended to the url during the submission is also correct. I checked for all syntax errors, but the codings are perfect. Do I have to change php.ini file to fix this problem. Could anyone can help me to solve this problem. Kaushan -- 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] Variables
Hello Alex, Thursday, January 15, 2004, 9:47:27 PM, you wrote: AH How do you insert a php variable into a javascript function? AH function redirect(?php $MyVar ?) { location = ?php $MyVar ?; } function redirect (?=$MyVar?) { location = ?=$MyVar?; } -- Best regards, Richardmailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables
AH How do you insert a php variable into a javascript function? AH function redirect(?php $MyVar ?) { location = ?php $MyVar ?; } function redirect (?=$MyVar?) { location = ?=$MyVar?; } or use: function redirect (?php echo $MyVar; ?) { location = ?php echo MyVar; ?; } The short syntax only works with short_open_tag enabled in php.ini or with ini_set(). -Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables
AH How do you insert a php variable into a javascript function? AH function redirect(?php $MyVar ?) { location = ?php $MyVar ?; } function redirect (?=$MyVar?) { location = ?=$MyVar?; } or use: function redirect (?php echo $MyVar; ?) { location = ?php echo MyVar; ?; } The short syntax only works with short_open_tag enabled in php.ini or with ini_set(). -Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables
AH How do you insert a php variable into a javascript function? AH function redirect(?php $MyVar ?) { location = ?php $MyVar ?; } function redirect (?=$MyVar?) { location = ?=$MyVar?; } or use: function redirect (?php echo $MyVar; ?) { location = ?php echo MyVar; ?; } The short syntax only works with short_open_tag enabled in php.ini or with ini_set(). -Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables
On Thu, 2004-01-15 at 16:47, Alex Hogan wrote: How do you insert a php variable into a javascript function? For instance; function redirect(?php $MyVar ?) { location = ?php $MyVar ?; } ?php echo 'function redirect(' . $MyVar . ') {'; echo 'location =' . $MyVar . ';}'; ? -- BrianGnuPG - KeyID: 0x04A4F0DC | URL: www.gfx-design.com/keys Key Server: pgp.mit.edu == gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC GnuPG: http://gnupg.org http://www.biglumber.com/x/web?qs=0x2C35011004A4F0DC Linux Registered User #339825 at http://counter.li.org signature.asc Description: This is a digitally signed message part
[PHP] Re: PHP Variables
Hi Lloyd, use quotes around your values echo input type=\text\ name=\question1_text\ value=\$question\br /; Regards, Greg -- phpDocumentor http://www.phpdoc.org Lloyd Bayley wrote: Greetings All, Have a small problem that I just can't work out. I know it's an easy one but it's got me stumped... I have some code to pull a question out of a database and display it on the screen. I also want to store it in a hidden var for use with the $_POST on the next page. Currently, the display bit works fine. The only problem is the hidden var only has the first word of the question in itand I'm setting it from the same var!!! Eg. If the question is: What is the problem with this stupid thing? The hidden var will contain: What What am I missing? Why has the rest of the question packed it's things and moved out??? Code Snippet while ($newarray = mysql_fetch_array($result)) { $qid = $newarray['qid']; $question = $newarray['question_text']; echo brfont face = Verdanab$question/b/fontbr; --- This works perfectly. echo input type=text name=question1_text value=$questionbr; This returns first word. Many Thanks In Advance, Lloyd. :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP Variables
Greg, Sheesh! I had neglected to do that...I've been working with a few different languages and I'm starting to confuse them I think. Thanks for your non-offensive reply. It's nice to see that you can overlook the little failures we have now and again. Lloyd. :-) At 09:58 AM 7/12/2003, you wrote: Hi Lloyd, use quotes around your values echo input type=\text\ name=\question1_text\ value=\$question\br /; Regards, Greg -- phpDocumentor http://www.phpdoc.org Lloyd Bayley wrote: Greetings All, Have a small problem that I just can't work out. I know it's an easy one but it's got me stumped... I have some code to pull a question out of a database and display it on the screen. I also want to store it in a hidden var for use with the $_POST on the next page. Currently, the display bit works fine. The only problem is the hidden var only has the first word of the question in itand I'm setting it from the same var!!! Eg. If the question is: What is the problem with this stupid thing? The hidden var will contain: What What am I missing? Why has the rest of the question packed it's things and moved out??? Code Snippet while ($newarray = mysql_fetch_array($result)) { $qid = $newarray['qid']; $question = $newarray['question_text']; echo brfont face = Verdanab$question/b/fontbr; --- This works perfectly. echo input type=text name=question1_text value=$questionbr; This returns first word. Many Thanks In Advance, Lloyd. :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP Variables
Lloyd Bayley wrote: Thanks for your non-offensive reply. It's nice to see that you can overlook the little failures we have now and again. Please learn HTML is offensive? Please... I even gave you the _correct_ answer that involves htmlentities(), otherwise you'll be back here with another question when your $question has a double quote within it. -- ---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] Re: PHP Variables
John W. Holmes wrote: Lloyd Bayley wrote: Thanks for your non-offensive reply. It's nice to see that you can overlook the little failures we have now and again. Please learn HTML is offensive? Please... I even gave you the _correct_ answer that involves htmlentities(), otherwise you'll be back here with another question when your $question has a double quote within it. You big meanie. -- By-Tor.com It's all about the Rush http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Variables scope question
This doesn't sound right. It's doesn't behave like this for me. Can you supply an example? Martin -Original Message- From: Mike D [mailto:[EMAIL PROTECTED] Sent: Thursday, 4 December 2003 10:35 AM To: PHP General list Subject: [PHP] Variables scope question Hello, I have recently noticed something that I wasn't aware of until now. I have index.php which contains include1.txt and include2.txt. If a variable is set in include1.txt it will *only* have a local scope, even if I declare it GLOBAL. Is this normal or a bug? - MD Mike Dunlop AWN, Inc. // www.awn.com [ e ] [EMAIL PROTECTED] [ p ] 323.606.4237 -- 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] Variables scope question
NEVERMIND - some user error there... (happens once in a while) It's been a long day ;-) Thanks - MD On 12/3/03 3:36 PM, Martin Towell [EMAIL PROTECTED] wrote: This doesn't sound right. It's doesn't behave like this for me. Can you supply an example? Martin -Original Message- From: Mike D [mailto:[EMAIL PROTECTED] Sent: Thursday, 4 December 2003 10:35 AM To: PHP General list Subject: [PHP] Variables scope question Hello, I have recently noticed something that I wasn't aware of until now. I have index.php which contains include1.txt and include2.txt. If a variable is set in include1.txt it will *only* have a local scope, even if I declare it GLOBAL. Is this normal or a bug? - MD Mike Dunlop AWN, Inc. // www.awn.com [ e ] [EMAIL PROTECTED] [ p ] 323.606.4237 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Mike Dunlop AWN, Inc. // www.awn.com [ e ] [EMAIL PROTECTED] [ p ] 323.606.4237 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables - showing onpage
On Sunday 30 November 2003 15:54, Biph wrote: I have a question, and maybe I'm an idiot (alright not maybe). I can't get the damned variables to stop showing their variable names on the screen, like a variable $stock_quote appears in the HTML as $stock_quote, what the hell am I doing wrong? I'm using Win2K to test a site on my own computer using Apache2, but all variables from MySQL to PHP are just showing up as the variable name and not the value in the HTML.Any help would be nice. example: ?php $price = 1.00 print('the price is: $price') ? is apprearing as: the price is $price in the HTML instead of: the price is 1.00 manual Chapter 7 Strings -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* I had the rare misfortune of being one of the first people to try and implement a PL/1 compiler. -- T. Cheatham */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Variables - showing onpage
You have to put it between double quotes. Jeroen -- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end. (Henry Spencer) Politics.be op imode! http://i.politics.be/ -Original Message- From: Biph [mailto:[EMAIL PROTECTED] Sent: Sunday, November 30, 2003 8:54 AM To: [EMAIL PROTECTED] Subject: [PHP] Variables - showing onpage I have a question, and maybe I'm an idiot (alright not maybe). I can't get the damned variables to stop showing their variable names on the screen, like a variable $stock_quote appears in the HTML as $stock_quote, what the hell am I doing wrong? I'm using Win2K to test a site on my own computer using Apache2, but all variables from MySQL to PHP are just showing up as the variable name and not the value in the HTML.Any help would be nice. example: ?php $price = 1.00 print('the price is: $price') ? is apprearing as: the price is $price in the HTML instead of: the price is 1.00 -- 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