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.





Cleaning Up After A Script Runs


how do you clear all varialbles and arrays after a script is run?




View Complete Forum Thread with Replies

Related Forum Messages:
User Runs PHP
I have an app that uses PDFLib to read some images off the file system (Red Hat linux) and puts them into a PDF. I have permissions set on the directory to be readable by the owner and the group, 'images'.

I made apache a member of the group 'images' but get a permission denied error when trying to read an image from the images directory. Is there some other user that owns the PHP app.

Env.
PHP 5.03
Red Hat ES4
Apache 2.02

View Replies !
PHP Only Runs From Command Line
I know very little about PHP, but I was just curious to know
why exactly would some PHP code run fine from the command line but not
from the browser?

I'm just curious. I was working with someone else's PHP code that
supposedly created MySQL tables in a database and for some reason it
just wouldn't create the tables at all (no specific error message).
Someone suggested I run from the command line and when I did, it
worked...

View Replies !
Bad Query Runs With No Error!
there must be some weird setting on the mysql database i am using for this latest project. the following query runs without throwing an error:

SELECT start_time, last_access_time, user_ip session_data FROM demo_sessions WHERE id='b31fd40c7e9135f2b52e4f17c23fc3c54da137b8'

notice there is no comma between user_ip and session_data

what's the story here? seems like a real security risk to me because my server won't log bad requests.

View Replies !
Why Script Runs Differently With CRON?
I am running a PHP Script that downloads my RSS News (and the accompanying Thumbnail images)from the Web. When I execute it from CMD line, no problem. The News and Images are downloaded, great!

When I begin to update via CRON, no images are downloaded/written to disk.--I don't have this problem when it's RUN from a shared hosting account, it's only on my home Linux Box.

View Replies !
Bug 23891 MySQL Runs Out Of Connections
http://bugs.php.net/bug.php?id=23891

According to this report, what the person was asking isn't a bug, it's
a feature (rimshot).

I'm running into this problem almost exactly, and really don't
understand what the answer is. The support person snidely suggests
reading the manual, which is always great advice, but in this case
really doesn't help out.

Could someone explain what "If you use mysql_select_db() or slightly
different connection string you can have more open connections then
you have process." means?

If I don't use mysql_select_db, then what do I use?

View Replies !
EXEC() Runs Process In Background
Exec, shell_exec, system, popen functions all run the process in the
background.
how can i get it to run the process normally.
my code looks like this:
<?
exec("batch_file.bat");
?>

am i doing anything wrong?

View Replies !
Close Window After Script Runs
When a user clicks on a link in their email, I have a browser window that opens in the background and runs a script confirming their desire to be added to our email directory. I basically want this window to open, run and then close without the user having to deal with it.

Is there a way in PHP to close the window after the script finishes running in it? Or should I revert to JavaScript? I want the script to be mobile so I've sort of ruled out processing it server side. TIA.

View Replies !
How Often Does Garbage Collector Runs In Sessions?
Does anybody knows how often the session garbage collector checks for expired session to delete them? is it possible to modify this timeframe? is it possible to call this function manually?

I am storing my sessions in a mysql database and i am using a session expiration of 5 seconds (just for testing), but after the session is expired the session record in the db table still exists.

and it looks the sessions aren't expiring either because if you still have the session cookie you can keep up with the session. Code:

View Replies !
Email Form Which Runs From An Iframe
I have set up an email form which runs from an iframe. The only problem is that when the script redirects the user to the success or error pages, these pages open within the iframe. Is there a way to specify the target window as 'parent'? Someone said that this could not be done via the php script and would have to be done with javascript in the html form itself.

View Replies !
Optimizing Query That Runs Slowly On Linux
I was wondering if anyone has any insight into why the query I have posted below runs exceedingly slow on my Linux server. I am using Php with a MySQL database. On both my development computers the query runs briskly. They are however both Windows boxes, one running Windows XP and the other running Windows 2000 Professional. Here is the culprit.....

View Replies !
Counter - Increased By One Everytime The Loop Runs
i want to make a counter that i can echo. its going to be used in a while loop so i want it to be increased by one everytime the loop runs so each time it runs it would look like this:

counter=1
counter=2
counter=3
etc.

View Replies !
Php Script Auto Runs At Specific Time?
Is it possible to have a php script automatically execute at a certain time without having to visit the page or manually executing the code?
For example, execute test.php every hour?

View Replies !
Switch Statement That Runs Through Cases Numbered 1-100:
I have a switch statement that runs through cases numbered 1-100:

What is the most optimal way to run this switch?

switch($a){

case 1:

case 2:

...
}

View Replies !
MySql Is Loaded When Runs From Command Line, But Not Through IIS
Sorry for the newbie question, but I've been searching and searching and
haven't found an answer to this one yet.

I installed PHP and MySql (both latest versions) yesterday on a machine
running Windows 2003 Server with IIS6. Code:

View Replies !
Cleaning Up
I've made the roomlist for my server but as you can see the topics look pretty out of it with all the colour codes and what not. Is there a code that can clean it up a little.

View Replies !
How Do I Create A Link That Runs A MySql Query When Pressed!!
I Want To Create A Link, And When You Press That Link It Runs A MySql Query.

View Replies !
Header Function Runs Before Update To Database Is Made
I have been having some problems with a part of my login script. This is the two lines of script I am having problems with:

mysql_query("UPDATE " . $userName. " SET login = '$loginIN' WHERE pass = '$password' AND course = '$courseID'");
header( 'url=http://www.somewebsite.com/logged_IN.htm' );

The problem is that when this php script is executed the second line executes before the first and an update to the database is not made. I also tried the script without the second line and the first works then.


View Replies !
Query Runs In Mysql But Returns Error 1064
The same query runs in mysql and in Zend interface but not runs when using inside php script. I am receiving the error:

"1064 - You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near
'str_qry_Insert' at line 1"

INSERT INTO fnd_script_type (type_name) VALUES ('test1')

I already have tried it with as:

INSERT INTO `fnd_script_type` (`type_name`) VALUES (`test1`)
INSERT INTO fnd_script_type (`type_name`) VALUES (`test1`)
INSERT INTO fnd_script_type (type_name) VALUES (`test1`)

what am i doing wrong ?

View Replies !
Cleaning Forms
I want to stop people inserting characters into forms (such as !"£$%^&*()><?.,).

What's the best way of doing this? Can I stop them from doing it to return a message, or is it better to just wipe the characters before inserting into a database, or both?

The only symbols I need is for an e-mail field, which are   . - @    otherwise it's just numbers 0-9 and letters A-Z. I found a script to disable input but it doesn't stop people from finding other ways of inputting bad characters.

View Replies !
Cleaning Up An Array
I was trying to filter the contents in an array, and it seems to work, but I've got an issue with the indexes. When I unset() an element, if I count() the number of elements, I still get the same number that I had before filtering. I'd also like to make my indexes go back to 0,1,2,3... Code:

View Replies !
Data Cleaning
I'm making a php XML parser that loads data into mysql database. I'm using just the basic XML functions. The files I'm parsing are uber huge, so I can't use one of the easier XML parsing methods that load the whole file into memory. So anyway, I read a file line by line, and pass each line into the parse. I keep getting invalid character errors. I use the utf8_encode() function and it got a little further. I added a function to replace all &'s with &amps; (which apparently is a bug in the XML file, that this isn't already done) and it got a little further. But its still not making it nearly all the way through the file.

This particular is 256 MB that I'm trying to parse, though once this is squared away, I'm going to have an even bigger one I want to build a parser for to run once a week. So what I really need, is a way to clean the xml data before giving it to the parser. With MySQL, i use the myql_real_escape_string() function before giving it data, and it works nicely. Is there any function or technique I can use to do the same kind of cleaning to lines of XML files? Even if it just deletes "illegal" characters?

View Replies !
Cleaning Up Text
I have a text variable that I want to strip of a section of each line. below is a sample of the text I have for the variable Quote:

Richfield (pop. 34,439)
Robbinsdale (pop. 14,123)
Rochester (pop. 85,806)
Rosemount (pop. 14,619)
Roseville (pop. 33,690)
Sartell (pop. 9,641)
Sauk Rapids (pop. 10,213)

what I am wanting to strip out is the end area the.

View Replies !
Cleaning An Array
I have a form that submits an array. Such as:

<input type="text" name="aName[]">
<input type="text" name="aName[]">
<input type="text" name="aName[]">
<input type="text" name="aName[]">

I need to "clean" this info before inserting it into a database, etc. Code:

View Replies !
Cleaning Up A QUERY
$limitvalue = $page * $limit - ($limit); 
    $query  = "SELECT * FROM Feed_3PT_SF, View_Member, View_Office WHERE Feed_3PT_SF.TOWN_NUM = '$id' AND Feed_3PT_SF.LIST_AGENT = View_Member.MLS_ID AND Feed_3PT_SF.LIST_OFFICE = View_Office.MLS_Number ORDER BY LIST_PRICE ASC LIMIT $limitvalue, $limit";         
    $result = mysql_query($query) or die("Error: " . mysql_error());

Is there anyway I can clean up this query? It takes way too long for 100 or so results to display on the page.

View Replies !
Query Runs Multiple Times Under Heavy Server Load.
I have been having an issue with some MYSQL queries running multiple times when the server is under a heavy load. 

Example, if I do an 'update Table1 set item1 = 0 where 1 = 1'

This runs fine under normal conditions, but will repeat itself multiple times when the server is under load.  Is this just an optimization or server resource issue.  If so, I would assume the query would just timeout and not run at all instead of running a few times.

View Replies !
Cleaning Up After Php Build And Install
I've compiled a custom version of php with extensions persuant to my
needs, but now want to clean up the files used in the compilation.

When the php cgi is compiled, are all the extensions compiled into the
one file, or does the cgi reference libraries pointed to in the php
configure statement? If it references other files, how do I know which
ones it points to, so as to know what I can and can't delete.

View Replies !
Cleaning MS Word Input
I have a problem with a form, and I have tried various permutations of
htmlentities() and html_entity_decode() to resolve, but without success.

Here is the workflow.

1: User pastes MS Word formatted text into form field.
2: Server uses mail() to send input text to mail client.
3: Recipient pastes text into html file.

The problem is that MS Word contains peculiar characters for things like
bullets, which come out as tabs, which then come out as different, but
spurious, html characters in the html translation.

Does anyone know of a function(s) that can clean up MS Word input into
something that can be simply pasted as plain text without spurious
characters?

View Replies !
Cleaning Customer Data
At what point is it wise to clean the data entered into a form by your customer, and to what extent?

For example, can malicious scripts be sent via a simple e-mail form, or only when data is collected and stored in the database? And is the use of stripslashes() and strip_tags() sufficient to remove any threat, or is there something else I would need to do?

View Replies !
Cleaning Up Session Cookies
I have a problem where session cookies get left inside
the temporary folder. Is this a common problem or is
there perhaps something I've over looked - there a
way to make sure the session variables get cleaned up?

View Replies !
Cleaning Html Tags
somebody knows any way to put off all html tags from a file. I want to store cleaning pages for information purposes.

View Replies !
Cleaning Up Array After Unset()
I'm working on an e-commerce site, and one of the things I need to do is split an existing order into two orders. The problem I'm having is not
creating the new order, but getting the remaining items from the original order cleaned up in the array. What I've tried to do so far is:

1) The data is stored in a serialized array in the order_data field in the orders table. When the order is selected, it is unserialized and called
$order_data. Each item is a three item array containing price, quantity, and sku (i.e. $order_data[$i]['price'], $order_data[$i]['quantity'], etc.).

2) On the order details page, the items in the order are listed using the price, quantity, and sku fields. There is a checkbox for each item that is
used to indicate the items to be split into the new order. The name is split[] (to create an array of just the selected items), and the value is the
sku. The $order_data array is put into a session variable.

3) On the page that processes the split, $old_order = $_SESSION['order_data']. So now I have two arrays: $old_data contains the entire original
order, and $split contains just the selected items.

4) I then go through and compare each item in $split[] against each item in $old_order. Once the current item in $split finds a match in $old_order,
it is put into $new_order, and I use unset() to remove that item from $old_order:

for ($i = 0; $i < count($split);$i++)
{
foreach ($old_order as $key => $value)
{
if (array_search($split[$i],$value))
{
//add item to new order array
$new_order[$new_counter]['attribute_sku'] = $value['attribute_sku'];
$new_order[$new_counter]['price'] = $value['price'];
$new_order[$new_counter]['quantity'] = $value['quantity'];

//increment index counter
$new_counter = $new_counter + 1;

//increment order total
$new_order_total = $new_order_total + ($value['price'] * $value['quantity']);

//delete item from order_data array
unset($old_order[$key]);
}
else
{

View Replies !
Phpdig Cleaning Index
Ive just taken over the hosting of a site which uses phpdig as a site
search function, a program I have absolutely no knowledge of. Does
anyone know how i can immediately clear the index of redundant data and
also how i can set up cronjobs to do this regularly or where to change
the frequency of these cronjobs which i believe are already in
existence (just too infrequent)

View Replies !
Cleaning Up Data In An Array
I have an array with 10 items in it. How do I go about clearing all spaces before the data?

Ex:
Before:         jacob
After: jacob

Also some of the data looks like this, World&#32;of&#32;Warcraft&#32;Guide

How do I go about checking each value for this &#32; and replacing it with a space if its there?

View Replies !
Cleaning Information Retrieved
I was reading through this PHP security book and it recommends cleaning/screening/sanitizing information retrieved from the db prior to displaying it. Is this something that everyone recommends, or is it considered overkill?

Like I know to use htmlentities() to clean up these fields for proper display, but do I need to run everything through some eregi() checks or something to validate the information again before displaying it? Or does this all depend on how secure the db server is?

View Replies !
Cleaning $ POST Values
I'm trying to clean up some POST variables in this form and running into some errors when doing this:

function cleanDB($value)
{
// Stripslashes
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
// Quote if not a number or a numeric string
if (!is_numeric($value)) {
$value = "'" . mysql_real_escape_string($value) . "'";
}
return $value;

I keep getting an error at the foreach statement saying the '&' is unexpected and it was expecting a '$' but the PHP manual for 'foreach' has the same code. Is there something else going on here?

View Replies !
Cleaning Uploaded File Name
I have spent hours (literally) tring to figure out the regular expression to clean the name of an uploaded file. I find that my clients often try to upload non-images, so I can check if its a '.jpg', '.gif' etc, but what about if they name their files 'cupboard.html.jpg'? This is what I have so far (after checking the file): PHP Code:

$photo = 'cupboard and other illegal chars' here!@#$%^&*(.html.jpg'

    if (preg_match("/jpg|jpeg/i",$photo)){$image_type=".jpg";}
    if (preg_match("/png/i",$photo)){$image_type=".png";}
    if (preg_match("/gif/i",$photo)){$image_type=".gif";}

    // Don't process non-images
    if (eregi('.jpg|.jpeg|.gif|.png',$photo)) {    

        // Take out illegal char in name
        list($name)=explode($image_type, $photo);
................

View Replies !
Pointer Examples Of Cleaning
I have managed to create a very basic CMS, the CMS cover 6 pages and each page can have its title, pagetext, image link 1 and 2 altered.

I have doen the best I can but, I imagine that the code I have produced is somewhat ugly and could be clearer and slimlined. I have included the code for both the form page and the post page. Code:

View Replies !
Session Garbage Cleaning
I recently wrote a script that counts the sessions on the server. BUt since I'm on a shared host, it counts it for all sites on the server. Well I changed the session save path and now it saves in my public folder and the script worked how it should, only counting mine.

But doing this resulted in another problem, the sessions seem to get saved, but are never deleted. I thought the PHP GC would take care of this automatically. Here is the session part of the php.ini, I thought it'd delete this after 5min: Code:

View Replies !
Cleaning User Input
Is this enough to clean all user input before its inserted into the database, or do I need to do more? PHP Code:

function preclean($value) {
if(get_magic_quotes_gpc())
  return htmlentities(preg_replace('/[^wds'"!&,.!?]/i', '', mysql_real_escape_string(str_replace('>', '&gt;', str_replace('<', '&lt;', stripslashes($value))))));
}

View Replies !
Cleaning Form Input
I cant seem to find my mistake after checking the manual many times. PHP Code:

$wrong ='""'
$trans = array('"' => "&quot;", "'" => "'");
echo strtr($wrong, $trans);

View Replies !
POP Account Creation Script On CPanel. Runs Fine On Win2000, Not On Linux.
I am facing a weird problem. This is a POP account creation script. If I run it from my Win2000 PC, it creates the POP account. But when I run this script from the Linux server (CPanel is also on that server), it does not create any POP account.

View Replies !
Working With Dates - Runs And Queries The Database To Produce A List Of Information
I have a script that runs and queries the database to produce a list of information, based on a date range. This is to fllow up on a script that is automatically run each Sunday night.

What I want to try and acheive is, for example, if someone manually runs this report on a Tuesday the script will assume that it is run on the Sunday night, to make sure the results are exactly the same as the emails that have gone out. PHP Code:

View Replies !
Cleaning Up User Form Input In Php
Does anyone please know why when trying to clear up user input that has been entered into a form, php only clears up most of it and not all?

For example, using stripslashes to remove all slashes from a variable after a user has submitted quotation marks ("") into a form.

The quotation marks cause the variable being parsed to contain slashes.

e.g. a user enters """""" into a form , the variable returned to php becomes """""

So if I only wanted the quotation marks, I thought the stripslashes function would achieve this.
However, it only removes 3 of the 5 slashes leaving 2 unwanted slashes behind.

View Replies !
Strategy For Creating Files And Then Cleaning Up
I'm using PHP 4.3. There is a section of my application in which I'd
like users to be able to download a custom file. The file would be
different for each user, so I was planning on creating it on the fly
when they click "Download". However, I would like to delete the file
from the server a certain period of time after they've downloaded it.
(It's a 3 or 4K file). How can I do this?

View Replies !
Sorting And Cleaning Array From 4 DB Fields
I have 4 fields in my database that I am trying to combine and present as a unified dropdown. I've gotten the basic sort and display of the info to work, but don't quite know how to remove spaces caused by empty field nor how to make the dropdown unified. Code:

View Replies !
Cleaning User Input, Is This Safe Enough?
I've written a small function that cleans up all user input before entering it to the DB. I'm wondering, is this sufficient or am I missing someting?

function clean_text($text) {

$text = str_replace("<", "&lt;", $text);
$text = str_replace(">", "&gt;", $text);
$text = strip_tags($text);
$text = htmlspecialchars($text, ENT_NOQUOTES);
$text = mysql_real_escape_string($text);

return $text;
}

View Replies !
Cleaning A String Before Inserting It Into A Php File
other than:

< ? > ' " $

what else should i escape from a string if i'm to write it into a php file?

i'm writing the following line to my vars.php file

$file_contents .= "define('".$var_name."', base64_decode('".base64_encode($value)."'));
";
I wanna get away from using base64 since it's completely unreadable, but I don't want to create an exploit either.. ($var_name is already clean, only [A-Za-z\_] accepted).

View Replies !
XML Parsing Problem, Data Cleaning
I'm making a php XML parser that loads data into mysql database. I'm using just the basic XML functions. The files I'm parsing are uber huge, so I can't use one of the easier XML parsing methods that load the whole file into memory.

So anyway, I read a file line by line, and pass each line into the parse. I keep getting invalid character errors. I use the utf8_encode() function and it got a little further. I added a function to replace all &'s with &amps; (which apparently is a bug in the XML file, that this isn't already done) and it got a little further.

But its still not making it nearly all the way through the file. This particular is 256 MB that I'm trying to parse, though once this is squared away, I'm going to have an even bigger one I want to build a parser for to run once a week. Code:

View Replies !
Cleaning Form Input Data
Im looking for a function that will clean user submitted form data. I've looked all around the web for a good function that will do this, but all the ones i have found are really super simple or super complex. i just want a basic function that will clean the input and help reduce risk or causing errors while inputting the data into the database and also removing html tags, code, and other things that can cause problems.

Does anyone use something similar in their own code? If so could you please paste your function and maybe a simple explanation of what it does. I am really just not sure what things are the most important things that need to be cleaned out from the form input.

View Replies !
Form Data > Validation And Cleaning
I am using the following algorithm/flow/pseudocode for
validation and cleaning of data entered by the users
in the form( consisting of fields like name,
main article(text type in db),
mood for election(should ONLY be 1,2,3... 6). Code:

View Replies !
Cleaning Up The Mail Body - When The Email Has Attachments.
I have a problem extracting the body from an email when the email has
attachments. Instead of just getting the body of the mail I am getting
something like (where the body is simply 'another attachment' plus
some other ads from yahoo):

View Replies !
Tool For Cleaning Up PHP Code - HTML Tidy Like
I have a bunch of files with PHP code. These files were written by
multiple developers with different coding styles and is just so
painful to read them.

Could you recommend any tool I could use to clean up PHP code -
something like "HTML Tidy for PHP"


View Replies !

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