How Can I Assign Output To A Variable?
I'm trying to send an email and would like to put the output of some of my script into the body of the email. Here's the part that needs to be executed: PHP Code:
View Complete Forum Thread with Replies
Related Forum Messages:
Assign Function Output To Variable??
I've found some references to this topic at : http://forums.devshed.com/showthrea...ion+to+variable but it does not seem to be working for me. here's a snippet... <? PHP function listPeople ($getArray) { foreach ( $getArray as $val ) { echo "$val, "; } } $foo = listPeople($splitDirector); ?> The function works, and as you can see i'm simply trying to assign the output of the function to $foo. But instead, the output is written to the page where I assign it... like a print or echo statement, and the variable $foo is empty.
View Replies !
Assign Value To Variable
Is there any way I can use a function to create a variable and assign a value to it? I have a Perl script that returns some LDAP information: sn=Shore givenname=Mike logintime=20041008153445Z logindisabled=FALSE Instead of parsing this text and assigning the values, I was wondering if a function exists where I can pass a variable name and a value, and the variable would be created. ie. somefunc("sn", "Shore") Would create the variable $sn and assign the value "Shore" to it.
View Replies !
Assign To Variable
I am trying to take data from the database and assign it to a variable but i'm not sure how this is the code ive been trying $sql = "SELECT Name FROM Names WHERE Name = 'Peter'"; while($row = @mysql_fetch_array($sql)) { $var == $row['Name']; }
View Replies !
Is It Possible To Assign A Whole Function Or Block To A Variable ???
Is it possible to assign a whole function or block to a variable ??? eg. <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre> <? if (db_num_rows($qid_p) == 0) { ?> <li>No <? } ?> <? while ($prod = db_fetch_object($qid_p)) { ?> <p><b><a href="product_details.php?id=<?=$prod->id?>"><? pv($prod->name) ?></a></b> <br><? pv($prod->description) ?> <br>$<? pv($prod->price) ?> <br>[<a href="cart_add.php?id=<?=$prod->id?>">+ Add to Cart</a>] <? } ?> How to assign this code to a unique variable ???
View Replies !
Ways To Assign A Value To A Session Variable.
I am wandering which way to assign a value to a session variable exist. Which of the following examples will work. Example #1: session_start(); session_register("ex"); $ex = 2.0; Example #2: In first.php: session_start(); session_register("ex"); In second.php: $ex = 2.0; Example #3: In first.php: session_start();...
View Replies !
Assign Variable From Database Field
Is there a way to assign a variable from a database field? I'm thinking along the lines of $make = $row_rsList['make']; $model = $row_rsList['model']; then they'll switch out based on my SQL WHERE statement. This valid syntax?
View Replies !
Assign Userid To A Session Variable
When a user logs into my system, i assign their userid to a session variable [php] $_SESSION['userid'] = $myrow[0]; [php] and then a user logs out, i do the following [php] $_SESSION['userid'] = '' session_write_close(); [php] so, when a user clicks on a link to a page they should only see when logged in, i do the following test [php] if (isset($_SESSION['userid'])) { header('Location: members.php3'); } [php] but the logout does not seem to work for some reason? userid still seems to be set after running the logout script, any ideas? am i doing something silly?
View Replies !
Assign A New Value To A Variable Passed From An Html Form
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.
View Replies !
Multi-Dimensional Arrays - Assign Variable
It's a simple question, but I'm just not getting it. I have two files: <?php $precinct = array ( array ( number=>2324, centerlat=>-122.31705665588379, centerlong=>47.710367959402525, etc... <?php include ("precinctdata.php"); $filename = $_GET['id']; $number = $precinct[filename-1][number]; etc... I want to assign the value of "2324" to the variable $number. I've done this with arrays that start with number=>1, 2, 3, etc., but not successfully with specific values. What am I missing?
View Replies !
Assign MySQL Function Result To PHP Variable
I know to use: mysql_fetch_row($result) to convert a row from a SQL query result set into an array for use with PHP. but in the case of SQL queries that return one value, such as calls to MySQL functions, is there another PHP mysql api function I should use. For example, right now I use a "workaround" technique from PHPBuilder: $result=mysql_query("SELECT COUNT(*) FROM tablename"); list($numrows)=mysql_fetch_row($result); Rather than using this "workaround" code is there a way to simply assign the result of the MySQL function query to a variable. $result=mysql_query("SELECT COUNT(*) FROM tablename"); $numrows=mysteryfunction($result);
View Replies !
Assign Variable To A Block Of Html Code
Is it possible to assign variable to a block of html code? Something like this : $myblokvar = "<table width="487" border="0" cellspacing="0" cellpadding="0"> <tr> <td><table width="487" border="0" cellspacing="0" cellpadding="0"> <tr> <td><img src="images/bartitle_login.gif " alt="Login" width="475"...
View Replies !
Assign Variable Name As Variable
I want to be able to create a foreach loop that will go through all the intended POST variables and then assign it as a standard variable. For example, I want to have $username = $_POST['username'] without even knowing username exists in the context of the foreach loop. Code:
View Replies !
Extract Variable From Database, Then Output That Variable.
I have this strange problem (and probably also a strange question). Let's say you set a variable $blah. The variable has 'test' as content. When I write the variable ($blah) to a database (and not the content of the variable 'test') and I want to output the variable again, I get $blah as output. And not 'test'. PHP Code:
View Replies !
Output A $variable
Hello lovely helpful people, i need to out put: $src = array( dynamically and am having a problem when you use this echo("$src = array("); the $src is seen as a variable itself and so not echoed as it is empty, how can i get round this.
View Replies !
Variable In DB Output
I'm pulling HTML from a DB and would like it to respond to variables from the outside. Say I have this in my MySQL field: <?=$name?> $name = "Jack"; $rq = $db->query("SELECT * from greetings WHERE `id` = '$gid'"); while ($r = $db->fetch_array($rq)) { echo $r['greeting']; }
View Replies !
Output From A For Loop Into One Variable
I know the answer to my question may be quite obvoius, one of those days I guess. The kind of day that me and me head is not running on all cylinders. The question: How do you take an output from a for loop and place it in variable to echo.
View Replies !
Include Output As Variable
I'm working with some code, and have run into an issue that, after a long search on the forums, I still haven't located a resolution to. I'm familiar with includes, and have used them quite a bit with the last several webpages I've designed. However, currently I have data from an external source that I can add as an include file (the output is a text string) but the location I need to add this data is inside a variable string. As an example : PHP Code: $display_content = " <tr> <td>blah blah</td> </tr> <tr> <td> [NEED INCLUDE DATA HERE] </td> </tr> <tr> <td>blah blah</td> </tr>"; ..........................
View Replies !
Can't Output A Variable To HTML
I have this code on a page: <p class="appTitle"> <?php echo "$appTitle"; ?> </p> But the resulting HTML is: <p class="appTitle"> </p> $appTitle is a global variable which I've declared at the top of the page in a require_once file like this: $_GLOBALS['appTitle'] = "My App Title"; According to my debugger, $appTitle is defined with the correct value when execution reaches that point. I've also tried, <?= "$appTitle" ?> However this work fine: <?php $appTitle = "My app"; ?> <?= $appTitle ?> I have a feeling the answer is something totally obvious, and I'm just not seeing it.
View Replies !
Streaming Output To A Variable
I am trying to find a way to stream output to a variable. Basically I have a file that mostly an html document (it does have one or two php tags) that I want to include, but I don't want it outputted, I want it put into a variable.
View Replies !
Use Stripslashes() To Get A Clean Output Of My Variable
I have begun to use mysql_real_escape_string() to prevent injection attempts. Now, and rightly so, when I echo the output backslashes are added before illegal characters such as ' and ". My question is can I safely use stripslashes() to get a clean output of my variable. I shouldn't have to worry about mysql injection at this point, but are there any other securtiy worries? I have also begun using htmlspecialchars().
View Replies !
Saving Output Of PHP File To Variable
I've got a script i wrote that is piecing together a CSV. Part of this task is to include HTML code inside of the CSV. What i'm trying to do is save the output of a file like text_file.php to a variable like $text_file_output. I can't figure out a way to include the output of a PHP page to a variable.
View Replies !
Limit Output Of A Variable (length)
Hi im scripting a site for a newspaper where I have to display a page (a category) which displays summaries to the entire articles On the category summaries page I want to show either 3 full sentences (looking for three periods) or I want to show X amount of characters in length. I have all the text stored in one variable.... whats the best way to do this?
View Replies !
Output Format For A Timestamp Date Variable
I have a variable - $lastdate - that is the latest date any record in a MySQL database was updated. Its MySQL format is TIMESTAMP. If I say [echo $lastdate] I get the output I'd expect - 20060424221549 which is a YYYYMMDDHHMMSS format. I'd like to be able to display that using a format of mm/dd/yy with no leading spaces on the month and day. I don't know what the php command is to do this. In other words, I'm trying to display a variable - $lastdate - formatted a certain way. I know that the formatting string n/j/y will get my output looking as I'd like, but I can't figure out how to apply that to my variable.
View Replies !
Capturing PERL Script Output Into PHP Variable
This must be easy, but I'm missing something... I want to execute a Perl script, and capture ALL its output into a PHP variable. Here are my 2 files: ------------------------------------- test3.pl ------------------------------------- print "PERL Hello from Perl! (plain print)<br> "; print STDERR "PERL This is text sent to STDERR<br> "; $output="PERL Some output:<br> "; for ($i=0; $i<5; $i++) { print STDOUT "PERL $i: This is text sent to STDOUT<br> "; $output .= "PERL line $i of output---<br> "; } print $output; exit; ------------------------------------- passthru3.php ------------------------------------- <? $command = "/usr/local/bin/perl"; $pgm = "test3.pl"; print "PHP: Before passthru, in PHP...<br> "; $result=passthru("$command $pgm your_variable"); print "PHP: After passthru, result=($result)<br> "; ?> ------------------------------------- OUTPUT: ------------------------------------- PHP: Before passthru, in PHP... PERL Hello from Perl! (plain print) PERL 0: This is text sent to STDOUT PERL 1: This is text sent to STDOUT PERL 2: This is text sent to STDOUT PERL 3: This is text sent to STDOUT PERL 4: This is text sent to STDOUT PERL Some output: PERL line 0 of output--- PERL line 1 of output--- PERL line 2 of output--- PERL line 3 of output--- PERL line 4 of output--- PHP: After passthru, result=()
View Replies !
Capturing Print Output Of Function To Variable
I have a function, say: function printTable($Variables) { ?> <table> <tr><td>Your name is</td></tr> <tr><td> <?php print $Name; print "</td></tr></table>"; } (Obviously not my exact function, but a simple one to demonstrate my needs... The function I have inherited is much bigger with much mixed php and html like the example) It is currently used to print the same data table on many pages. I have been asked to have the system send this data table by email, so what I want to do is run the function, but send the output of the function to a variable, in the same way that print_r($arr,1) will return the output instead of printing it.
View Replies !
Load The HTML Output Of A File Into A Variable?
How can i load the html output of a file into a variable.. Kind of like include()ing or require()ing a file.. but not echoing the content.. but saving it to a variable.. Can it be done? I dont want to use fgets because they are PHP files.. and i want to get the HTML as if a user opened with a browser..
View Replies !
Adding Variable Output To An Array (beginner)
I have a variable that stores a temporary password. I'm just learning about arrays. I know this is wrong $pwList[]= ($newPW); I want to add the value of the $newPW which keeps changing to a unique variable and store each one in the array. How do I do that? Code:
View Replies !
Increase Variable Digit Output Amount
I'm working on a small script that uses polygons to find pi, and I need a way to increase the default amount of digits that are presented. Currently, each variable is displayed with 13 digits. I'd like it to be closer to 30, or higher for better accuracy. Any way to do this?
View Replies !
Cannot Re-assign $this ...
I'm one more guy having the cannot re-assign $this problem. someone left a php4 file here containing the lines |function linkbar() |{ |if(func_num_args() == 1) |{ |$this = func_get_arg(0); |return; } ... |} inside a php4 class definition. func_get_arg(0) in this case delivers an object - working fine in php4. I struggled a bit with the & referencing (while not really understanding it and the problem) but gave up. how must I modify the code to get it to work in php5?
View Replies !
Output Variable Contents In Htm File From Php File
I have a PHP file. No MYSQL database. I'd like to have it open an .htm file and output the results in the php file to the .htm template. So, for example say there is a bunch of variables called: $make $model $year I want to open a .htm file and output the contents of $make, $model & $year in the htm format using variables in the htm itself. ie. {make} {model} {year} and it would import the contents of each into the corresponding tag.
View Replies !
PHP 5 Re-assign $this PROBLEM
Just a quickie, in case it's been covered, like a million times or something. I'm self taught, and thought I was being pretty clever when building a "messaging" class. The idea was to abstract "html email", "text email" and "sms message" up a layer into a "message". To get a message started, I call on something like this: $msg = new Message("sms"); Message (which re-assigns the $this variable) then looks something like this: class Message{ var $message_hash; var $message_path;//this can be changed, in case stuff is moved in future... function ryan_Message($type=""){//starts the whole thing switch($type){ case "html"://this means an html email include_once("HtmlMessage.php"); $this = new HtmlMessage(); break; case "text"://this means a text mail include_once("TextMessage.php"); $this = new TextMessage(); break; case "sms"://this means an sms message include_once("SmsMessage.php"); $this = new SmsMessage(); break; }// end switch }// end function }// end class Each class has methods that are named the same, but act a little differently, so, basically, I can use the same set of commands to compose a message and send it, regardless of what type of message it is. Things work fantastically under php4, but I know that when I swap over to php5, it's going to throw a hissy fit, because reassigning $this is not allowed. Aside from going around the Message class, and just starting messages of a particular type from scratch: Is there some sort of cunning retro-fit I could do to the Message class, so I don't have to trawl through thousands of lines of code?
View Replies !
Assign Value On Click
is there a way to change the value of a variable when a hyperlink is clicked? like im include()ing a variable $content. and when you click it changes from URL to links or whatever?
View Replies !
Assign Value To The Link
I am creating a order-online application. I create some links in my html file. And in my table that I created by mySQL, there are some fields including picture_id, picture_name. What I want is to assign the picture_id to the link so that the picture_name will be selected (using mySQL) when the link was clicked. Can someone tell me how to write PHP code to assign the picture_id to the link?
View Replies !
Assign Include
if I can assign the output of an included file like include("file.php"); to a variable? I tried $content = include("file.php"); but it does actually include the file. I want the output kept in the variable and not be displayed, because I plan to use the variable later with a template engine.
View Replies !
Assign All The Values
How do i assign all my values of a row: I found the following: is it a good way to do: Code: $row = $rs->GetRowAssoc(false); Code: $strSQL = Select * from users where id_user=ཊ' $rs = $dbconn->Execute($strSQL); $row = $rs->GetRowAssoc(false); $data["login"] = $row["login"]; $data["fname"] = $row["fname"]; $data["sname"] = $row["sname"]; $data["country"] = $row["country"]; $data["city"] = $row["city"];
View Replies !
How Do You Assign A Various Number Of Variables?
I'm struggeling with a small search engine here. I'm trying to put everything together myself, but I have a problem. I've made a small form where search-words can be entered. This string is put into a variable $search. Then I've split this string up in pieces using the SPLIT command. something like this: list ($one, $two, $three) = split ('[ ]', $search); This works very nicely, but there is only one small problem. I can't possibly know how many search words will be used. It could be only one, but it could very be 10 or more (although unlikely). I thought about creating 10 variables, and in case they use less, they are just blank, but then if I use a OR function between these empty variables, the complete database (MySQL by the way) is called for. I don't know if you're getting the picture, but I want to know how I can assing a number of variables not knowing the amount in advance.
View Replies !
Assign Japanese String To Var
Following code contains japanese string that is assigned to variable $str. code ============= <?php $str = "$B%0%C%I%P%$%T%+%=(B"; ?> ========= When i am executing above program it gives me error as following. Parse error: parse error, unexpected $ in /var/www/html/bhavin/mohla1.2.2/b.php on line 3 Do anybody have solution for the above problem. How can i assign above japanese string($B%0%C%I%P%$%T%+%=(B) to variable without error.
View Replies !
Trying To Assign Number To Image..
I am working on a countdown script that will display the number of days to go to an event. I am after a graphical version. I have the code working that displays the amount of days to go to the event but I now want to display that number as a graphic. Whats the way of parsing the varible with "19" in it to make up a graphic? I have graphics for digits 0 - 9 made. Do you use some sort of array?
View Replies !
Extract 5 Rows Assign Name
I want to extract the last 5 thumbnail names added into my products table and assign each one a variable, for example: thumb0452 = '$thumb1' thumb0234 = '$thumb2' thumb0678 = '$thumb3' thumb0876 = '$thumb4' thumb0123 = '$thumb5' I assume I would start with something like this: PHP Code:
View Replies !
Fatal Error: Cannot Re-assign $this
i am running a code created with php4 on a php5 engine and I am running into problems with the $this . In php4 its a variable and in php5 its a ref to a class object (if am right) I get the following error in a class "Fatal error: Cannot re-assign $this in {path}" which is caused by this line "$this = new $db( $serv, $user, $pass, $dbName );" How can i resolve this ? am thinking of renaming $this to something like $this_var but then this is likely not to work.
View Replies !
Assign Table Value As A Session??
someone logs into my application - a login function runs from a pinc file. What is suppose to happen is if the username and password match - it is suppose to assign a session to the username - which is being passed from form and to the first and last name which are in the table for the user. Can I assign a session variable to value in a mysql table? It does properly set the cookie I am assigning on the setCookie line but is is not setting any of the three sessions. Here is the function I am using: Code:
View Replies !
|