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.





Function Not Returning Expected Value


I have a php file that contains a couple of arrays used for
state/country pull-down lists. I have two global arrays and an accessor
method for each. I have some simple logging methods, so I know a little
bit about what I'm getting back. When I try to get the arrays from
another file using the accessor methods, I get no array back. Within
the file that contains the arrays, I can access them by global name and
also by the accessor methods. Any ideas why I cannot access the arrays
from another file? Code below.

<SNIP FROM CALLING METHOD>

require_once BASE . '/config/formfields.inc.php' // file with needed
arrays

// the calling method
function display_states($smarty){

logobj(function_exists(get_states)); // returning True/1
$s = get_states();
logobj($s); // no love here
logobj(BASE . '/config/formfields.inc.php'); // it's the right
file
}




View Complete Forum Thread with Replies

Related Forum Messages:
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 !
Returning Array Value From Function
I have a function whose purpose is to return an array of values to be used elsewhere on a page, but I can't seem to get it to ouput the array. (When I try to reference the $territory variable outside the function I get nothing.) Here's my function: Code:

View Replies !
Returning An Array From A Function
I have a function (fileTree) that recursively reads all the files in a
directory passed to it, and returns an array of the files, I have included
the code for this function below.

When I call this function, the bit of debug code at the end will correctly
print the array of files I am expecting, and then returns.

However, what is returned form the function isnt the array, is a scalar that
just contains the value of the last element in the
array

I am calling the function like this:

View Replies !
XML_unserialize Function Not Returning Anything
Has anyone used the XML_Library? The XML_serialize function works great, but I am having a problem with the XML_unserialize function not returning anything. I have e-mailed the author but have not received a response and I really need to get past this problem.

View Replies !
Returning A String From A Function
if (isset($search)){
return "<A HREF=javascript:popUp(emailsearch.php?mysearch=".$search.")>Email Search to Friend[/url]";}

something wrong in my return statement. The popup window is not opening.     

View Replies !
Function Not Returning NULL
Im working on a function that returns a NULL value if no value was entered into the form, otherwise it returns the value entered in the form. Heres the function, but its not working: Code:

View Replies !
Returning A Variable Generated In A Function
I have a function that is being called from the main script using include() and there is a variable (generated inside the function),that I want to make available to the main script. I tried using "global $var" inside the function, but I get a NULL string as the value, although I should be getting a timestamp, since $var = time();

View Replies !
Returning Mulitple Variables From A Function
Not sure if this matters but my function is actually part of a class.  I am just trying to return 2 variables, from what I have read I need to store these variables in an array, but I can't seem to get the data out. Code:

View Replies !
Returning Variables To A Calling Function
I have a system wherein different scores can be entered by month. The details for the selected month are displayed, and with a calendar box or by left and right arrows the user can move the form to different months.

I've done this via resubmitting on-clicks that load $_POST with the desired month and year.

When details are entered and the 'Save' button is pressed, javascript changes the form action to another PHP function and then submits the page. Code:

View Replies !
Array_multisort - Returning In A Function Out Of Oracle.
Returning in a function out of Oracle. Having a problem doing multisort on the arrays.

Here's some partial code of the function:

while ($row = oci_fetch_array($statement)) {
foreach ($row as $key=>$value) {
$$key=$value;
}
$result[$USR_ID][ITEM][] = $ITEM_ID;
$result[$USR_ID][TYPE][] = $TYPE_ID;
$result[$USR_ID][GRP][] = $GRP_ID;
}

array_multisort($result[$USR_ID][GRP], SORT_ASC, SORT_NUMERIC, $result[$USR_ID][TYPE], SORT_ASC, SORT_NUMERIC, $result[$USR_ID][ITEM], SORT_ASC, SORT_NUMERIC);

return $result;


View Replies !
Zip_open Function Returning Integer
I've been working on a script to download a zip file from an ftp server and unzip the contents into a folder. I'm able to get everything from the ftp folder and save it locally with no problems, but I cannot get it unzipped.

I spent some time looking through the php manual on http://php.net , but none of the functions that other users had provided have worked. Failing that, I wrote a simple bit of code from scratch that should do what I need, but I keep getting an error to the tune of: Code:

View Replies !
Returning False On Date Function
I need to get someone's age in years + months for different dates. For some reason, my input check isn't working and I keep getting a mktime error? Is there an easier way to return false if dates aren't splitting or numeric? PHP Code:

function getAge($date, $futureDate=false)
{
        if(preg_match('/^[0-9]{2}/[0-9]{2}/[0-9]{4}$/', $date) === false) { return false; }
        elseif($futureDate!=false && preg_match('/^[0-9]{2}/[0-9]{2}/[0-9]{4}$/', $futureDate) === false) { return false; }

        $p = split('[/.-]', trim($date));
        $start = mktime(0, 0, 0, $p[0], $p[1], $p[2]);

        $end = mktime(); // 1970s unix bday
        if($futureDate!==false) {
                $p = split('[/.-]', trim($futureDate)); // delimiter can be slash, dot,
.........................................

View Replies !
Passing By Reference Better Than Returning A Value When Calling A Function?
When I need a function to generate a string, I have two methods:
1. pass by reference: mystring = ""; myfunction( mystring ); // prototype of myfunction( &anystring );

OR

2. mystring = myfunction(); //which return a string. According to experience of C/C++, the former one is better as of the...

View Replies !
Select Query In Function Not Returning Content?
My connection works, my script runs without errors, warnings, etc, but the content that should be found from this function isn't coming through to the output? Code:

View Replies !
Returning NULL Vs. Returning FALSE
It seems to be a generally adopted convention to have a function return FALSE in case of an error. But if a function is supposed to return a boolean anyway, one cannot distinguish anymore between the "normal" FALSE and the "error" FALSE. So why not using NULL instead to indicate an error? Are there drawbacks I am not aware of?

View Replies !
Help: Date Function Not Returning Correct Date & Time
I have just notices that the date() function is not returning the correct
date/time on my "server".

I am running apache2 on my winxp pro laptop.

My system clock is set to the correct date, time and timezone, get the
results returned by date() are 11 hours behind.

View Replies !
Expected Output
When I try to test my setup by making the file test.php with the single line PHP Code:

<?php phpinfo(); ?>

then goto http://localhost/test.php it displays Quote:

<?php phpinfo(); ?>

instead of all the info.

View Replies !
T_OLD_FUNCTION Expected???
I use EngIn editor, my code ran ok there... but not when I ran it on my apache server.. got the following error:

Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in C:japachecaseFileCVf.php on line 5

Here's the code:

View Replies !
Loop Expected
i get it to loop, so that it keeps doing it for;

$start =10 then 20 etc right up to 1000

the function is;

function query($topic, $start = 0)

{
$googlelist = $this->_query("Google", $topic, $start);
$yahoolist = $this->_query("Yahoo", $topic, $start);
$this->found = array_unique(array_merge($googlelist, $yahoolist));
$this->counts = array("yahoo" => count($yahoolist), "google"=> count($googlelist), "total" => count($this->found));
return true;.

View Replies !
Could The Close_date Be One That Is Not The Expected Value?
Here's the code.

$link="http://xbox360cheat.org";
$close_date=$_POST["close_date"]; #last content change check
if ($close_date == 0)
$close_date = date("Y-m-d H:m:s", mktime(12, 0, 0, date("m"), date
("d")+7, date("Y")));
else if ($close_date == 1)
$close_date = date("Y-m-d H:m:s", mktime(12, 0, 0, date("m"), date

Could the close_date be one that is not the expected value? For example, if the month is 11 and $close_date == 7, then the mktime function should return the next year for the year value, not the current year. And if the day is the last week of December, than the month and year should change if close_date == 7.

View Replies !
Implode() Not Working As Expected
I have one page with a form that uses an array ($order) to print out ordered items. This page then posts to a second page to get personal information from the person ordering. Before posting the form, I implode the array into another variable ($items_ordered), so that I can print a summary of the items ordered on the second page.
(The following code is all within the <form> tags.): Code:

View Replies !
NULL Expected, Won't Show Up ...
I have tho following code.

$_GET['artile'] looks like this: /2006/03/lorem_ipsum

$locationinfo = explode('/', trim( $_GET['article'] , '/') );

list( $article_year, $article_month, $article_url ) = $locationinfo;

echo '<br>year: '.(($article_year === NULL)? 'null': $article_year);
echo '<br>month: '.(($article_month === NULL)? 'null': $article_month);
echo '<br>article: '.(($article_url === NULL)? 'null': $article_url);

The weird thing is, if $_GET['article'] is empty, $article_year isn't
NULL, but the rest is. This doesn't make any sense to me ...

View Replies !
Ini_set() Not Working As Expected
When running the following code I get a warning:

<?
ini_set('session.use_cookies',0);
?>
random text
<?
session_start();
?>

The output / warning I'm getting is this:

random text
Warning: session_start(): Cannot send session cache limiter - headers
already sent (output started at /path/to/file.php:5) in
/path/to/file.php on line 6

Shouldn't the fact that I'm setting session.use_cookies to 0, via
ini_set, prevent this error from taking place?

View Replies !
Preg_replace Not Matching As Expected
I'm attempting to write a bit of code that will parse a HTTP_REFERER from google and return the search data and the nationality (.fr, .co.uk, etc).

I can get a rough output (see bellow) but the search value (2 in the script) continues past the '&' character which is where I need it to stop. PHP Code:

View Replies !
CURL Results Not What Expected
I was playing with cURL on a website and it didnt work.  So I switched to a different website and it worked just fine.  So that little part of my brain that is always working started wondering why cURL wouldnt work with the first website that I had tried.

I'm hoping that someone here can help me figure out why this particular website wont work with my cURL script, and help me get it working. Code:

View Replies !
Sort Results Not As Expected
In the actual array I'm working with, the a, b, c's are primary keys. One shouldn't expect them to actually be in order. This example uses a, b, c to verify if a sort worked properly. I want to sort the array so the result will have a,b,c,d,e,f,g,h, etc in order. Code:

View Replies !
Not Getting Expected MySQL Error
I am inserting values into a row.. works OK

If I try to insert a value into a row that doesnt exist (using where)
it always returns true the same as if it did work

I want to update rows that have one unique field.. if the row doesnt
exists it should return 0 rows updated.. I then create the row...

But it always returns 1 even when I update a row that doesnt exist..
How do I get an error or a false return?

View Replies !
If Statement Not Working As Expected.
I am trying to get my error message to print if either the login is incorrect or the dropdown variable is "Unknown" I get no errors and I know that the variable is posting correctly. I think I'm missing something or put it in the wrong place. Code:

View Replies !
Ereg Not Behaving As Expected
I'm having a problem with the ereg function to verify a user submitted variable the situation is that the user is submitting a textarea post variable there are a number of allowed characters there are more in the actual application but i have removed to demonstrate the problem as removing them makes no difference the php code is as follows:

$message=$_POST['textarea1'];
if (ereg("^[A-Za-z0-9
]*$",$message)) {
$textValid=TRUE;
} else {
echo "error";
}

but it seems to act like

$message=$_POST['textarea1'];
if (ereg("^[A-Za-z0-9]*$",$message)) {
$textValid=TRUE;
} else {
echo "error";
}

View Replies !
Buffer Flush Doesn't Work Quite As Expected
I've got a PHP script (running on MacOS X, PHP 4.1.12) which uploads
bookings from one database to another, and I'd like to have the screen show
progress as it happens (each time I process a booking, I write a line
summarising it to the browser with 'print')

From RTFMing and Googling, it seems that I should be able to do this by
turning output buffering on and using ob_flush() et al. However, this only
sort-of works, in that instead of getting output line by line, I get a
multi-line chunk on the browser from time to time.

Am I stuck with having this chunk-by-chunk visualisation, or can anyone
please suggest a way that I can make it force each line to the browser as I
write it?

View Replies !
Unexpected Absence Of Expected Warning
The page 167 of book Learning PHP5 by David Sklar says that
setcookie() and session_start() must be added before any output.
I tried to use that functions at last line but no warning!.
The warning which i got 1 month back is not issued now.
------------------------------------------------------------------
The following is my PHP program
<?php

function Intelli()
{
echo"Hello P";
}

function Bitz()
{
echo"Hello MySQL";
}

;
$a = 1;
if($a)
$myFunc = 'Intelli'
else
$myFunc ='Bitz'

$myFunc();
print'header'

session_start();
setcookie('userid')
?>

----------------------------------------------------------------
The following is the output i got.
There is no warning

[tdphpadmin@trgbws40 ~/public_html/demo]$ php dynamicfun.php
X-Powered-By: PHP/5.2.0
Set-Cookie: ZDEDebuggerPresent=php,phtml,php3; path=/
Set-Cookie: PHPSESSID=bp1m17rlrgsa5g19tfekidov31; 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: userid=
Content-type: text/html

View Replies !
Predefined Variable Not Working As Expected
I have a script that was working fine until I had to reinstall everything.  Now my scripts says that :

PHP Notice: Undefined index: LOGON_USER in D:Inetpubwwwroot
ame.php on line 5

Where I have just made a new file to isolate the issue, but this derives from this script :

<?php

echo $_SERVER['LOGON_USER']; ?>

Which worked fine before.  Is this down to the way php is being run? As it stands it is being run via IIS 5 as cgi executable.  I've looked over the install txt and it seems as though I have done everything correct.

View Replies !
DomDocument::loadHTML - Expected Behavior?
Quick question about DomDocument::loadHTML (http://www.php.net/manual/en/functio...t-loadhtml.php) Why does this not create a parse-tree? Code:

View Replies !
Delete Query Not Working As Expected
I have 2 different php forms. One makes sure that a user has chosen an unique user name (below):

$query_rsApp = "SELECT * FROM users where UserName=".$Registered." ";

This Select query works right every time (as far as I can tell). I have a form that I want to use to delete user records.

This Delete query works fine if the username and password are both numeric... But if the username or password is text, it returns the error "UNKNOWN FIELD 'whatever'" where whatever is my search criteria that I am trying to use.

View Replies !
Unexpected Absence Of Expected Warning.
The page 167 of book Learning PHP5 by David Sklar says that setcookie() and session_start() must be added before any output.

I tried to use that functions at last line but no warning!. The warning which i got 1 month back is not issued now. Code:

View Replies !
Regex Doesent Work Expected...
i use this to get all html tags out of an string ..
preg_match_all('/<[^>]*>|[^<>]+/', $data, $contentParts);

worked wonderful till i noticed that this doesent work with something like

"{if $commandCount > 0}"

this will be split in 2 parts:
"{if $commandCount " and " 0}"

and the < is gone
It shouldnt split anyway when it detects an " < " or ">=" or " <=" and so on..

View Replies !
Imagecolortransparent Not Working As Expected - Any Ideas?
I'm trying to rescale a gif file with transparency but am having difficulty with the imagecolortransparent() function - It's not working as I would hope...

I'm telling it to replace the colour red with transparency and then overlay my transparent gif, but resized. For some reason, it is turning anything black in my transparent gif, transparent, instead of the red - Can anyone else figure out why it might be doing this? Code:

View Replies !
Elegantly Handling An Expected Error
I have a very modest database on my server and I use php to allow people to query it. Its very simple, they enter a value that should be in column 1 (account_num) and I return the value for column 2 (balance) (same row).

Here is the question: What if the value they enter doesn't match any values in column 1? Right now, I get this ugly error message: Code:

View Replies !
Line Breaks Don't Work As Expected
I wrote this small bit of code for a college class, but the instructor offered no feedback. Our textbook offered nothing and the teach yourself book I bought had typos in it. :mad:

I don't understand why the linebreaks in the php code didn't work properly. I ended up putting them at the beginnings of the next line, rather than the end of the previous line.

I think that's sloppy; I want to undertand why the line break worked on the first line but not subsequent lines. I expect it's something semantic, quotes or such. Code:

View Replies !
Problem Getting Script's URL ($_SERVER['PHP_SELF'] Not What I Expected)
I have a function that restricts access to a page to logged in users.
When a user who isn't logged in goes to the page, it will dynamically
generate a login form.

I'm trying to use it in conjunction with the free shared SSL
certificate offered by my host. To use SSL, you would change a URL
like this

http://mydomain.com/page.php

to

https://ssl.myhost.com/mydomain.com/page.php

My problem: when my script dynamically generates the login form, it
uses the $_SERVER['PHP_SELF'] value in the action field. But this ends
up being '/page.php' rather than '/mydomain.com/page.php' so my form
gets submitted to

https://ssl.myhost.com/page.php

instead of

https://ssl.myhost.com/mydomain.com/page.php

Simple I thought, I'll just use the SERVER or ENV variable that gives
me the full url. My problem: it doesn't seem to exist!

View Replies !
Apache ErrorDocument / PHP Header() Interaction Does Not Work As Expected
I recently worked on error handling and three related issues/questions came up.

1.) I am trying to trigger Apache ErrorDocument handlers by setting appropriate HTTP status codes in my PHP code, but I don't get the expected results. Code:

View Replies !
PHP 404 Document's REQUEST_URI Does Not Hold Expected Value In $_ENV And $_SERVER
I wanted to migrate some custom 404 error pages from shtml to php for the ease of email notification of lost pages. However when PHP processes the page $_ENV['REQUEST_URI'] and $_SERVER['REQUEST_URI'] both now hold the error page eg "404.php".

Does anyone have advice on how to dodge this? Should I just continue to use shtml error pages and
do an shtml include on a little php script to do the mail?

View Replies !
SQL Not Returning Value Even Though It's There...
I have been having fits with a simple PHP script and I'm hoping it's
something that someone here can help me with. Basically, when I execute the
SQL statement directly on the MySQL CLI, it returns. But when I run the same
statement through the following PHP script, I *think* it returns an empty
set.

I say I think because the if(mysql_num_rows($recset) > 0){} block is
executed. But when I try to retreive values stored in my array,

=== SCRIPT ===
<?php
include("db.php");

$incoming_user = stripslashes($_POST['username']);

$sql = "SELECT * FROM tblSisters WHERE username != '$incoming_user' AND
isTaken != 'yes' ORDER BY RAND() LIMIT 1";

$recset = mysql_query($sql, $conn);

if(mysql_num_rows($recset) > 0){
$row = mysql_fetch_row($recset);
echo "<table border="1" align="center" cellspacing="7">
";
echo "<tr>
";
echo "<th>USERNAME</th>
";
echo "<th>WANTS MAIL</th>
";
echo "</tr>
";
echo "<tr>
";
echo "<td>$row[username]</td><td>$row[wsm]</td>
";
echo "</tr>
";
echo "</table>
";

// Update the database to reflect the new selection

$sql2 = "UPDATE tblSisters SET isTaken='yes', takeBy='$incoming_user' WHERE
username='row[username]'";
mysql_query($sql2, $conn);
}
else{
echo "<h2><u><b>RECORD RETREIVAL FAILURE</b></u></h2><br>
";
echo "The secret sister database could not be queried. Please try again ";
echo "later or contact the system administrator.
";
}
?>
=== END SCRIPT ===

View Replies !
Not Returning First Row
I have the following code, and it's connecting and pulling the information, however, when only one line is returned, it's not displaying it. Though if I have 2 rows, it will display the 2nd row but not the first. Code:

View Replies !
SMS Returning...
In the client side i have a popup menu, if this menu pops up and in that time refresh comes this menu drops down in the default state. Is there any decision how to fix this situation? I see in some sites <iframe> which reloads a php every ... seconds, may be i can use it to popup sms? or have any other decisions?

View Replies !
Returning The Whole URL
im trying to retrieve the entire URL using php and so far not had much luck, i have tried using <?php echo $_SERVER['REQUEST_URI'];?> which will return everything after http://localhost:6789. here is the entire URL...

http://localhost:6789/p03272434/emudom/register.php?UName=seen using <?php echo $_SERVER['REQUEST_URI'];?> returns..... p03272434/emudom/register.php?UName=seen

can anyone help ?

View Replies !
SELF Not Returning URL
I use $_SERVER["SCRIPT_NAME"] in order to work out where on the server the PHP app has been installed. This is then used (amongst other things) to build absolute links in the resulting page sent to the client, of the form:
<a href="<?=_INSTALLDIR?>index.php">Link</a>

This works great on a couple of development servers, with a fairly standard Apache installation, but on the big ol' live server (Apache 2, PHP 5) it doesn't.

This seems to be because of either virtual directories and/or URL rewriting (?!) that results in SCRIPT_NAME / PHP_SELF etc. all returning the file system path to the current file, and *NOT* the URL that appears in the address bar, which is required to build the links. Code:

View Replies !
Way Of Returning Something Differently??
I have created a table with one of the columns being a datetime column.nOnce the date and time has been collected off of the person submitting, i would like to show the date and time in the way of:
Dec 22 2000 22:09:01
Is it possible to do this via PHP rather than it outputting the usual:

View Replies !
ID Of Record Not Returning ?
The following code returns the fields from the row ( $product for example is used later and displays OK ) except the 'prid' field ( only ever has zero), which is the unique ID for this table.
Any thoughts appreciated - PHP Code:

View Replies !
Returning References
according to the php manual, it said:

Do not use return-by-reference to increase performance, the engine is
smart enough to optimize this on its own.

I doubt if this only apply to the PHP5 engine, while if I am using
PHP4, performance is a factor to continue to use return by refercnece?

View Replies !
Returning Results With An '
I am using this script

$mresult = mysql_query("SELECT DISTINCT game FROM vids order by id desc limit 50", $link) or die ("query 1: " . mysql_error());

while ($mrow = mysql_fetch_array($mresult))
{
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM vids where game = '$mrow[game]'"), 0);
}

but for any $mrow[game] that has an ' in it a 0 is returned, how do I fix this?

View Replies !
Returning All Rows Instead Of Row By ID
When I try to call data for only one person using the below code, it displays everyone in the database. What am I forgeting to do? Im refering them to this from options.php?id=<? echo $row->id; ?> PHP Code:

View Replies !

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