
mrherman
Members-
Posts
158 -
Joined
-
Last visited
Everything posted by mrherman
-
Conceptually stuck: passing array as function parameter
mrherman replied to mrherman's topic in PHP Coding Help
YESSSS!!! That was it!! Thanks for this information. Now everything works! Happy, happy!! -
Conceptually stuck: passing array as function parameter
mrherman replied to mrherman's topic in PHP Coding Help
Thanks, guys! Extract() is not working because the array contains various functions. When the array is extract-ed, it echos back the function calls, not the values that they should derive. For example, after extract(), the values are: function trace_log( $a_log ) { if (is_array($a_log)) { extract($a_log); } echo $file . "<br />"; echo $script . "<br />"; echo $func . "<br />"; echo $line . "<br />"; echo $var_name . "<br />"; echo $var_value . "<br />"; ........ Prints out: Notice: Undefined variable: file in E:\Web\HTDOCS\Learnweb\Register_login\includes\inc_functions.php on line 75 script_name() __FUNCTION__ __LINE__ var_name() var_value() As for serialize(), I'm not clear as to how that would be helpful. -
I've spent a lot of time on this, thinking I could figure it out, but I'm royally stuck. I have a "debugging" helper function that I call when I need to know what is happening to a variable. The results of the call are inserted into a table, which I then review for problems. Here is an earlier version of my function call to "trace_log()." It worked fine. trace_log( file_name(__FILE__), script_name(), __FUNCTION__, __LINE__, var_name(), var_value()); Now I want to put the function call parameters into an array. Here is my code: $myarray = array( 'myfile' => 'file_name(__FILE__)', 'script' => 'script_name()', 'func' => '__FUNCTION__', 'line' => '__LINE__', 'var_name' => 'var_name()', 'var_value' => 'var_value()' ); Note that script_name(), var_name(), and var_value() are user defined functions. Now, I am trying to make the parameters in $myarray work within the function, but I have not been successful. Here is how I think the code should begin: function trace_log( $myarray ) { /* Connect to db */ if( is_array( $myarray ) ) { foreach( $myarray as $k => $v ) { ... !!!!! CAN'T GET PAST THIS POINT !!!!! Here is the code I use in the function "trace_log()" to insert the items into a table: $sql = "INSERT INTO reg_log_trace( step, file, script, func, line, var_name, var_value ) VALUES ( 0,'{$file}','{$script}','{$func}', {$line}, '{$var_name}', '{$var_value}' )"; How can I resolve this? Thanks for the help!
-
How to place function parameters list in a variable for tidiness??
mrherman replied to mrherman's topic in PHP Coding Help
Thanks! That's what I was thinking, but I wanted to make sure. -
Hi -- I have a debugging function that called like this trace_log( file_name(__FILE__), script_name(), __FUNCTION__, __LINE__, var_name(), var_value()); As I use it many times within a script, is there a way to group the parameters in a variable or constant in order to make the line of code less cumbersome? I know the following won't work, but to give an example of what I mean: $paramList= "file_name(__FILE__), script_name(), __FUNCTION__, __LINE__, var_name(), var_value()"; trace_log( $paramList ); Thanks!
-
Problem with < form action href ... PHP variable not working
mrherman replied to mrherman's topic in PHP Coding Help
Well, actually, in reality I'm not. See, none of my "variable links" were working -- form, redirection, etc. -- and I couldn't figure it out. So, to illustrate my error on the forum, I just copied and posted a link, which happened to be a reference to the CSS file. I didn't even notice that I had done this. Good catch! -
Problem with < form action href ... PHP variable not working
mrherman replied to mrherman's topic in PHP Coding Help
Well, thank you very much! I tried everything BUT that! -
This works: form action="http://localhost/mysite/css/screen.css" method="post"> This does not work: <?php $link_1 = "http://localhost/mysite/css/screen.css" ; $link_2 = '"' . "http://localhost/mysite/css/screen.css" .'"' ; ?> <form action=<?php echo $link_1;?> method="post"> <form action=<?php echo $link_2;?> method="post"> Why do neither of the PHP variables work? Thanks!
-
Where did the term "T_STRING" originate for PHP?
mrherman replied to mrherman's topic in Miscellaneous
Every time I see it on the screen, there is an error. So, to me it means Trouble. -
Where did the term "T_STRING" originate for PHP?
mrherman replied to mrherman's topic in Miscellaneous
Ah, so it stands for token. Thanks for the pointer. I read some more about this (http://en.wikipedia.org/wiki/Lexical_analysis) and it is a pretty complicated subject. -
Just curious. Why the term "T_STRING?" Looked it up, but all I could find was that it is a very small pair of underwear.
-
Thank you, requinix!
-
Hello -- Other than organizational clarity for the developer, is there a particular advantage (e.g., security, file access speed, etc.) for placing web files (php, css, html, etc.) in various folders and sub-folders vs placing all files in the root directory or in one particular folder? Thanks.
-
Yes, I meant the variable name. Thanks for the answer.
-
I did a phpfreaks search for this, but didn't find anything specific. How can I echo out an array name? I have a function to return the array contents (for debugging purposes), and I need it to generate the actual name of the array as well. Thanks!
-
Thanks for the reply. Yeah, the index.php was in the correct folder, but I finally discovered the problem! In the Apache folder, the "httpd.conf" file did not contain "index.php" in the dir_module (about line number 244): # # DirectoryIndex: sets the file that Apache will serve if a directory # is requested. # <IfModule dir_module> DirectoryIndex index.html index.php (<-- I added) </IfModule> Thanks again!
-
I've installed Drupal 7.1 on my computer and I'm trying to access it via localhost. However, the site does not load the "index.php" file. Instead, I get the list of files and folders in the working directory with the heading "Index of /drupal71" (drupal71 is the temporary site name). The .htaccess file has the following lines, so I'm confused as to why index.php doesn't load automatically. # Set the default handler. DirectoryIndex index.php index.html index.htm Any suggestions?
-
Tool to display the localhost website files that have been accessed
mrherman replied to mrherman's topic in PHP Coding Help
Gah! I have it installed, but I didn't know it would do that! Thanks very much for pointing that out!! -
I'm working with a downloaded open-source CMS on localhost, and trying to learn. Is there a tool that will list the files (php and otherwise) that are accessed (in order) as the CMS does various normal operations? I want to see the order and the repetition of files that are opened, even if it is something minor. Thanks.
-
Get a list of unique variables from a script
mrherman replied to mrherman's topic in PHP Coding Help
Man, that was fast!! Thanks, fellas! -
I have a long PHP script that I didn't write. I'd like to get a simple text list of all the unique variables from the script -- all variables within the script that begin with $, such as $_ADMIN $query $category $user $id $result, etc..... Any ideas how a PHP dabbler can go about this? I did a PHPFreaks search, but didn't find a thread on this. Thank you!
-
Well, that was simple enough. I thought subqueries were always in the WHERE clause. But I looked it up and you are right. Very helpful. Thanks!
-
Hi -- I'd like to ask about the SQL statement below, which is something that I didn't know about: the second SELECT, after the FROM phrase. My question is, what is this called? Is it a NESTED SELECT, a SUB-SELECT, an EMBEDED SELECT, or what? I want to read more on this type of statement, but don't know how to classify it. Thanks! SELECT t.* FROM table1 t, ( SELECT id FROM table1 ORDER BY id DESC LIMIT 5,1 ) as x WHERE t.id <= x.id ORDER BY RAND() LIMIT 3
-
Sending error message back to user who omitted fields in login form
mrherman replied to mrherman's topic in PHP Coding Help
Thank you, Pikachu2000...but doesn't your byline suggest that this is bad? -
Sending error message back to user who omitted fields in login form
mrherman replied to mrherman's topic in PHP Coding Help
Well, thank you both. Those simple facts and the code help quite a bit!!