Filling Variables From SQL
I have a dynamic dropdown menu filled with names of people that posted to the guestbook. When I select a user I want info about that user to show up (ip, when posted...)
if(in("show"))
{
$id = $_POST['info'];
$action = "SELECT * FROM entried WHERE id = '$id'";
$result = mysql_query($action);
$name_info = ???
$ip_info = ??
}
How can I fill in those variables (name_info , ip_info ) with information from SQL (fields are name , ip ...)
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Repeated Filling
How do I fill up a form continously and submit it remotely? Meaning, the form info comes in from a dbase using php and gets submited to a remote site. All this happens automatically.
Zero Filling Integer
Is there a way in PHP to zero fill an integer to a specified length? For instance, if I have a two digit number, and I want to zero fill it to four digits, is there a PHP function I can use? Or do I manually have to add zeros to the front?
Filling Out Forms Through Proxies With Php
i'm connecting to the internet via a proxy, and am having problems filling out forms... below is the code i have, and below that is the http request i am trying to make it look like. they look the same to me, but it isn't working, so i guess they aren't... $proxy = fsockopen("tcp://someaddresshere", 80, $errno, $errstr); $temp = "somethingelse=blablabla"; fputs($proxy,"GET somesite HTTP/1.0"); fputs($proxy,"Accept: */*"); fputs($proxy,"Referer: http://someothersitesite"); fputs($proxy,"Content-Type: application/x-www-form-urlencoded"); fputs($proxy,"Content-Length: " . strlen($temp) . ""); fputs($proxy,$temp . ""); while (!feof($proxy)) print fgets($proxy); fclose($proxy); with that script, i don't get anything. however, with this http request, from opera 7.10, i do: POST http://somesite HTTP/1.0 User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Opera 7.10 [en] Host: somesite Accept: text/html, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1 Accept-Language: en;q=1.0 Accept-Charset: windows-1252, utf-8, utf-16, iso-8859-1;q=0.6, *;q=0.1 Accept-Encoding: deflate, gzip, x-gzip, identity, *;q=0 Referer: http://someothersite Proxy-Connection: close Content-type: application/x-www-form-urlencoded Content-length: xx somethingelse=blablablaHTTP/1.1 200 OK Via: 1.1 DELTANS Connection: close Content-Type: text/html Date: Fri, 20 Jun 2003 17:54:37 GMT Server: Apache/1.3.27 (Unix) (Red-Hat/Linux) mod_ssl/2.8.12 OpenSSL/0.9.6b DAV/1.0.2 PHP/4.1.2 mod_perl/1.26 X-Powered-By: PHP/4.1.2 Set-Cookie: PHPSESSID=6c6baebea48c1ee4ad562d7fef3a46a4; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Set-Cookie: something Set-Cookie: something now the last part of the http request isn't a request persay, but whatever,....
Form Filling PDF Template
I realise there is a lot written on this subject, but as a newcomer I'm not having much luck finding a solution to my particular problem. Grateful for your help! I need customers to be able to enter information into a form and receive a non-editable PDF document, by email and/or in the browser, containing that information (with a specific layout based on a template) after submitting the data. I have found numerous libraries like PDFkit etc that might well do this. I'm not sure if I can install the library onto my host server though - is it normal to be able to do this? There's also the Acrobat forms option. However, I need this to be fool proof. If the client does not currently have Acrobat reader installed on their computer, would they not be able to view the PDF form, thus limiting accessibility? I also want to avoid FDF if possible because it seems that, again, there's the potential for the browser not to open the file properly, or problems if the client doesn;t already have Acrobat reader installed.
Filling An Array With A Set Of Values
i know there's a way to fill an array with a predetermined set of values (i.e. 0-999, a-z, etc) but i can't find the right syntax for the task nor find any examples.
Problem Filling An Array
I'm writing code to validate fields in a form before saving to a db. All the validating functions are in a separate script which is required. All the validating functions add an error message to an array if the data doesn't validate. I check if something went wrong with count($theArray). Here's my code:
Automated Table Filling
Ive put a whole bunch of images into MySql, and am referencing them through PHP. The code is as follows... PHP Code:
Filling MySQL Table From Within PHP
I don't seem to get the following right. In the following I try to fill a MySQL table named 'mutation'. The first element is a date but MySQL sees this as 0000-00-00 instead of the date 2002-11-01. Other problem is the textstring in $_POST['verklaring1'], in MySQL this stays empty. <?php $query = "insert into mutation values (2002-11-01, 1, 4, 1, 4, 10, 330 , ' $_POST['verklaring1'] ',N,N,N,N)"; mysql_db_query("projects", $query); ?>
Filling In For Deleted Images
I am creating an image gallary where the images are numbered 1, 2, 3 etc. Users will be uploading the images so if i need to delete an image, I need the code to be able to check if that number has been deleted and replace it with the next uploaded image. I have the code pulling from a txt file with a counter to name each file. The problem is that if images "36", "29" and "2" are removed... I need those slots to replaced in numerical order with the next uploaded images. So the next image will be named image "2" and will show up as the 2nd image on the page. Code:
Dynamically Filling Selection Boxes
I was wondering if anyone knows how to fill a selection box with different values depending on a selection made in a nother selection box in the same page. I dont know if what I'm tryin to do can be done or not, at least in PHP. First a quick background: We have a number of projects running right now, each of which is subdevided into various tasks. Now, I've got two selection boxes. The first contains a list of all current projects. What I want to do is this: when someon selects a project from the first box, I'd like the second box to be filled with a list of the tasks that have been assigned tot hat project.
Filling Form With Database Info
I have a table with 5 fields for a tour business activity list : (1) id -table key (2) name (3)description (4)picture -text link not binary(5) country. I would like to create a form that takes all the activitys an puts it neatly down on site in checkboxes so user can select activtys.this will be linked to form mail.i would like the activitys to be seperated by the country they r in?
Filling An Array Depending On A Variable
I want to fill an array with numbers depending on a variable. On the page for holiday booking, the user gives the date of arrival and the date of departure, now i have written code to determine the number of days the user is staying. Say this is 5, now i want to fill a variable with the numbers 1,2,3,4,5 If the user stays 3 days the variable should be filled with 1,2,3 I came up with this ....
How To Shortcut Execute Php Script Without Filling Out Form?
There is a website that has two input boxes inside a POST form that uses the action="rcon.php" here is the code for the form: <form method=POST action="/rcon.php"> <input size=25 type=text class="sm" name="addr"> <input size=20 type=text class="sm" name="rcon"> <input class="coolbuttonblue" type=submit value="Submit">...
Efficiently & Safely (re)filling Array From $_POST
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: $myarray = $array(1, 2, 3, ... 100); echo 'Enter your changes, then click Submit:' foreach ($array as $i) echo '<table tags> <input value="'.$i.'" name="index.'$i.'"> <table tags>' When the user clicks Submit, I need to pull the values back into the array so I can re-display & operate on it. The data is in $_POST, which is associative and contains stuff other than my array. $_POST contains something like: Submit=>submit someVariable=>someValue anotherVariable=>anotherValue index1=>1 index2=>99 index3=>93.2 .... index100=>-3 After doing a quick google search, I tried: for ($i = 0; $i < count($array); $i++) { $name = 'index'.$i; $array[$i] = $_POST["$name"]; } It runs, but I get nothing out of $_POST - those key values are unset. Is my only option to inefficiently iterate through $_POST AND $myarray, and doing the assignment to the proper element when I find the corresponding name in $_POST's key? Can I use the $_POST keys as indexes in a loop? If so, is it *safe* to do that, and what's the syntax? Something vaguely like: for ($i = 0, $key = index1; $i < 100 && $key < index100; $i++, $key++) array[$i] = $_POST[$key];
Same Named Variables.. Or Addressing Variables In A Loop
I'm just starting to program in PHP.. fairly new to programming in general... and I've run across a (probably simple) programming problem I hope someone can help me with. I'm sending variable names through an HTTP get that are generated through a foreach loop. The names are along the lines of name1=, begin1=, end1=, name2=, begin2=, end2=.. etc. The number is the number of the current cycle through the loop. My problem is addressing the variables on the next page... namely how do I evaluate those variables in a loop? I want the value of name1.. but obviously for (i=1; i<3; i++) { echo "$name$i"; }; is not working. Is there an easy way to do this?
Passing Variables & Dummy Variables
Hi! thanks for all the previous help - I've made some progress & have dropdowns and a checkbox; however I have 2 probs which I can't figure out: grateful for any further help. THANKS! 1. Not sure how to code so that user can query from just 1 or all of the dropdowns (at the moment unless they select the correct answers from each dropdown - no results!) = defeats the whole purpose of searching. By selecting from menu options user selects from 2 diff tables. [the page allows user to search catalogue by selecting year of release, artist, music type - results from 2 tables need to be selected & sent to mysql. I just don't know how to code it so that user must make an initial selection to get any results, and whichever menu options they choose "add them together" if you like to make a complete query.... sorry my coding just isnt deep enough! A friend suggested using a dummy variable but as I'm a bit out of my depth; I need to get some help! The coding I've done so far;
Passing Variables And Session Variables
I'm currently working on a shopping cart script that works just fine with register_globals turned on but when turned off i get all kind of errors. The following page displays a detail of the book with the "Add to cart" link at the bottom. PHP Code:
Passing My Variables With Forms Variables
how to carry variables onto the next page along with the forms variables. I need to carry my own over too, but when I press submit on the form page only the forms variables carry over, not my own ?? I have two drop down menues on my form that provide two values "start & end" which I require to go with my own variables.I have tried "a href=" link which carries my variables but not the forms variables. <?php echo"<form method=get action=somepage.php?one=$one&two=$two&three=$three&four=$four>";?> also tried <a href=somepage.php?one=$one&two=$two&three=$three&four=$four&start=$start&end=$end
Persistant Variables - Application Variables
In the books I have read about PHP I haven't been able to find any descriptions of how to set variables that persist in the servers memory, in the way that Application variables persist in Cold Fusion. In CF, if I set an application variable then any of the application pages that are run will have access to those variables. And you can put complex arrays of data in the Application Variables and then access these variables at any time, without having to reload those variables for each page when it loads. I expect you can do this is PHP, but I can't find any info about how to do this.
Variables That Change Session Variables
I'm currently writing a mulit-page form app that uses a session to retain data from each form element in order for the user to jump between pages, then the final data is passed to a calculation script. However, I've noticed that if I assign a session variable to another variable, which then performs a mathematical calculation, the session variable changes. i.e. $_SESSION["inflation"] = 4; $temp_inf = $_SESSION["inflation"]; if ($_SESSION["inflation"] =="RPI") { $inflation = $rpi;} else {$inflation = ($temp_inf/100.0);} now it equals = 0.04 How can I take a value from a session and perform operations on it without altering the original session value.
Form Variables To Session Variables
I am writing a small script that consists of two pages: page one displays a bunch of values from a DB (ie. First Name, Last Name, Phone Number). On this page you will find a form that follows this format: <input type="text" name="edit_firstname" size="20" maxlength="35" value='Bob'> <input type="text" name="edit_lastname" size="20" maxlength="35" value='Smith'> <input type="text" name="edit_phone" size="20" maxlength="35" value='5552222'> So when you see the page there will already be a 'default' value in each line (which is information extracted from a DB). This works perfectly and has been tested thoroughly. On the second page I have the following code: $editfirstname = $_POST['edit_firstname']; $editlastname = $_POST['edit_lastname']; $editphone = $_POST['edit_phone']; What I am trying to do is this: the default value for edit_firstname from the form is 'Bob' by default, but the user can change this in the input field on the first page. This value, whether changed or unchanged, should then be stored as edit_firstname and by calling up the function $_POST[''] on the second page I want to transfer the value to the variable $editfirstname. However, it seems that $_POST['edit_firstname'] and the other fields do not return a value at all, hence $editfirstname = '' or $editfirstname = 'NULL'. I have never tried to do things this way before.
Building Variables From Variables
I am trying to build a variable, that will have a amount of that variable, can someone describe/explain in detail the best method to do this?
Variables
I have a variable holding text which I want the text to have a $ in front of it to convert it to a variable.
Php Variables
I'm trying to assign a new value to a variable passed from an html form to a php3 script. I'm using an if statement to evaluate variable 3 to see if it is equal to a specific string, if it is I'm reassigning variable 2 to be variable2+variable 3. if ($question3!="select days") { $question2=$question2+$question3; } This is the statement. It keeps giving me a parse error and I can't seem to find the right documentation to show me how to combine two string variables.
Variables
If i created an array that holds fields of a table, how could I call one of the fields ie $array[field] if i need the field part to be a variable?
What Does @ Do In Variables?
i've noticed that many scripts contain @ before a funciton is called as in the following: $host = @gethostbyaddr($HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"]); so what is the purpose of the @ ?
Variables In URL
I have tried the following to pass a variable queried from a database to another page through the URL (id is the database record): $idnum = $row->id; print "<a href="page.php?$idnum>"; print "Click Here"; print "</a>" and then to print the results on the linked page: print $idnum; but it didn't work. What's the exact code to retrieve and print the variable $idnum? Also, can I use $idnum as a variable in a database query string such as $result = mysql_query( "select id from articles where id is like $idnum" );
JS Variables In Php
i've got a piece of javascript code which prints out the city + country of a visitor to a website. I want to print both, city & country to a file. JS doesn't have file I/O. Would it be possible to somehow import the variables to php? here's the JS code: <script language="Javascript" src="http://gd.geobytes.com/gd?after=-1&variables=GeobytesCountry,GeobytesCity"> </script> <script language="Javascript"> document.write("<p>Welcome to visitors from "+sGeobytesCity+", "+sGeobytesCountry); </script>
Variables Within Variables
The actual app I am building allows users to create an email which is then mailed out members from a db of email addresses. Although I am having a big problem reading a variable into the mail after the mail has been created. In a very simplified state all I am trying to do is this (the order of events has to be this way unfortunately): $content = "This is an email and the variable $name needs to be viewed at this point"; $name = "buttie"; echo $content; When $content is echoed the variable $name does not get read. What is the best way to let $content access the variable $name, using this order of events.
Variables By URL
Hi have a simple php script that gets the website URL from a form... puts it on a variable and calculates Link Popularity. How can I get this to work passing the site URL by the address instead of the form. [php] <?php if(isset($_GET['getlp'])){ // Edit this to your website url: $myWebSite = ($_POST['url']); [/php] I go to http://localhost/novo2/material/linkpop.php On the form I introduce my site and the address becomes http://localhost/novo2/material/linkpop.php?getlp=1 How can I avoid introducing the address and make the script assume that the address it needs its the address where it's being host?
PHP Variables Put Into A PDF
I have been searching for at least 5 hours all over the web and can't find a single thing to help me with this problem... I have a form created in Adobe Designer 7.0 (editable form) and I want it to receive variables from PHP and display the filled in form to users so that they can print it off for their own records. The form HAS TO BE laid out in the format I created in Designer 7.0. Any tips, suggestions, refering stuff?
Variables Through URL
I am trying to pass a variable through a URL eg. index.php?page=Features. Sadly, I used to do this in the Global off environment of PHP Nuke, and now have to cope with Global on. I have tried PHP Code:
Get URL Variables
how to get a variable passed in the URL, like this: <a href="issue.php?ticket=2">2</a> On the issue page how do I get the variable 'ticket'? There seems to be no HTTP_URL_VARS or something of that nature and nothing in the PHP manual that I could find.
Variables?
I simply want to print some text that has 2 variables in it. Here is the code i have now. PHP Code:
Php URL And Variables
It's probably very easy, but I cannot find my mistake: page1.php <?php echo "<a href=page2.php?vartrans=5342>Clic</a>"; ?> page2.php <?php echo "$vartrans"; ?> When I click on the link on page 1, page 2 appears on the screen but with the following error message: Notice: Undefined variable: vartrans in c:program fileseasyphp1-7wwwpage2.php on line 2 What's my mistake? I use php 4.3.3.
Variables
i have many pages (page1.php .. page100.php) and each of them include some fixed subpages (top.php, bottom.php). each subpage (top.php, bottom.php) uses a variable ("theme") defined in its "parent" (one of the pageX.php). this variable is also used (not only defined) in the parent page itself. i would like to have the variable "theme" defined in a single external file, instead of defyning it for every page. is it possible? sorry for the probably stupid question, im new to php.
Variables
Let me explain what i want with an example. I have 3 files :- File-A File-B File-C I am using a variable called $tdir in File-C. Its default value is stored in File-B. Now, there is a Form in File-A where i can input a certain value and when i click "Submit", the value will be stored as $tdir in File-B. From then, this new value will be used in File-A.
Get Variables
I want to transfer a variable to the next page. Here is the code: First Page: $page="1"; <a href="fav.php?page=$page">I like it!</a> Second Page, (retrieves the variable) $page = $_GET['$page'];
Sum Of Two Variables.
Im creating a small stats counter (god knows why after all the trouble it ahs caused me!) for my site, and getting all of the relevant data from the server log files. Getting the data isnt a problem, and slicing it up is fine but.. Ive created a rule that is trying to emulate a google analytics feature (the feature will count a visitor twice if they return after a certain amount of minutes even if its the same ip), but the code doesnt work. There are loads of different ip's in the log so I just cant understand why the code is interpreting just one ip. Code:
Getting All Variables
anybody know a way of getting all variables? the php parser engine must remember what each variable is... i just want to be able to make a debug type function which retrieves all of them....
If Problem With Some Variables Containing The Same Value!?
Hi all, I feel a bit dizzy. I have been sitting in front of this programm for 12 hours now or so and now I only wanted to add a little function which checks if the user is allowed to see edit and delete links. pretty easy hmm? ok here is the code: Code: function showsubmenu($userid, $dbName, $libid){ $lur="SELECT `ur_edit`,`ur_remove` FROM $dbName WHERE `user_id` = $userid"; $lurquery=mysql_query($lur); $lurresult=mysql_fetch_array($lurquery); $ur_edit=$lurresult[ur_edit]; $ur_remove=$lurresult[ur_remove]; // just for checking if the rights come correctly from the db echo "uredit= $ur_edit<br>ur_remove=$ur_remove<br>"; // edit link if($ur_edit == 1){ echo "<a href="edit.php?action=edit&libid=$libid class=head>edit</a> | "; } // delete link if($ur_remove == 1){ echo "<a href="admin.php?action=delete&libid=$libid class=head>delete</a> | "; } // back link echo "<a href="javascript:history.back();" class=head>back</a>"; } The idea is pretty easy. I got one additional table where the system stores rights for every action. The name for editing items is "ur_edit". 0 is not allowed 1 is allowed so as Admin, the system returns 1 for $ur_edit and $ur_remove. the query is correct! The problem: Only links displayed are delete and back. if I remove the edit lines, delete also vanishes. If I remove the delete lines, only the back link will be displayed. it should be: edit | delete | back but if you use the code above you only get: delete | back The syntax really seems ok to me and $ur_edit and $ur_remove are both 1. What am I doing wrong here??
Truncating Variables
I would like to truncate a variable to 0 decimals.. no rounding just choping the decimal places right off.
Dynamic Variables In Php?
Hi, I have a mySQL table that contains two columns column one is 'feature' and column two is 'feature_value' - some of the data is for example 'hair_color' - 'blue' 'hair_color' - 'blonde' 'hair_color' - 'black' 'hair_color' - 'gray' 'eye_color' - 'blue' 'eye_color' - 'hazel' 'eye_color' - 'brown' Yeah I know... definitely NOT third normal form. OK here's where it gets even better On one web page, I build select controls from this data. The name of the control would be the value of the feature column. So from the data above I would have a select control whose name would be name="hair_color" and another select name="eye_color" NO problems so far.... ok. Now after the user selects from the selects (get it, sorry).... i am processing the data. Although I use javascript for some client side validation... I also want to validate in php. (ok, just because I want to ok) NOW.. the web page form will post these two variables $hair_color' and '$eye_color' as described above. But I don't know ahead of time what these variables are because they're based on data from a table....... I go the table described above and select distinct on the feature column - I will return two rows.... see below while($row = mysql_fetch_row($result_set)) { $feature =trim($row[0]); } the value of feature in the first row is 'hair_color' and in the second row 'eye_color'-- What I'd like to do.... is to take the values in the $feature variable and create a literal variable that I can test for that was posted from the form........ so for example in the first row where $feature = 'hair_color' - I want to create a $hair_color variable...... because this is a variable of the select control from the form. Then for the second row where $feature = 'eye_color' - I want to create an $eye_color variable because again... this is the variable of a select control on the form.
Variables W/ Space Gets Cut Off On GET
I'm not sure why my text spaces aren't getting changed to %20. When I click a link w/ variables in it, the next page only gets the first word contained in the variable. Any idea why this is happening? I don't remember having to do anything when passing multiple worded values across pages.
Invisible Variables - How To
I have a tagged iframe and two variables ($loginuser and $password) in a script that I am trying to write. I want to include them as part of the URL href to a target program for rendering in the iframe without using javascript. The following works: Code: $src="http://www.host.tld/prog.php? loginuser=$loginuser&password=$password"; echo "<iframe id='myIframe' href=$src>No Iframes</iframe>"; but is undesireable. The variables can be read in the browser with View/Source. Same thing if I use target="myIframe". The only way I have been able to do this without javascript is to use the php script to write a temporary file (middle.php) that includes a redirection with the variables as in: Code: $src="http://www.host.tld/prog.php? loginuser=$loginuser&password=$password"; header(Location: $src); exit; and then call it from the main program as: Code: echo "<iframe id='myIframe' href='middle.php'>No Iframes</iframe>"; and finally deleteing the temporary file. This works ok and there is nothing in the browser to show the value of the variables nor is there anything in the frame doucment source. I don't like writing temporary files if I don't have to, however, and I think this approach won't work for a target program (http://www.host.tld/prog.php) that is expecting post variables. Anyone have an idea about a better way to do this, given the constraints stated?
Passing Variables
here is some of my code why wont it work it works when i replace $hello with $smith <input type="text" name="hello" value="smith"> <?php $db = mysql_connect("", "", ""); mysql_select_db("",$db); $result = mysql_query("SELECT first,last FROM employees where last='$hello'",$db);
|