ryantaylor3 Posted July 4, 2007 Share Posted July 4, 2007 I can't get this to work, it prints out $Field1,$Field2,$Field3,$Field4,$Field5 instead of the actualy form variable. if($submit){ require("config.php"); $db_connect = mysql_connect($sql_host, $sql_user, $sql_pass) or die ('Could not connect: ' . mysql_error()); mysql_select_db($sql_db, $db_connect) or die ('Could not select DB'); $field_names = mysql_query("SELECT * FROM ryan_devel_fieldnames", $db_connect); $fieldnames_row = mysql_fetch_row($field_names); $fieldnames_var = ""; for ($i = 0; $i < mysql_num_fields($field_names); $i++) { $fieldnames_var .= "\$$fieldnames_row[$i], "; } $fieldnames_var = substr($fieldnames_var, 0, -2); $fieldnames_var = '$fieldnames_var'; echo $fieldnames_var; exit; } <html> <body> <br><br><br> <form action="<? echo $PHP_SELF; ?>" method="post"> <input type="text" name="Field1"><br> <input type="text" name="Field2"><br> <input type="text" name="Field3"><br> <input type="text" name="Field4"><br> <input type="text" name="Field5"><br> <input type="submit" name="submit"></form> </body> </html> Quote Link to comment Share on other sites More sharing options...
trq Posted July 4, 2007 Share Posted July 4, 2007 Remove. $fieldnames_data = '$fieldnames_data'; $fieldnames_var = '$fieldnames_var'; $fieldnames_url = '$fieldnames_url'; Quote Link to comment Share on other sites More sharing options...
ryantaylor3 Posted July 4, 2007 Author Share Posted July 4, 2007 I get this output: Field Names = Field1, Field2, Field3, Field4, Field5 Field Values = $Field1, $Field2, $Field3, $Field4, $Field5 Field URL Format = Field1=$Field1&Field2=$Field2&Field3=$Field3&Field4=$Field4&Field5=$Field5 OK, well this is what the code looks like now: <? if($submit){ require("config.php"); $db_connect = mysql_connect($sql_host, $sql_user, $sql_pass) or die ('Could not connect: ' . mysql_error()); mysql_select_db($sql_db, $db_connect) or die ('Could not select DB'); $field_names = mysql_query("SELECT * FROM ryan_devel_fieldnames", $db_connect); $fieldnames_row = mysql_fetch_row($field_names); $fieldnames_data = ""; $fieldnames_var = ""; $fieldnames_url = ""; for ($i = 0; $i < mysql_num_fields($field_names); $i++) { $fieldnames_data .= "$fieldnames_row[$i], "; $fieldnames_var .= "\$$fieldnames_row[$i], "; $fieldnames_url .= "$fieldnames_row[$i]=\$$fieldnames_row[$i]&"; } $fieldnames_data = substr($fieldnames_data, 0, -2); $fieldnames_var = substr($fieldnames_var, 0, -2); $fieldnames_url = substr($fieldnames_url, 0, -1); echo "Field Names = $fieldnames_data<br>"; echo "Field Values = $fieldnames_var<br>"; echo "Field URL Format = $fieldnames_url"; exit; } ?> <html> <body> <br><br><br> <form action="<? echo $PHP_SELF; ?>" method="post"> <input type="text" name="Field1"><br> <input type="text" name="Field2"><br> <input type="text" name="Field3"><br> <input type="text" name="Field4"><br> <input type="text" name="Field5"><br> <input type="submit" name="submit"></form> </body> </html> Quote Link to comment Share on other sites More sharing options...
ryantaylor3 Posted July 4, 2007 Author Share Posted July 4, 2007 http://209.216.10.166/devel/index.php Quote Link to comment Share on other sites More sharing options...
ryantaylor3 Posted July 4, 2007 Author Share Posted July 4, 2007 fixed it with this: $fieldnames_data .= $fieldnames_row[$i] . ", "; $fieldnames_var .= $_POST[$fieldnames_row[$i]] . ", "; $fieldnames_url .= $fieldnames_row[$i] . "=" . $_POST[$fieldnames_row[$i]] . "&"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.