Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Saving Result Of Function Without Being Echoed


I am trying to save the function "rand(1, 1000000)" in a variable but when I am for example trying:

$randomnumber = rand(1, 1000000);

it is executing it right ahead while when i try

$randomnumber = "rand(1, 1000000)";

or

$randomnumber = 'rand(1, 1000000)'

It is saving rand(1, 1000000) as variable.

But what I need is a variable saving the result of rand(1, 1000000) so the number does not change either.

Any ideas how I would do this?




View Complete Forum Thread with Replies

Related Forum Messages:
Saving A Result To Another Table
I have a script that will print out the results of a table and make a
calculation of a total of one of the columns. See example:

<?php

/* Database connection */
include(MYSQL_CONNECT_INCLUDE);

/* Select all pilots */
$query = "SELECT * FROM pilots ORDER BY pilot_num ASC";
$result = mysql_query($query);

/* Determine the number of pilots */
$number = mysql_numrows($result);

if ($number > 0) {
/* Print roster header
Change this HTML to fit your webpage layout */
print "<table>";
print "<tr>";
print "<td bgcolor=#000080 width=85 height=12
align=left><font face=Arial color=#FFFFFF
size=2><b>NUMBER</b></font></td>";
print "<td bgcolor=#000080 width=120 height=12
align=left><font face=Arial color=#FFFFFF
size=2><b>NAME /
EMAIL</b></font></td>";
print "<td bgcolor=#000080 width=130 height=12
align=left><font face=Arial color=#FFFFFF
size=2><b>CITY</b></font></td>";
print "<td bgcolor=#000080 width=93 height=12
align=left><font face=Arial color=#FFFFFF
size=2><b>COUNTRY</b></font></td>";
print "<td bgcolor=#000080 width=93 height=12
align=left><font face=Arial color=#FFFFFF
size=2><b>FLIGHT
TIME</b></font></td>";
print "<td bgcolor=#000080 width=75 height=12
align=left><font face=Arial color=#FFFFFF
size=2><b><center>STATUS</center></b></font></td>";
print "<td bgcolor=#000080 width=75 height=12
align=left><font face=Arial color=#FFFFFF
size=2><b><center>LOG
BOOK</b></center></font></td>";
print "</tr>";


View Replies !
ImageJPEG() - Saving Result From Browser With Filename While Using Sessions
I've created a PHP file called filename.jpg. It outputs a JPG. I've set up
a .htaccess file to force the filetype to PHP. The file is displayed in a
page on a browser. I cannot get the damn thing to save as my suggested
filename or even as anything but a BMP in IE6. I've tried a bunch of
different combinations of the content-type and content-disposition (inline,
attachment, filename, name) headers. Nothing has worked.

I've tried all combinations of the following header() string (regex for
brevity-I didn't actually use the regex characters):

Content-(T|t)ype: image/jpeg(; (file)?name="?xx.jpg"?)?

with and without:
Content-(D|d)isposition: (inline|attachment)(; (file)?name="?xx.jpg"?)?

followed by:
ImageJPEG($im,'',60);

After many hours pounding my head against the wall and RingTFingM, I
realized 2 things as I was writing this post.

The first is that I'm using session_start(). Take it out and I have no
trouble.

The second is that I've encountered this problem before, spent hours on it,
and finally gave up and passed all parameters to the script by $_GET.

I'd rather not do that again. The image is being used as a server-side
image map. Does anyone know how I can use session_start AND the
Content-disposition header? I've tried placing the header before
session_start, to no avail.

View Replies !
Mail Attachment Saving Function
here's a little function I threw together that can save attachments from messages retrieved via the IMAP library.

Note that the function takes two arguments, the first being the mailbox opened by imap_open(), and the second the message number of the message you want to retrieve the attachments/body from. note that the function dosn't check the validity of a message of $mnum actually existing, as in the code I wrote it for, the message number was checked for validity before calling the function. The function returns a string containing the body of the message, as well.

Oh yea, it also dosn't save attachments of type 0 (7-bit) and 5 (Other). still playing with that functionality.

View Replies !
Saving Form Variables Using A Java Function
I would like to know if it is possible to save a value from a php form in a session using a java function. What I am doing:

I have a php form. The form contains a textbox and 2 list menus (drop down box) The second drop down box relies on the selection made in the first.

within the reload() java function I save the value entered in the first list menu (using the onChange="reload(this.form)" ) I pass the variables in the url. The users selection loads values into the second list menu. Where the user can make a second selection. This value is passed using the same method.

What I would like to do is save the textbox (or all the entered values) values in a session using a java function. When the user changes the a value or enters one.

View Replies !
A PHP Function For Saving An Image To The Local Hard Drive?
I am looking for a PHP function that when run, would save an image to
the user's hard drive.

View Replies !
Being Echoed
I have following html before head of html in my page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

View Replies !
HTML Echoed Out
Does anyone have any idea why when I echo HTML it doesn't parse the HTML but outputs the code? I even added two <h2> tags manually and it works, so it's just from pulling it out of the database.

PHP Code:

<?php
//The <h2>s work fine but the array variable being outputted doesn't parse the HTML
echo "<h2>".$profile['biography']."</h2>";
?>

View Replies !
HTML Echoed
I have the notion that everything is more secure if everything is in php, and nothing is in html. Perhaps I am mistaken in my understanding. But, because I believe that everything would be more secure in php, I am trying to take an html form, and find a way to ECHO it in php.

It is an example form that I found in google.  It works just fine as HTML, and it is a submit to a php script which will receive the data through $POST. But, I am trying to build all the HTML in $form and then echo it. I am not having much success. Code:

View Replies !
How To Add Function Result To Array?
The way I'd like to set up a particular set of functions is to have them either return TRUE or, for example:

$errors[type] = "Sorry, the file type is not allowed. Allowed types are ".print_array_inline($acceptedTypes).". ";

Then later, I have a foreach loop that echos each array element. However, when I echo each array element is doesn't output the whatever the print_array_inline function does.

Any suggestions?

View Replies !
Formating Echoed Table
How would I format the table with borders backgrounds etc.

printf("<table>");

do
{
$myrow = pg_fetch_row($result_set,$rows);
printf("<tr>");
for ($i=0; $i < $count_ch; $i++)
{
printf("<td>");
printf($myrow[$i]);
printf("</td>");
}
printf("</tr>");

$rows++;
}
while($rows < $rowsnum);
}

View Replies !
Last Twelve Hours Echoed
I am so tried but can someone help and show me a basic way to only display the last twelve hours of results from the MySQL? I have a column with the time, how do I only show the last tweleve hours?

View Replies !
Echoed The MySQL Query
I'm currently building a time booking system, and what I have done is created a few tables in my database and populated these with some test data.

The problem I'm having is that I know for a fact that when I click on the 1st Sept for example the first couple of time slots have been taken,so for a test I've used the word 'booked', this works, if the time slot is not taken then it should say 'available', this doesn't do it.

I have echoed the MySQL query and I've test this on the MySQL console and it works, but yet it says 'booked' when its really not.

View Replies !
Variable In A Php Echoed Form
At the moment it prints " /> and I lose the variable.

<?php
echo '<form action="formt.php" method="post">
<input type="hidden" name="uname" value="$_SESSION["username"]" />
<input type="submit" label="submit"></form>'
?>

View Replies !
Query Result Navigator Function
I've just updated this, and I thought I'd also say that not only can this provide a page navigation for MySQL or other database results, but can be used to navigate other lists.. such as a file list. PHP Code:

View Replies !
Adding Result Row To Mail Function
I have an email script that will pull the addreses from my club membership database. That part works fine. the problem I am having is being able to include row results inside of the actual email message. My message variable is something like this: Code:

View Replies !
Storing The Result Of Javascript Function
how do I store the result of a javascript function into a PHP variable? I have a div that is hidden or shown based on whether or not a checkbox is clicked. Initially the div needs to be hidden.

So how do i make sure that it will be hidden in all browsers when the page loads. The code for hiding and unhiding it works in the different browsers i have tried, but not initially being hidden. attached is what I currently have.

View Replies !
MySQL Result To Real Array In Function
I'd like to create a function which input is the result of a mySQL
query.
The output should be exactly the same, only not a mySQL result array,
but a 'real' array.
So it should also get the fieldnames returned by mySQL and use those as
keys.

I can't get things to work properly: it should return a
multidimensional array,
like

$result_array[1] = array(
[field1] => field1 value,
[field2] => field2 value,
etc.
)

somehow my result is (with code below)

$result_array[1] = array(
[0] => field1 value,
[field1] => field1 value,
[1] => field2 value,
[field2] => field2 value,
etc.
)

+++++ code ++++++

$get_res= mysql_query(QUERY);

if( $res = mysql_fetch_array( $get_res ) )
{

do{

$result[] = $res;

}while( $res = mysql_fetch_array( $get_res ) );

};

foreach( $result as $key => $value ){

print_r($value);

};

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 !
Chmode With Mkidir Function, The Result Isn't As Expected
I've tried to create a directory with the php function mkdir(). I've used a "0777" mode , so that owner,group and other can read,write and exectue files in this directory.
There's no problem creating the directory, but after it has been created, its mode is "0755".

Where did I commit a mistake ?

View Replies !
Using The Function Prevents Accessing The Result Of The Match.
I don't know if this is possible, but it should be. However, it doesn't seem to be working for me. how I can get it to work:

I use :||: for my delimiter for str_replace, etc.

When replying, the new PM is appended in front of the existing chain of replies, thus the same table entry is used and updated each time. Problem is in storing the sent date, and providing time zone and format adjustments:

$string='This is the message that was sent on :|1161850848|:'

$newString=preg_replace('/([0-9]*)/',format_time(adjust_time('${1}')),$string);
// the result of this is as if ${1} = 0

$newString=preg_replace('/([0-9]*)/','${1}',$string);
// returns 'This is the message that was sent on 1161850848'

It seems that using the function prevents accessing the result of the match.

View Replies !
Search Function That Highlight Result Instead Of Filtering It Out
I am trying to create a search function that will jump to the page containing the result and highlight it instead of filtering it out. To more clearly illustrate what I mean take a look at this link:

I would like to search for eg. "bruce wayne" (its record number 30) and just have that row highlighted. Anybody who could steer me in the right direction would be a massive help as I've spent the last 2 days trying to work this out with no joy.

View Replies !
Accessing Session In A Php Page Echoed By Fstream
if I load a php page from controller.php like this:

$handle = fopen("http://localhost/MvCphp_1.0/View/maincatgory.php", "rb");
               echo stream_get_contents($handle);
               fclose($handle);

then the created session, in the file where I am running the above code,  for instance $_Sesssion['hr']='ge'; will not be accessible in echoed file above "maincatgory.php" I don't know why? and I want to know how can I access...?

View Replies !
Get A Database Stored Date Echoed On A Website
I'm trying to get a database stored date echoed on a website. The problem is it won't show up. This is the code piece getting the rows:

$row3 = mysql_fetch_array($result);

This is the piece declaring date to $actualdate:

$actualdate = $row3['date'];

This is the piece echoing the date:

echo $actualdate;

I'm sure I'm doing some damn mistake here, it's probably really easy for you other guys to solve.

View Replies !
Function To Test If Mysql_fetch_array($result) Pointing Last Record?
I try to perform multiple insert statment, but the problem is in the below codes, the last sql concatenation ends with ",". I wonder if there is any php function to test if the $result set contains the last record.

------------------
//Get topic id of vote_topic from last insert record
$sql_topic_id = "SELECT topic_id FROM vote_topic ORDER BY topic_id DESC LIMIT 1";
$result = mysql_query($sql_topic_id,$conn);
$row = mysql_fetch_array($result);

//Get all student info from stuinfo
$sql_strn = "SELECT strn from stuinfo";
$result1 = mysql_query($sql_strn,$conn);

//Dump all student strn into vote_status.
//Multiple insert statement? How?
$sql2 = "INSERT INTO vote_status (strn,topic_id) VALUES ";
while ($row1 = mysql_fetch_array($result1)){
$sql2 .= "VALUES ('".$row1[strn]."','".$row[topic_id]."'),";}
mysql_query($sql2,$conn);
---------------------

View Replies !
Refreshing Cache Through Php Header Function Yields No Result?
I am building a website for a client. He wants a login page with a "Your account" page for his clients. I am using a combination of javascript and php.

Upon succesful login $_SESSION variables are set to 1.
example: $_SESSION['logged']= 1;

If the client logs out due to idle time or pressing 'logout' these values are set to zero.
example: $_SESSION['logged']= 0;

Upon loading of "your account" and any of its sub-pages, that page checks $_SESSION['logged']. If the value is zero it redirects automatically back to the login page. Providing oppertunity to log in again if you wish.

The checking of $_SESSION['logged'] is supposed to redirect even if the client has logged out, but has pressed "back" on the browser to try and see a login page.

The page does not do this. Pressing "back" reveals the page. Interacting with the page or pressing "refresh" THEN causes it to redirect.

I need the page to auto-redirect, not show. I am aware that it is the page being cached and keeping those values until you interact with it. I have fully tested the header function in php. Using 'must-revalidate' & 'no-cache' and other version! (most info from php.net).

I get no errors when testing the pages, so my code is correctly spelled! But there is simply no reaction by the page, it just does what it does, which is not what it is supposed to do?

I ask for experience! Is there a specific way of doing the header functions? Perhaps it must be placed in a specific place in the page? And how can i check that the page is actually using the functions and not just moving over them with no action taken?

View Replies !
How To Create A Hidden Field Variable From An Echoed PHP Figure?
I have a PHP script on a shopping cart summary page that creates an invoice number and then echoes it to the page. This page, when submitted, will go to the shopping cart processor.

The echo portion of the script is working properly, it generates the number as intended.

My problem is that, not being very experienced in PHP, I want the invoice number not only echoed (which it is doing properly now), but also to populate a value in a hidden field that is submitted to the shopping cart processing page. My question is how do I populate the hidden field with the figure that is now being echoed in the script below?

The script that generates and echoes the invoice number is as follows:

<?php
echo "SA"; //department code
echo date ("mdy"); //date generator
// begin counter this reads figure from "count_file.txt"
if (file_exists('count_file.txt'))
{
$fil = fopen('count_file.txt', r);
$dat = fread($fil, filesize('count_file.txt'));
echo $dat+1;
fclose($fil);
$fil = fopen('count_file.txt', w);
fwrite($fil, $dat+1);
}
else
{
$fil = fopen('count_file.txt', w);
fwrite($fil, 1);
echo &#391;'
fclose($fil);
}
// end counter
?>

The hidden field is as follows:

<input name="Invoice_Num" type="hidden" id="Invoice_Num" value=" ">

I would like the value in the above to reflect the invoice number that is echoed by the above PHP script.

View Replies !
Warning: Mysql_result() [function.mysql-result]: Unable To Jump To Row 0
i want to grab the value of a sql entry. but the thing is, sometimes this value is <NULL>. i thought, no biggy, i'll just have an if statement:

if (is_numeric(mysql_result($query, 0))) {
//do something
} else {
//do something else using mysql_result($category_id_query, 0);
}

however, this doe not work. i get this error: Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 is there a way to check to see if mysql_result() is <NULL> without throwing an error.

View Replies !
Displaying Result 1-8, Then Result 9-17 Etc.
I dispaly the results from the database like this.

<? while ($row = mysql_fetch_array($prod_result)) {
$small = $row[0];
echo"<td align=center><img src="produkter/hardware/decks/$small"></strong></td>";}?>

But if there are more than 8 results, I wnat to dispaly the first 8 on one page, then the next 8 on the next page...How can this be done?

View Replies !
Saving XML To Db
What would be the best way to save XML to a database?

I mean I can use the example
'http://www.php.net/manual/en/function.mysql-real-escape-string.php'.

they give a function to prevent any SQL Injection,

function quote_smart($value)
{
// Stripslashes
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
// Quote if not integer
if (!is_numeric($value)) {
$value = "'" . mysql_real_escape_string($value) . "'";
}
return $value;
}

but then how do I get the data back, (as intended), from the db?
what would be the reverse of the above code?

View Replies !
Csv Saving
i have a form and it saves all logs into the enquiry.csv
everything is working fine except that for the message
text area, when i type something with spaces

example
test1
test2
test2

the output in my csv is being moved into other cells
below is my current code:

View Replies !
Saving Png
I used GD and created a png image, and then you press a "Save" button and it runs my save.php file,this file creates the image and then uses

<?php
Header('Content-type: image/png');
ImagePNG($im,$location);
ImageDestroy($im);
?>

to save it, the image shows up in the folder, but when I view it, it is just ablack box, my image wasn't really created. I can preview the image and see that it works, is there something I am missing?

View Replies !
Saving To PS Or PDF
I'm writing an application that needs to parse a database and then print the output with a header graphic to specific printers, depending on a field in the database. To do this, I'm thinking if parsing the database with php than somehow saving this output to a Postscript or PDF file with the graphic header, then printing this to the specific printer using lpr.

Can someone point me to a site or utility that'll let me save an HTML page in PHP to PS or PDF? Or if someone knows of a simpler way of doing this, please let me know.

View Replies !
Nesting Result Loops Within Result Loops Possible?
I'm looping through a query, and inside the while result output, I am trying to loop through a second query (created from the 1st query's row results).

I have checked that both queries return info.

I can see that the 1st while result output works fine, but when I get to the inner while result output, it never returns any rows (nothing in the while loop evaluates).

So, IS it possible to nest one query's output loop within another, or am I doing something wrong?

View Replies !
Creating A Result Page From A Result Page...
I have a contact management database (4500 records) where each record contains many columns = a lot of data to look at in one go.

So... I have created a search page to look for "Company" or "Name" which then returns a recordset with a primary ID number and a summary of 5 other fields.

This recordset is then displayed on a results page in a dynamic repeating table which just shows simple record lines.

My aim is to then be able to go from the results page to another detailed result page based on the ID of a specific selected record.

I understand how to generate the recordset from a text box but cannot find out how to create a recordset from a dynamic repeating table.

View Replies !
Saving File
When saving the file, I would like let the user to browse through the directory where they want to save the file (like window pop up sreen). may I know is it can be done using php?

View Replies !
Saving Images On The Fly?
but it just shows the images, what i would like to do it save the image from the script,

my code:

View Replies !
Daylight Saving
i still have the problem with daylight saving last Sun of March will increase 1 hour of the normal time and first Sun of Oct will set back to normal time: I try date("I") and it's doesn't work.

View Replies !
Saving A Session
I have been trying to find out how I can save a session - so far without success.

I use PHP in combination with MySql and I would like my users to be able to save their sessions in my database so that they can retrieve it later... Meanwhile, this will also allow me to analyze their choices (what searches they did, etc...).

I have been searching the net, but so far without a lot of success.

View Replies !
Saving Streamed Jpg
I have a requirement to programmatically save some images, which appear
to be streamed jpgs. If I make a call to the page which serves these
images, using a browser, then the picture appears, under a different
URL, almost as though the page was forwarded. The picture appears fine
if I put a link on a web page. But the usual copy() command doesn't
work.

View Replies !
Saving A Textarea
I have a textarea input box in a form. My client needs to be able to cut text from a document and paste it into the textarea for saving in the mySQL database. This part works correctly. Code:

View Replies !
Saving To A Floppy?
Hey, is there any way to save a file to a floppy disk using php?

The server will be linux and the local computer will be windows.

I need it so the user can put a disk in the drive, hit go, the php page
will create an excel file, save it to the users floppy drive and then
tell him to put another disk in and hit ok to restart the cycle again.
This will continue until all the needed files are build.

I know how to do everything except the save to the floppy part and I am
hoping it's possible.
If it's not, does anyone know another way?

View Replies !
Saving Php Results
I have an html code which contains callings to a php script which generates JPEG images
via GD library. When I select 'save as' in any browser two options are given (.html or .txt) but none of them allows to save the page as it is shown in the browser (with images). Where images should be there are only empty links....Does anyone have an idea about it?

View Replies !
Daytime Saving
I live in new zealand which has dayLight Saving which push 1 hour forward on the 1st Sunday of October, and put back on the last Sunday of March, I know that there is a daylight saving function in php DATE (I - capital i)

anyone know how to use it? as I remeber, it changes the setting when it's 3.00AM but not sure.. it may change the time when it's 0.00am i am not 100% sure about this .

View Replies !
Saving As WORD
How do i save some text thats is stored in an array... as a Word file
?



View Replies !
Saving An GD Image
after you create an image in GD how do you save it to your computer or database?

View Replies !
Saving Word Into .txt
I need to change a sentence from an input text box into words and store it in a text file (file.txt) Eg. "Can someone pls help me" .

Can
someone
pls
help
me

and then store all these into file.txt file.

View Replies !
Saving Show.php As A .jpg?
How can I save a show.php file as a .jpg or similar?

View Replies !
Saving From Textarea
I have a textarea field, and I enter text into it. Like this:
Today is...

a Nice day
and I save all from that field to a db field.
Now when I extract it from the db, it looks like this:

Today is...a Nice day
So there is no break after the "is..."

any ideas?

View Replies !
Saving JPG Images
This line of code aparently saves the jpg file:

 imagejpeg($image2,$src,95)

If the default value is set to 100, some of the saved files are larger in size than what they were uploaded (ie: uploaded as 300K, saved as 450K).  To keep the file size from bloating, I set the parameter to 95. But this causes the images to pixelate in 8x8 arrays, some worse than others. Is there a better function to save jpg images so that they don't weird out?

View Replies !
PHP And Saving Imgs
is there a way, and how, to have php take an image from a website, rename it and save it to your own server?

View Replies !
Cookies Are Not Saving
I have the following

$username="test";
$username="pass";
setcookie("username", $username, time()+3600);
setcookie("password", $password, time()+3600);



echo "<br>username:".$_COOKIE["username"];
echo "<br>password:".$_COOKIE["password"];

echo "Thank You. Your username is:".$username." <br>Your Password is:".$password;

for some reason the cookies are not saving -- what am i doing wrong?

View Replies !
Not Saving To Database
I'm making a website for a racing game, and I'd like to have a section of the site where drivers can post tips or tricks for setting up a car. Problem is, sometimes the tips post, sometimes they don't. I've tried LOTS of different combinations ... tip length, special characters, etc . Code:

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved