PHP session variables and MySQL

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default Re: PHP session variables and MySQL

    I answered this from the news reader many hours ago, but it seems to have been
    swallowed up by the system. Your problem lies with the quotes in
    $_SESSION['validuser']. What's happening is that the first single quote inside
    the square brackets is matching the single quote just before $_SESSION, turning
    the rest of the string into unidentified data. There are several ways around
    this. The first is to remove the quotes inside the square brackets:
    $query_memberviewquery = 'SELECT * FROM artistmembers WHERE email
    ='$_SESSION[validuser]' ORDER BY membername ASC'; This is acceptable, but may
    cause a warning notice (depending on the level of error reporting). The better
    way is as follows: $query_memberviewquery = 'SELECT * FROM artistmembers WHERE
    email =''.$_SESSION['validuser'].'' ORDER BY membername ASC'; What this does
    is to build the query from three elements: the first part of the query as a
    string, followed by the session variable, and finally, the last part, again as
    a the string. -- David Powers Author, 'Foundation PHP 5 for Flash' (friends
    of ED) Co-author 'PHP Web Development with DW MX 2004' (Apress)
    [url]http://computerbookshelf.com[/url]

    jface Guest

  2. Similar Questions and Discussions

    1. #39833 [NEW]: Session variables overwritten by local variables (register_globals=off)
      From: sup1382 at accedo dot es Operating system: OpenBSD 3.9 PHP version: 5.2.0 PHP Bug Type: Session related Bug...
    2. #39447 [NEW]: Want to optionally handle apc_upload_progress variables using session variables
      From: krudtaa at yahoo dot com Operating system: All PHP version: 5.2.0 PHP Bug Type: Feature/Change Request Bug...
    3. MySQL/PHP problem. getting field names from MySQL and using it asPHP variables
      Is this possible? I'd like to just get the field names from my database and use it as variables to save me from making errors as to where i should...
    4. MySQL and PHP Session Variables
      The following 3 mysql/php statements are used in my home page to access my admin table: $php_linkID = mysql_pconnect("localhost","user","pw");...
    5. Session problem when setting session variables in files that are in different directories
      I am running PHP 4.3.0 on a WinXPpro machine and I recently got problem with sessions. What I am building is a loginsystem and I need to save...
  3. #2

    Default Re: PHP session variables and MySQL

    thanks so much :)
    bethan81 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139