Jump to content

mmtalon

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Posts posted by mmtalon

  1. First, I don't know if the code example is deprecated because of a later version of the document object model (DOM). Or, perhaps, the code is designed for a later version of DOM, where PHP 4.3.x won't support the newer version of DOM. I was hoping that someone would recognize the code as being to old or not new enough.

    I thought that the PHP server is what translate the javascript to the client computer and that the PHP server would ultimately be the problem. Do correct me if I am wrong on how javascript reaches the client computer.
  2. I read the two mulitdimensional post below, however I could not draw a conclusion from them.
    [url=http://www.phpfreaks.com/forums/index.php/topic,119312.msg488542.html#msg488542
    http://www.phpfreaks.com/forums/index.php/topic,119312.0.html]
    http://www.phpfreaks.com/forums/index.php/topic,119312.msg488542.html#msg488542
    http://www.phpfreaks.com/forums/index.php/topic,119312.0.html
    [/url]
    I varified that the array is being stored properly by a session dump:

    [code]
    foreach ( $_SESSION as $key => $key_value )

    { print "<li> $key = $key_value\n"; }
    [/code]

    dump result: X = Array - Where X is the name of my array($count).

    An example of my code is below. I tried to retrieving the array using the two foreach construct below. I must be doing something wrong. Please help.

    [code]
    session_start();

    $_SESSION['count']; // tried session var init here
    $_SESSION['count'] = array(); // tried session array init here

    $v[0] = 489; $v[1] = 883; $v[2]= 350; $v[3] = 555;

    for ($counter=0; $counter < 4; $counter++)
    { $count[$counter] = $v[$counter]; }

    // this code result in successful output
    echo "count_0: " . $count[0];
    echo "<p>count_1: $count[1]\n\r</p>";
    echo "<p>count_2: $count[2]\n\r</p>";
    echo "<p>count_3: $count[3]\n\r</p>";

    $trans = $_SESSION['count'];

    // no extraction results from the following code:
    foreach ($trans[] as $key => $value )
    { echo "<p> $key = $value\n</p>"; }

    foreach($_SESSION['count'][] as $var) {
    echo "this is a new count:". $var;
    }

    [/code]
  3. fert, I am still testing and you have gave me something to think about. At the same time I am looking at the created variable or function "$x('y');" as some kind of place holder. However, I better think twice about my testing after seeing your code you posted above. Does your book tell you explicitly what the code is doing?

    Thanks fert for the warnning and your input. I'll post whatever I find out if I thank it is helpful.

    Hi there MCP.

    $a("Alice") becomes myNameFunc("Alice") becomes "Bill and Alice" does seem to become one in the same. So it being call an expression might be the same as calling it a place holder(perhaps). I'm kind of clear on what it does and therefore I can make a decision if I should use it for the best results. I will check back periodically to see if anyone has any more info regarding this particular code.

    Thank again KingPhilip, MCP and fert for all the help.



  4. MCP, I'm still testing this out. I'm trying to figure out if "$a()" is a function, function-variable, a pointer or what. And what about the result from - $a("Bill");? I'm sure that I am barking up the right tree with you and KingPhilip's help. Thank.

    fert, I agree with you regarding how PHP use pointers for variables. And this is the same way that C++ use variable pointers. However, C and C++ use arrays and function pointers somewhat differently, at lease this is what I think. I am still a novice when it come to PHP or C and C++.
  5. MCP,

    This makes a lot of sense and possibly ties into my pointer theory. Thank you for pointing this snippet of code out to me, no pun intended.

    [quote]Note that the same works for variable names:

    Code:
    $a = "b";
    $b = "Bob";
    print $$a;
    will print "Bob", since the "$a" will evaluate to "b", and then the "$b" will evaluate to "Bob". Try it!

    Same works with functions:

    Code:
    $a = "myNameFunc";
    function myNameFunc($name){
      return "Bill and $name";
    }
    echo $a("Alice");
    will print out "Bill and Alice"[/quote]
  6. Thank you for your help KingPhilip.

    [quote]Okay, are you wanting to make functionName a function or a variable?

    because right now you have it set as a variable, but then checks to see if it is a function. [/quote]

    Is "$functionName" setup as a variable? If I can recall playing around with C++, this code could be acting as a pointer to the beginning of the function and copying another function to create a duplicate. Nevertheless, I never seen a function called using a pointer and parameters. I could be totally off base here, and that is why I am asking. But I am assuming that the developers are creating a function and is using function_exists call as an error handler.

    This is not the only time I have seen this code being used. I got the code example that I posted from the Xinha site [url=http://(http://xinha.python-hosting.com/changeset/622?format=diff)](http://xinha.python-hosting.com/changeset/622?format=diff)[/url], the HTML open source editor.

    Here's another example below that came from Drupal Developers [url=http://(http://cvs.drupal.org/viewcvs/drupal/contributions/sandbox/jareyero/image/image.gd2.inc?rev=1.2)](http://cvs.drupal.org/viewcvs/drupal/contributions/sandbox/jareyero/image/image.gd2.inc?rev=1.2)[/url], the web-based content management system. This example was not part of a class, however, it's using the same concept.

    [code] // Check image type
     $image_details = _get_image_details($imagename);
     $function = 'imageCreateFrom'.$image_details['type'];
     if (function_exists($function))  {
       $im = $function($imagename);
    [/code]

    Please do reply, KingPhilip, if you have the time, especially if I'm wrong about the pointer assumption. Thank you again for your consideration.

    P.S. I just read MCP's Post before posting this reply.

    [quote]What the class is aiming to do is avoid from having to hardcode all the different functions for all the different image types supported.[/quote]

    [quote]The $functionName($this->image) statement is perfectly valid. it will evaluate $functionName to, as in the running example, ImageCreateFromJPEG, which will then turn the actual function call into ImageCreateFromJPEG($this->image).
    [/quote]

    I will research this further because I am still in doubt regarding thoughts about this as mentioned above. So MCP, if you read this, please don't hesitate to respond.

    Thank you all so much for your time and clearification.



  7. I need help with understanding the following PHP code:

    [color=red][b]$functionName = 'ImageCreateFrom' . $this->type;[/b][/color]

    The code is part of a class function. A copy of the function is below and the code in question is above highlighted in red and bold.

    After this assignment, the code checks to see if a function "$functionName" exist and later assigns a class variable with the value of the "$functionName(class var)" function call.

    The dollar sign in front of the function seems strange to me.

    Q. can you create a function in this manner?

    Please help me understand and tell me where I can go to get more information with this code assignment.

    Thanks All.
    [code]
    function load($image)
        {
            $this->uid = md5($_SERVER['REMOTE_ADDR']);
            $this->image = $image;
            $this->_get_image_details($image);
            $functionName = 'ImageCreateFrom' . $this->type;

    if(function_exists($functionName))
    {
    $this->imageHandle = $functionName($this->image);
    }
        } // End load

    [/code]

  8. [!--quoteo(post=366513:date=Apr 19 2006, 12:41 PM:name=mmtalon)--][div class=\'quotetop\']QUOTE(mmtalon @ Apr 19 2006, 12:41 PM) [snapback]366513[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    Thanks for the replies wisewood and poirot. I have checked the session id, which is spitting out the same id. I was thinking maybe I had missed some setting of some kind - e.g. php.ini etc. or maybe it's my ISP.

    Tell me if I could be overlooking something. Also if you create your own sessions, how often do you use them and are they hard to construct?

    Again, thanks a lot for your help.
    [/quote]
    I found out that I am overlooking something. It has something to do with my code and how it's structured. I know this after testing with 2 files that I created having just the essentials. The stripped down code worked and let me know that the problem is within my code somewhere.

    Thanks for all the input.
  9. [!--quoteo(post=366445:date=Apr 19 2006, 10:00 AM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Apr 19 2006, 10:00 AM) [snapback]366445[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    No, that's not un-necessary. That will propagate the session ID if the user disables cookies.

    If it's outputting the same session id, I have really no idea on whats wrong.
    [/quote]
    Thanks for the replies wisewood and poirot. I have checked the session id, which is spitting out the same id. I was thinking maybe I had missed some setting of some kind - e.g. php.ini etc. or maybe it's my ISP.

    Tell me if I could be overlooking something. Also if you create your own sessions, how often do you use them and are they hard to construct?

    Again, thanks a lot for your help.
  10. Can't share SESSION variables. I need some help!

    Don't understand why this isn't working. Perhaps it is because I have the 2 files in 2 different directories? My register_globals is Off

    Code example:

    <?php
    session_start();
    // page1.php
    $_SESSION['grncolor'] = 'green';
    echo $_SESSION['grncolor']; // output works here
    echo session_id(); // outputs session_id
    // passing the session id - also tried absolute path with same results
    echo '<br /><a href=\"../AA_dir/page2.php?' . SID . '\">page 2</a>';
    ?>

    <?php
    session_start();
    // page2.php
    //tried if(isset($_SESSION['grncolor'])) { negative }
    echo $_SESSION['grncolor']; // green - will not output a value
    echo session_id(); // outputs same session_id as in page1.php
    echo '<br /><a href="../BB_dir/page1.php">page 1</a>';
    ?>
  11. Does anyone have an idea how the variable "$MM_donotCheckaccess" in Dreamweaver's authentication restriction code is used, the when, where, why and how it's used. I am sure you have seen the code many times over. However, here it is again (below) with the variable in question at the fourth line. FYI, I am using DW 2K4MX.

    P.S. This question is of utmost importance because I'm banging my head out of pure curiosity to know, so please help before curiosity kills the cat!!

    Thank you in advance.

    Here's the all so common code:

    <?php
    session_start();
    $MM_authorizedUsers = "Sellers,builders,agents";
    $MM_donotCheckaccess = "true";

    // *** Restrict Access To Page: Grant or deny access to this page
    function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
    // For security, start by assuming the visitor is NOT authorized.
    $isValid = False;

    // When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
    // Therefore, we know that a user is NOT logged in if that Session variable is blank.
    if (!empty($UserName)) {
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
    // Parse the strings into arrays.
    $arrUsers = Explode(",", $strUsers);
    $arrGroups = Explode(",", $strGroups);
    if (in_array($UserName, $arrUsers)) {
    $isValid = true;
    }
    // Or, you may restrict access to only certain users based on their username.
    if (in_array($UserGroup, $arrGroups)) {
    $isValid = true;
    }
    if (($strUsers == "") && true) {
    $isValid = true;
    }
    }
    return $isValid;
    }

    $MM_restrictGoTo = "myaccount.php";
    if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
    $MM_qsChar = "?";
    $MM_referrer = $_SERVER['PHP_SELF'];
    if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
    if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
    $MM_referrer .= "?" . $QUERY_STRING;
    $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
    header("Location: ". $MM_restrictGoTo);
    exit;
    }
    ?>
  12. MySQL syntax help "grave accent" !!!

    I was attemping to insert the $keys/values below into MySQL DB after including the latitude and longitude. Here are values ('37.833526' , '-122.27078'), respectively.

    code example:

    / *** Set $long_keys and $long_values *** /

    $long_keys = "(h_features,c_features,lat,long,dateposted,";
    $long_values = " values ('$h_features','$c_features','$latitude','$longitude','$mysql_date'," ;

    I continued to get the error message "You have an error in your SQL syntax;".

    NOW, I was banging my head against a wall trying anything I could find to make this work, addslashes-real escapes-dbl and single quotes(with/without periods). Everything seemed to fail, until I remembered seeing some INSERT INTO code using the grave accent. To my surprise, this worked when I tried it.

    E.g. ($long_keys = "(h_features,c_features,`lat`,`long`,dateposted,";)

    By running some test, I know that the purpose of the accents has something to do with escaping the hyphen in the longitude value.

    Unsuccessfully, I have searched to find information on how PHP or MySQL is parsing this code. I was wonder if anyone has a clue to where I can get more information regarding the use of the "grave accent" punctuation in relation to PHP and MySQL??? I also welcome any knowledge that you have on this subject.

    Thank you in advance for your consideration and any input that you offer.

    Enquiry mind wants to know,

    mmtalon
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.