PHP - Assigning $_server['remote_addr'] To Variable
Hi, I have just started creating my first class in php. I'm trying to assign $_SERVER['REMOTE_ADDR']; to a protected variable but I keep getting an error message. I'm still trying to get my head around oop php.
My current code is "protected $user_ip = $_SERVER['REMOTE_ADDR'];" and the error message is "Parse error: syntax error, unexpected T_VARIABLE". Similar TutorialsAt the very bottom of the page i am using the tag <? $_SERVER['REMOTE_ADDR'] ?> to show the clients ip address but it is not working any ideas where i am going wrong? Code: [Select] <?php require("../include/validate_mem_cookie.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Edit Your Pictures</title> </head> <link rel="stylesheet" type="text/css" href="../graphic_include/newstudio.css"> <body> <?php $uincookie = $_COOKIE["uin"]; require("../include/mysqldb.php"); $con = mysql_connect("$dbhost","$dbuser","$dbpass"); $imgff = "/p1c5_u91o4d/" ; if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("$dbame", $con); $result = mysql_query("SELECT * FROM Reg_Profile_images WHERE uin ='$uincookie'"); $i=1; while($rows = mysql_fetch_array($result)){ $image_zero = $rows[image_zero] ; $image_one = $rows[image_one] ; $image_two = $rows[image_two] ; $image_three = $rows[image_three] ; $image_four = $rows[image_four] ; $image_five = $rows[image_five] ; $image_six = $rows[image_six] ; $image_seven = $rows[image_seven] ; $image_eight = $rows[image_eight] ; $image_nine = $rows[image_nine] ; $image_ten = $rows[image_ten] ; $image_eleven = $rows[image_eleven] ; if (!empty($rows[image_zero])) { print "<p> </p> <table width=\"0\" border=\"0\"> <tr> <td><table width=\"112\" height=\"129\" border=\"0\"> <tr> <td><img src=\"$imgff$image_zero\" alt=\"\" width=\"156\" height=\"166\" /></td> </tr> <tr> <td><form id=\"form3\" name=\"form1\" method=\"post\" action=\"..\p1c5_u91o4d\delete_image.php\"> <label> <div align=\"left\"> <input type=\"submit\" name=\"button3\" id=\"button3\" value=\"Delete Picture\" /> <input type=\"hidden\" name=\"img[]\" value=\"$image_one\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_two\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_three\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_four\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_five\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_six\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_seven\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eight\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_nine\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_ten\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eleven\"> <input type=\"hidden\" name=\"remove\" value=\"$image_zero\"> <input type=\"hidden\" name=\"updel\" value=\"image_zero\"> </div> </label> </form></td> </tr> <tr> <td><form id=\"form4\" name=\"form2\" method=\"post\" action=\"change_order.php\"> <label> <div align=\"left\"> <input type=\"submit\" name=\"button3\" disabled=\"disabled\" id=\"button4\" value=\"PRIMARY PICTURE\" /> <input type=\"hidden\" name=\"img[]\" value=\"$image_zero\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_one\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_two\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_three\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_four\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_five\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_six\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_seven\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eight\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_nine\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_ten\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eleven\"> </div> </label> </form></td> </tr> </table></td>\n"; } if (!empty($rows[image_one])) { print "<td><table width=\"112\" height=\"129\" border=\"0\"> <tr> <td><img src=\"$imgff$image_one\" alt=\"\" width=\"156\" height=\"166\" /></td> </tr> <tr> <td><form id=\"form5\" name=\"form1\" method=\"post\" action=\"..\p1c5_u91o4d\delete_image.php\"> <label> <div align=\"left\"> <input type=\"submit\" name=\"button4\" id=\"button5\" value=\"Delete Picture\" /> <input type=\"hidden\" name=\"img[]\" value=\"$image_zero\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_two\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_three\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_four\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_five\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_six\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_seven\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eight\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_nine\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_ten\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eleven\"> <input type=\"hidden\" name=\"remove\" value=\"$image_one\"> <input type=\"hidden\" name=\"updel\" value=\"image_one\"> </div> </label> </form></td> </tr> <tr> <td><form id=\"form6\" name=\"form2\" method=\"post\" action=\"change_order.php\"> <label> <div align=\"left\"> <input type=\"submit\" name=\"button4\" id=\"button6\" value=\"Make Primary\" /> <input type=\"hidden\" name=\"img[]\" value=\"$image_one\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_zero\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_two\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_three\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_four\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_five\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_six\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_seven\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eight\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_nine\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_ten\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eleven\"> </div> </label> </form></td> </tr> </table></td>\n"; } if (!empty($rows[image_two])) { print "<td><table width=\"112\" height=\"129\" border=\"0\"> <tr> <td><img src=\"$imgff$image_two\" alt=\"\" width=\"156\" height=\"166\" /></td> </tr> <tr> <td><form id=\"form7\" name=\"form1\" method=\"post\" action=\"..\p1c5_u91o4d\delete_image.php\"> <label> <div align=\"left\"> <input type=\"submit\" name=\"button5\" id=\"button7\" value=\"Delete Picture\" /> <input type=\"hidden\" name=\"img[]\" value=\"$image_zero\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_one\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_three\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_four\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_five\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_six\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_seven\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eight\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_nine\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_ten\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eleven\"> <input type=\"hidden\" name=\"remove\" value=\"$image_two\"> <input type=\"hidden\" name=\"updel\" value=\"image_two\"> </div> </label> </form></td> </tr> <tr> <td><form id=\"form8\" name=\"form2\" method=\"post\" action=\"change_order.php\"> <label> <div align=\"left\"> <input type=\"submit\" name=\"button5\" id=\"button8\" value=\"Make Primary\" /> <input type=\"hidden\" name=\"img[]\" value=\"$image_two\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_zero\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_one\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_three\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_four\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_five\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_six\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_seven\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eight\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_nine\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_ten\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eleven\"> </div> </label> </form></td> </tr> </table>\n"; } if (!empty($rows[image_three])) { print " </td> <td><table width=\"112\" height=\"129\" border=\"0\"> <tr> <td><img src=\"$imgff$image_three\" alt=\"\" width=\"156\" height=\"166\" /></td> </tr> <tr> <td><form id=\"form9\" name=\"form1\" method=\"post\" action=\"..\p1c5_u91o4d\delete_image.php\"> <label> <div align=\"left\"> <input type=\"submit\" name=\"button6\" id=\"button9\" value=\"Delete Picture\" /> <input type=\"hidden\" name=\"img[]\" value=\"$image_zero\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_one\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_two\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_four\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_five\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_six\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_seven\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eight\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_nine\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_ten\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eleven\"> <input type=\"hidden\" name=\"remove\" value=\"$image_three\"> <input type=\"hidden\" name=\"updel\" value=\"image_three\"> </div> </label> </form></td> </tr> <tr> <td><form id=\"form10\" name=\"form2\" method=\"post\" action=\"change_order.php\"> <label> <div align=\"left\"> <input type=\"submit\" name=\"button6\" id=\"button10\" value=\"Make Primary\" /> <input type=\"hidden\" name=\"img[]\" value=\"$image_three\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_zero\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_one\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_two\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_four\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_five\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_six\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_seven\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eight\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_nine\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_ten\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eleven\"> </div> </label> </form></td> </tr> </table>\n"; } if (!empty($rows[image_four])) { print " </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> </table> <p> </p> <table width=\"0\" border=\"0\"> <tr> <td><table width=\"112\" height=\"129\" border=\"0\"> <tr> <td><img src=\"$imgff$image_four\" alt=\"\" width=\"156\" height=\"166\" /></td> </tr> <tr> <td><form id=\"form\" name=\"form1\" method=\"post\" action=\"..\p1c5_u91o4d\delete_image.php\"> <label> <div align=\"left\"> <input type=\"submit\" name=\"button\" id=\"button\" value=\"Delete Picture\" /> <input type=\"hidden\" name=\"img[]\" value=\"$image_zero\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_one\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_two\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_three\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_five\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_six\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_seven\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eight\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_nine\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_ten\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eleven\"> <input type=\"hidden\" name=\"remove\" value=\"$image_four\"> <input type=\"hidden\" name=\"updel\" value=\"image_four\"> </div> </label> </form></td> </tr> <tr> <td><form id=\"form2\" name=\"form2\" method=\"post\" action=\"change_order.php\"> <label> <div align=\"left\"> <input type=\"submit\" name=\"button\" id=\"button2\" value=\"Make Primary\" /> <input type=\"hidden\" name=\"img[]\" value=\"$image_four\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_zero\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_one\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_two\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_three\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_five\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_six\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_seven\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eight\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_nine\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_ten\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eleven\"> </div> </label> </form></td>\n"; } if (!empty($rows[image_five])) { print " </tr> </table></td> <td><table width=\"112\" height=\"129\" border=\"0\"> <tr> <td><img src=\"$imgff$image_five\" alt=\"\" width=\"156\" height=\"166\" /></td> </tr> <tr> <td><form id=\"form11\" name=\"form1\" method=\"post\" action=\"..\p1c5_u91o4d\delete_image.php\"> <label> <div align=\"left\"> <input type=\"submit\" name=\"button\" id=\"button11\" value=\"Delete Picture\" /> <input type=\"hidden\" name=\"img[]\" value=\"$image_zero\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_one\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_two\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_three\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_four\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_six\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_seven\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eight\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_nine\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_ten\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eleven\"> <input type=\"hidden\" name=\"remove\" value=\"$image_five\"> <input type=\"hidden\" name=\"updel\" value=\"image_five\"> </div> </label> </form></td> </tr> <tr> <td><form id=\"form12\" name=\"form2\" method=\"post\" action=\"change_order.php\"> <label> <div align=\"left\"> <input type=\"submit\" name=\"button\" id=\"button12\" value=\"Make Primary\" /> <input type=\"hidden\" name=\"img[]\" value=\"$image_five\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_zero\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_one\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_two\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_four\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_three\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_six\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_seven\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eight\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_nine\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_ten\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eleven\"> </div> </label> </form></td> </tr> </table></td>\n"; } if (!empty($rows[image_six])) { print " <td><table width=\"112\" height=\"129\" border=\"0\"> <tr> <td><img src=\"$imgff$image_six\" alt=\"\" width=\"156\" height=\"166\" /></td> </tr> <tr> <td><form id=\"form13\" name=\"form1\" method=\"post\" action=\"..\p1c5_u91o4d\delete_image.php\"> <label> <div align=\"left\"> <input type=\"submit\" name=\"button\" id=\"button13\" value=\"Delete Picture\" /> <input type=\"hidden\" name=\"img[]\" value=\"$image_zero\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_one\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_two\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_three\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_four\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_five\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_seven\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eight\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_nine\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_ten\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eleven\"> <input type=\"hidden\" name=\"remove\" value=\"$image_six\"> <input type=\"hidden\" name=\"updel\" value=\"image_six\"> </div> </label> </form></td> </tr> <tr> <td><form id=\"form14\" name=\"form2\" method=\"post\" action=\"change_order.php\"> <label> <div align=\"left\"> <input type=\"submit\" name=\"button\" id=\"button14\" value=\"Make Primary\" /> <input type=\"hidden\" name=\"img[]\" value=\"$image_six\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_zero\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_one\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_two\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_four\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_five\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_three\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_seven\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eight\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_nine\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_ten\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eleven\"> </div> </label> </form></td> </tr> </table></td> \n"; } if (!empty($rows[image_seven])) { print " <td><table width=\"112\" height=\"129\" border=\"0\"> <tr> <td><img src=\"$imgff$image_seven\" alt=\"\" width=\"156\" height=\"166\" /></td> </tr> <tr> <td><form id=\"form15\" name=\"form1\" method=\"post\" action=\"..\p1c5_u91o4d\delete_image.php\"> <label> <div align=\"left\"> <input type=\"submit\" name=\"button\" id=\"button15\" value=\"Delete Picture\" /> <input type=\"hidden\" name=\"img[]\" value=\"$image_zero\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_one\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_two\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_three\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_four\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_five\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_six\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eight\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_nine\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_ten\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eleven\"> <input type=\"hidden\" name=\"remove\" value=\"$image_seven\"> <input type=\"hidden\" name=\"updel\" value=\"image_seven\"> </div> </label> </form></td> </tr> <tr> <td><form id=\"form16\" name=\"form2\" method=\"post\" action=\"change_order.php\"> <label> <div align=\"left\"> <input type=\"submit\" name=\"button\" id=\"button16\" value=\"Make Primary\" /> <input type=\"hidden\" name=\"img[]\" value=\"$image_seven\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_zero\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_one\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_two\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_four\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_five\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_six\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_three\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eight\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_nine\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_ten\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eleven\"> </div> </label> </form></td> </tr> </table></td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr>\n"; } if (!empty($rows[image_eight])) { print " <td> </td> <td> </td> <td> </td> <td> </td> </tr> </table> <p> </p> <table width=\"0\" border=\"0\"> <tr> <td><table width=\"112\" height=\"129\" border=\"0\"> <tr> <td><img src=\"$imgff$image_eight\" alt=\"\" width=\"156\" height=\"166\" /></td> </tr> <tr> <td><form id=\"form17\" name=\"form1\" method=\"post\" action=\"..\p1c5_u91o4d\delete_image.php\"> <label> <div align=\"left\"> <input type=\"submit\" name=\"button2\" id=\"button17\" value=\"Delete Picture\" /> <input type=\"hidden\" name=\"img[]\" value=\"$image_zero\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_one\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_two\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_three\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_four\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_five\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_six\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_seven\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_nine\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_ten\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eleven\"> <input type=\"hidden\" name=\"remove\" value=\"$image_eight\"> <input type=\"hidden\" name=\"updel\" value=\"image_eight\"> </div> </label> </form></td> </tr> <tr> <td><form id=\"form18\" name=\"form2\" method=\"post\" action=\"change_order.php\"> <label> <div align=\"left\"> <input type=\"submit\" name=\"button2\" id=\"button18\" value=\"Make Primary\" /> <input type=\"hidden\" name=\"img[]\" value=\"$image_eight\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_zero\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_one\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_two\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_four\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_five\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_six\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_seven\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_three\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_nine\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_ten\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eleven\"> </div> </label> </form></td>\n"; } if (!empty($rows[image_nine])) { print "</tr> </table></td> <td><table width=\"112\" height=\"129\" border=\"0\"> <tr> <td><img src=\"$imgff$image_nine\" alt=\"\" width=\"156\" height=\"166\" /></td> </tr> <tr> <td><form id=\"form19\" name=\"form1\" method=\"post\" action=\"..\p1c5_u91o4d\delete_image.php\"> <label> <div align=\"left\"> <input type=\"submit\" name=\"button2\" id=\"button19\" value=\"Delete Picture\" /> <input type=\"hidden\" name=\"img[]\" value=\"$image_zero\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_one\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_two\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_three\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_four\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_five\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_six\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_seven\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eight\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_ten\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_eleven\"> <input type=\"hidden\" name=\"remove\" value=\"$image_nine\"> <input type=\"hidden\" name=\"updel\" value=\"image_nine\"> </div> </label> </form></td> </tr> <tr> <td><form id=\"form20\" name=\"form2\" method=\"post\" action=\"change_order.php\"> <label> <div align=\"left\"> <input type=\"submit\" name=\"button2\" id=\"button20\" value=\"Make Primary\" /> <input type=\"hidden\" name=\"img[]\" value=\"$image_nine\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_zero\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_one\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_two\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_four\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_five\"> <input type=\"hidden\" name=\"img[]\" value=\"$image_six\"> & I have been recording IP address's on a website since June 2006. This has worked for years up until 9th Dec 2014 when my database has stopped reporting the IP address and all I get since is 127.0.0.1
What has happened? I don't own the server it is being hosted by stramline.net
HELP
Hello, I have a website where only a couple of people can access it, so the number of IPs logged in is very limited. Everything submitted by the 'admins' logged in is sent to a specific folder dependent of their IP Address. Again they can't access the website through a proxy or anything because there's a limited range of IPs that is allowed. Can I trust $_SERVER['REMOTE_ADDR'] to give a valid IP so the log-system would be 100 % stable and efficient ? I am trying to make sure I don't get an "Undefined Index" error. Will this code work... $ip = (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''); Debbie What is different between: $host = $_SERVER['HTTP_HOST']; and $host = "www.my-domain.com"; Somehow when I have to use first line then $_SESSION vars doesn't go through two different domains. hi there, i'm trying to put a message in the footer of a page which welcomes a person who is logged in with his/her name, using sessions of course; when i place this: Code: [Select] $username = $_SESSION['valid_user']; in the footer before the echo: Code: [Select] echo "You are logged in as $username"; but the session is also needed before the footer to use the username for other things , such as -checking his credit- so if place in footer the footer shows name in browser but checking credit would not happen as the assignment is at the buttom. IF i place the assignment above at the top of the file: everything works for the user and checking credit ..etc...but the footer is not there... cud not put this any clearer..sorry...hope if someone cud help...thanks hi, i am updating records from database using ajax and javascript on php page. The result is displayed inside a div (<div id="show"></div>). Now i want to assign the content of the above div(say y) to php variable for further calculations. How can i assign the value displayed in div tag to a php variable? Thanks. Hi all, I can't seem to designate an array key by using a variable and I was wondering if this is possible. I'm looking to do something like this: Code: [Select] <?php $key = "apple"; $arr = array($key => "fruit"); ?> Any suggestions would be appreciated! Hi folks, I was wondering how to do this. I want the if statement to detect if the query string has any of these values. so im trying to assign them all to the same variable. However, this code wont work. Whats the trick here? <?php $primary=$_GET['intro']; $primary=$_GET['port']; $primary=$_GET['about']; $primary=$_GET['contact']; if(isset($primary)){ echo "<img src='graphics/left-a.png'>";} else {echo "<img src='graphics/leftb.png'>";}?> Hello, I am creating a class which contains one private function that deals with connecting to a SQL Server and executing the sql that is passed in to that function. I have defined a class variable which is assigned the value of sqlsrv_query like so. $this->QueryResult = sqlsrv_query($conn,$sql); I have placed private $QueryResult at the top of my class. The other public methods call this private function to assign the result set to the class variable, the private method returns and then the public methods loop through the results array like so. while($row = sqlsrv_fetch_array($this->QueryResult)) .. but the while loop never gets entered. If I declare everything in the same method then it works, however there are going to be several public methods that will use this private method and I don't want to duplicate all the database coding. Hope someone can help Hello Everyone, I am new to forum and could use some help with some php code that isn't working. I am very new to php/html/javascript and all of what I have learned, I learned from forums like this one so first....thank you! I am trying to assign a value from a php variable to the value of my form element. I'm sure there must be a way to do this but I can't seem to get the syntax right. here is my code... first I set the value of $loginname elsewhere in the script like so... <?php $loginname =strtolower(htmlspecialchars(strip_tags($_GET["loginname"]))); ?> This part works fine.. Then I try to set the value of my hidden text field inside the form to the value of $loginname to be passed to a javascript program. Everything works except that the value passed ends up being <?echo and not the expected user name inside of $loginname. <?php echo '<form name ="currentactivity" Id="currentactivity" action="<?php'.htmlspecialchars($_SERVER['PHP_SELF']).'?>" method="post">'; echo '<fieldset><legend><b>Your Current Activity Information</b></legend>'; echo '<input type="text" name="loginnm" style="visibility: hidden" value="<?php echo $loginname;?>">'; echo "<label for='myactivities'>Activity Name:</label>"; echo "<select name='myactivities' Id='myactivities' onchange=\"showdetails(this.form)\" value=''>"; echo "<option value = 'Select an activity'>Select an activity</option>"; for ($i = 1; $i <=$rowcount; $i++) { echo"<option value=$row[activity_name]>$row[activity_name] </option>"; $row = mysql_fetch_array($result); } echo "</select>"; echo '</fieldset>'; echo '</form>'; ?> Please note..the rest of the code is working perfectly, it is just this one value I can't seem to get. Any help you can give will be greatly appreciated. Okay, really newbie question, but for this code... Code: [Select] <!-- Gender --> <label for="gender">Gender:</label> <select id="gender" name="gender"> <option value="">--</option> <option value="F">Female</option> <option value="M">Male</option> </select> 1.) How do I assign a variable to this? 2.) How do I make this "sticky"? Here is how I have usually done other form types... Code: [Select] <!-- First Name --> <label for="firstName">First Name:</label> <input id="firstName" name="firstName" type="text" maxlength="30" value="<?php if(isset($firstName)){echo htmlentities($firstName, ENT_QUOTES);} ?>" /><!-- Sticky Field --> <?php if (!empty($errors['firstName'])){ echo '<span class="error">' . $errors['firstName'] . '</span>'; } ?> Oh, by the way, at the top of my PHP file I have this code... Code: [Select] if ($_SERVER['REQUEST_METHOD']=='POST'){ // Form was Submitted (Post). // Initialize Errors Array. $errors = array(); // Trim all form data. $trimmed = array_map('trim', $_POST); Thanks, Debbie I am facing problem to execute query by assigning NULL value to a variable and then executing query.In MySQL DB four fields Mobile,landline, pincode,dob are set as integer and date(for dob) respectively.The default is set as NULL and NULL option is selected as yes.All these fields are not mandatory.The problem is that when I edit the form my keeping the value as empty in DB these are saved as 0, 0 , 0 & 0000-00-00 inspite of Null. I have tried everything but still the defect persist. Please help me to come out of the problem The code, I have used: <?php //require_once 'includes/config.php'; $dbusername = $_POST['email']; $dbfirstname = $_POST['first_name']; $dblastname = $_POST['last_name']; //$dbmobile_number = $_POST['mobile']; if (isset($_POST['mobile'])) { $dbmobile_number = $_POST['mobile']; } else { $dbmobile_number = "NULL"; } $dblandline_number = $_POST['landline']; $dbdob = $_POST['dob']; if(isset($_POST['is_email'])) { $dbSubscribe_Email_Alert = '1'; } else { $dbSubscribe_Email_Alert = '0'; } if(isset($_POST['is_sms'])) { $dbSubscribe_SMS = 0; } else { $dbSubscribe_SMS = 0; } $dbAddress_firstname = $_POST['shipping_first_name']; $dbAddress_lastname = $_POST['shipping_last_name']; $dbAddress = $_POST['shipping_address']; $dbcity = $_POST['shipping_city']; $dbpincode = $_POST['shipping_pincode']; $dbstate = $_POST['shipping_state']; $dbcountry = $_POST['shipping_country']; echo "Welcome".$dbusername; //if($_POST['btnSave']) //if ($_POST['btnSave']) //{ //echo "Inside query loop"; $connect = mysql_connect("localhost","root","") or die("Couldn't connect!"); mysql_select_db("salebees") or die ("Couldn't find DB"); //$query = mysql_query("SELECT * FROM users WHERE username='$username'"); $query = mysql_query("update users set firstname = '$dbfirstname', lastname = '$dblastname', mobile_number = '$dbmobile_number', landline_number = '$dblandline_number', dob = '$dbdob', Subscribe_Email_Alert = '$dbSubscribe_Email_Alert', Subscribe_SMS = '$dbSubscribe_SMS', Address_firstname = '$dbAddress_firstname', Address_lastname = '$dbAddress_lastname', Address = '$dbAddress', city = '$dbcity', pincode = '$dbpincode', state = '$dbstate', country = '$dbcountry' where username = '$dbusername' "); header("location:my_account.php"); //} //else //{ //die(); //} ?> hey guys, I'm quite new to PHP and i was wondering if someone would be able to help me out with this. The code i have checks the database to see if a user has provided a Vimeo ID. If they haven't, $video_check will equal a line of html that says the user hasn't added any videos to their portfolio. If the a vimeo ID is present, i want $video_check to equal a bunch of html and css with a foreach function inside that is used to display the users videos from vimeo. The foreach function works fine when its not assigned to the $video_check variable. How do i structure it so that it displays correctly? If you click on videos on this page you might get a better idea of what i'm talking about. http://www.myfilmportfolio.ie/profile.php?id=33 and here is the code i'm having the problem with: /////// check if user has provided vimeo id ////////////////////////// $vimeoID = $row["vimeoID"]; $video_check=''; if (empty($vimeoID)){ $video_check = '<h3>'.$firstname .' has not added any videos to their portfolio</h3>'; } else{ $video_check = '<div id="stats"> <div style="clear: both;"></div> </div> <div id="wrapper"> <div id="embed"></div> <div id="thumbs"> <ul> <?php foreach ($videos->video as $video): ?> <li> <h4><?=$video->title?></h4> <a href="<?php echo $video->url ?>"> <img src="<?php echo $video->thumbnail_medium ?>" class="thumb" /></a> <p><?=$video->description?></p> <br /> </li> <?php endforeach ?> </ul> </div> </div>'; } if anyone could help me out id really appreciate it. Cheers, G what's the difference between them? how to use them. i print_r($_SERVER). there are no result of $_SERVER['PATH_INFO'] and $_SERVER['PORIG_PATH_INFO'] .why? how to enable it.i have read the php manual about them, but still don't understand . expect someone can explain them.thank you I get the following error when I try to pass a value to a methiod in a loop: Warning: Attempt to assign property of non-object in /Users/staceyschaller/Sites/dev_zone/ckwv2/classes/class.php on line 670 This one has me very baffled. It will work the first time, and seems to work every other time, so I have no clue what is wrong. Here is the code: This code is part of my "display" class: function display_partner ($type,$loc,$rand=0,$narrow=0) { $this->partners = new partner($this->cxn); $display = ' <div id="cont_info" class="partner-list"> <div> <h3 class="settings">'.ucfirst($loc).' '.ucfirst($type).last_letter($type).'s</h3> </div> <div class="settings-value" style="height:12px;padding:0;margin:0;text-align:right;padding-right:10px;"> <a href="" class="trunc">Add your organization to this list</a></p> </div> <div style="height:2px;padding:0;margin:0;"> <hr class="account" /> </div> '; $ids = $this->partners->get_partners_list($type,$loc,$rand); for ($b=0;$b<sizeof($ids->id);$b++) { $this->partnerID = $ids->id[$b]; $display .= ($narrow)? $this->card_partner_narr():$this->card_partner(); if ($b!=(sizeof($ids->id)-1)) { $display .= '<hr class="account" />'; } } if (sizeof($ids->id)==0) { $display .= '<div style="color:#999999;display:line;text-align:center;height:20px;">No Partners found for '.ucfirst($loc).' '.ucfirst($type).'</div>'; } $display .= ' </div>'; return $display; } function card_partner () { $this->partners->set_partner_id($this->partnerID); $part_info = $this->partners->get_partner_info(); if ($part_info) { $display .= ' <table class="settings"> <tr> '.$this->show_if($part_info['partLogo']['val'],'<td class="settings-value" rowspan="2"><img src="'.LOGO_FOLDER.$part_info['partLogo']['val'].'" '.resize_img(LOGO_FOLDER.$part_info['partLogo']['val'],175).'alt="'.$part_info['partName']['val'].'" /></td>').' <td class="settings-value" colspan="2"><h5>'.$part_info['partName']['val'].'</h5></td> </tr> <tr> <td class="settings-value"> <span style="color:999999;">'.$part_info['partAddress']['val'].'<br /> '.$part_info['partCity']['val'].', '.$part_info['partST']['val'].' '.$part_info['partZIP']['val'].'<br /> '.$part_info['partPhone']['val'].'</span><br /> <a href="'.$this->form->show_href($part_info['partWeb']['val']).'" target="_blank">'.$part_info['partWeb']['val'].'</a> </td> <td class="settings-value">'.$part_info['partInfo']['val'].'</td> </tr> </table> '; } return $display; } This code is part of my "partners" class: function set_partner_id($partID) { echo '<p>partID: '.$partID.' '.gettype($partID).'<br> $this->partner->id: '.$this->partner->id.'</p>'; $this->partner->id = $partID; ///*** ERROR HAPPENS HERE ***/ echo '<p>id set: '.$this->partner->id.'<br> $this->partner->id: '.$this->partner->id.'</p><hr>'; } function get_partner_id() { return $this->partner->id; } // gets user info at login function get_partner_info() { $this->partner = $this->cxn->proc_info('partner','partID',$this->partner->id);//$this->partner->id return $this->partner; } The following is the output generated: partID: 24 string $this->partner->id: id set: 24 $this->partner->id: 24 partID: 26 string $this->partner->id: Warning: Attempt to assign property of non-object in /Users/staceyschaller/Sites/dev_zone/ckwv2/classes/class.php on line 670 id set: $this->partner->id: partID: 17 string $this->partner->id: id set: 17 $this->partner->id: 17 partID: 25 string $this->partner->id: Warning: Attempt to assign property of non-object in /Users/staceyschaller/Sites/dev_zone/ckwv2/classes/class.php on line 670 id set: $this->partner->id: As you can see, the value passes to $this->set_partner_id($partID) each time. It is formatted as a string. When it assigns the value to $this->partner->id, however, sometimes it works, and sometimes it doesn't. It's probably something obvious, but I've racked my brain to see what it is. Any ideas? can someone explain to me why PHP returns so many different variants when throwing out visitor info using this piece of code? $ip = gethostbyaddr($_SERVER['REMOTE_ADDR']); here are some examples I have seen recently: planetlab24.gino-research.net.in.tum.de 10.32.64.124 49.129.197.35.bc.googleusercontent.com abts-north-dynamic-142.110.68.182.airtelbroadband.in 173-20-152-84.client.mchsi.com now, obviously i can understand the google one, and a few others. but, given the info and insight on these pages: https://www.php.net/manual/en/function.gethostbyaddr.php , and https://www.php.net/reserved.variables.server , why are the returns so different for different people? why does PHP see all different kinds of things? is the cause the way the user’s server is configured? some identifying info OF the server? and what about reserved IPs? like the “10.xx…” one I listed above? I’ve seen hundreds from that pool, and other blocks of reserved ones, and they have never had alpha-chars included in their captures. it’s always only the IP numbers. there a reason for that? really, all I’m looking for is why I see what I see. anyone help? furthermore, does anyone know if other server-side languages like c#, python, ruby or any js frameworks return different results than PHP ever would? thanks. Is there a server variable that holds the full url including the page name.php
TIA
Paul
my problem is when i click on hyperlink it start copying it self insertrow=yes in address bar how to tackle this Code: [Select] $httpquery = "{$_SERVER['PHP_SELF']}?{$_SERVER['QUERY_STRING']}&insertrow=yes" ; <a href='{$httpquery}' >New</a> <br> if (isset($_GET['insertrow'])) { echo "<br> {$_GET['insertrow']} "; } Hi, I use this form to call a function in self_php_page:addcomment; but it doesn't work. Wich part of form is incorrect: echo' <form action="{$_SERVER['PHP_SELF']}" . "?action=addcomment&id=$id" method="post" id="contactform" >'; echo' <ol>'; echo' <li>'; echo' <textarea id="message" rows="6" cols="50" name="comment"></textarea>'; echo' </li>'; echo' <li class="buttons">'; echo' <input type="image" type="image" name="imageField" id="imageField" src="../images/send.gif" />'; echo'</li></ol></form>'; i guess this line is incorrect:action="{$_SERVER['PHP_SELF']}" . "?action=addcomment&id=$id" TNX. |