473,385 Members | 1,983 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Passing a _POST key that contains a "."

I am passing a _POST key that contains a period and php is replacing it with an underscore. I need to keep the key as say "Test.1". Any ideas?
Oct 28 '08 #1
4 1979
Markus
6,050 Expert 4TB
I am passing a _POST key that contains a period and php is replacing it with an underscore. I need to keep the key as say "Test.1". Any ideas?
Hm, PHP shouldn't be doing that.

Show the relevant code you use.

Edit, do you mean the array key is being changed?
Oct 28 '08 #2
Expand|Select|Wrap|Line Numbers
  1. //php stuff
  2.  
  3. if($submit) {
  4.         $sql = "SELECT * FROM Release ORDER BY Release";
  5.         $result = mysql_query($sql, $db);
  6.         if($result) {
  7.             echo '<pre>';
  8.             print_r($_POST);
  9.             echo '</pre>';
  10.  
  11.             while($myrow = mysql_fetch_array($result)) {
  12.                 $name = $myrow["Release"] . "_search_string";
  13.                 $dateCode_name = $myrow["Release"] . "_valid_dateCodes";
  14.  
  15.                 $myvar = $myrow["Release"];
  16.  
  17.                 $sql = "REPLACE INTO Release (Release, Supported, search_string,valid_dateCodes) VALUES ('$myvar', '$_POST[$myvar]', '$_POST[$name]', '$_POST[$dateCode_name]')";
  18. }
  19.  
  20. //and relevant html code
  21.  
  22. <FORM ACTION="release.php3?ma=patchguard&sa=editRelease" method="POST">
  23. <TABLE>
  24. <TR><TH>Release</TH><TH>Supported?</TH></TR>
  25. <TR><TD COLSPAN="2"><HR NOSHADE></TD></TR>
  26. <?
  27.     $sql = "SELECT * FROM Release ORDER BY Release";
  28.     $result = mysql_query($sql, $db);
  29.     if($result) {
  30.         while($myrow = mysql_fetch_array($result)) {
  31.  
  32.             $myvar = $myrow["Release"];
  33.  
  34.             $s_value = $myrow["search_string"];
  35.  
  36.             $name = $myvar . "_search_string";
  37.  
  38.             $search_text = "&nbsp;<input type='text' name='$name' size='8' value='$s_value'>";
  39.  
  40.             $s_value = $myrow["valid_dateCodes"];
  41.  
  42.             $dateCode_name = $myvar . "_valid_dateCodes";
  43.  
  44.             $valid_dateCodes = "&nbsp;<input type='text' name='$dateCode_name' size='25' value='$s_value'>";
  45.  
  46.             $myrelease = $myrow["Supported"];
  47.  
  48.             $output = "<TR><TD>" . $myvar . "</TD><TD>No longer supported<INPUT TYPE='radio' NAME='" . $myvar . "' VALUE='noLongerSupported'";
  49.  
  50.             if($myrow["Supported"] == "noLongerSupported") {
  51.                     $outputplus = " CHECKED> Supported<INPUT TYPE='radio' NAME='" . $myvar . "' VALUE='supported'> Future<INPUT TYPE='radio' NAME='" . $myvar . "' VALUE='future'>$search_text $valid_dateCodes</TD></TR>";
  52.                     echo($output . $outputplus);
  53.             }
  54.             else if($myrow["Supported"] == "supported") {
  55.                     $outputplus = "> Supported<INPUT TYPE='radio' NAME='" . $myvar . "' VALUE='supported' CHECKED> Future<INPUT TYPE='radio' NAME='" . $myvar . "' VALUE='future'>$search_text $valid_dateCodes</TD></TR>";
  56.                     echo($output . $outputplus);
  57.             }
  58.             else if($myrow["Supported"] == "future") {
  59.                     $outputplus = "> Supported<INPUT TYPE='radio' NAME='" . $myvar . "' VALUE='supported'> Future<INPUT TYPE='radio' NAME='" . $myvar . "' VALUE='future' CHECKED>$search_text $valid_dateCodes</TD></TR>";
  60.                    echo($output . $outputplus);
  61.             }
  62.             else {
  63.                     echo ("Error outputing $myvar information");
  64.                  }
  65.            }
  66.     }
  67. ?>
  68. <TR><TD COLSPAN="2"><HR NOSHADE></TD></TR>
  69. <TR><TD><INPUT TYPE="text"  NAME="Release"></TD><TD>No longer supported<INPUT TYPE='radio'  NAME='Supported' VALUE='noLongerSupported'> Supported<INPUT TYPE='radio'  NAME='Supported' VALUE='supported' checked> Future<INPUT TYPE='radio'  NAME='Supported' VALUE='future'></T</TD></TR>
  70. <TR><TD COLSPAN="2"><CENTER><INPUT TYPE="submit" NAME="submit" VALUE="Submit"></CENTER></TD></TR>
  71. </TABLE>
  72. </FORM>
When I enter a new "Release" with a "." in it, it works fine at first, but when I make changes to any release it replaces the "." with a "_".

ie. Test.1 becomes Test_1 as shown when I print out the _POST vars, so then when it tries to replace each entry in the DB it cannot find Test_1_search_string and the REPLACE is aborted.

Here is the _POST info for the "Release" that was named "Test.1"

[Test_1] => supported
[Test_1_search_string] =>
[Test_1_valid_dateCodes] =>


Did that make sense????
Oct 28 '08 #3
Markus
6,050 Expert 4TB
I'm not sure but it seems PHP doesn't allow periods in array keys and changes them itself? I don't really now. You could str_replace(".", "_", $var) when you need to use the POST keys.
Oct 28 '08 #4
Atli
5,058 Expert 4TB
Hi.

PHP does not allow periods (dots) in variable names. That includes array elements.

So, if you try to pass a name into PHP that includes a period, in order to be able to import it into your PHP scripts, PHP automatically replaces it with an underscore.

See Variables From External Sources
Oct 29 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Paul | last post by:
I want to use sessions to cover myself in case the user switches off cookies so I am passing the session ID manually through a hidden input field. This is what I have so far. index.php page...
1
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains:...
1
by: Raptor | last post by:
I'm using a single script to generate a table with <input>s in each row. I fill the array with initial values, then write it out to the table and let the user edit the values. Something like: ...
10
by: Joseph S. | last post by:
Hi, How do I pass a string from one call to a php block to another call in the same page but from another form? Here's my full php code: I'm using two forms in the same page. A hidden field...
6
by: JackM | last post by:
I have a multiple select input in a form that's being populated by a row from my database as such: <input type=\"checkbox\" name=\"subm\" value=\"$row\"> That part is working fine as I can check...
5
by: Mark Woodward | last post by:
Hi all, I'm trying to set up a 'control panel' consisting of a table of icons. The early stages: http://www.deepinit.com/controlcentre.php Each of these is set up like: <td> <input...
7
cassbiz
by: cassbiz | last post by:
I have been wondering if someone can see where my error is. I have been reading a lot of different tutorials and just cannot find my error. ? Should I be using 'isset' I can get all of the...
4
epots9
by: epots9 | last post by:
would it be possible to pass the contains of a $_POST reference to another page without submitting the form? I have a page which using $_POST to fill up some of the fields, and i have a print...
7
by: amygdala | last post by:
Hi all, I'm starting this new project in which I'ld like to implement sort of a design pattern I have seen being used in the CodeIgniter framework. Basically, the site will examine the URI and...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.