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.





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 Complete Forum Thread with Replies

Related Forum Messages:
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 !
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 !
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 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 !
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 !
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 !
If Loop In A While Loop Producing Incorrect Results
I have this code that checks to see what the value of "del" is and places a certain word depending on if its a 0 or 1. PHP Code:

View Replies !
Creating Table Rows For Ever Other Loop In A WHILE Loop
I'm trying to create a table using a MySQL fetch array while loop that would look like this:

CONTENT1     CONTENT2
CONTENT3     CONTENT4
CONTENT5     CONTENT6

I need a <TR></TR> for every other piece of content. But I don't know how to do this with a loop that uses a MySQL fetch array

while($row = mysql_fetch_array($result, MYSQL_ASSOC))

{
PHP CODE THAT IS LOOPED;};

I'm trying to remember from my old college Java class that we did something with loops for whenever the counter variable was even the loop would do something special... I don't know if this is possible with a while+mysql_fetch_array loop though.

View Replies !
While Loop In A Foreach Loop.... Semi-results!
I am echoing a mysql database result which is stored in the database as such "Superman, Batman, Wonder Woman, etc".

I am using the explode to split the into an array using the comma as the delimiter. Then I am trying to get it so if I click on Superman I am taken to the Superman profile page... Batman I go to the Batman profile page. Code:

View Replies !
Creating A For Loop Inside Another For Loop.
I'm trying to write a script that will display questions that are in one flat file and answers from another flat file. In addition, there are copies of these files with their own data in multiple folders.

I created a for loop to work with an array of the different file paths to the different folders. Then I created a for loop inside of that one to display the questions and answers files that is in each folder. All I get when I run the script is the first folder and it's questions and then it stops there. PHP Code:

View Replies !
Get A Varable To Loop Out Side The Loop
i need to get the varable to loop out side the loop but the condition set within the loop so the varable loop's outside. Code:

View Replies !
Loop Running Inside A Loop
Having a problem with the following; PHP Code:

$last_id = mysql_insert_id();
    
$type_count = count($types);
    
for ($i=0; $i < $type_count; $i++) {
        
$match = "";

if ($types[$i] == $featured[$i]) {
    $match = "y";
    }
                    
    $q_add_types = "INSERT into company_ins (Id, company_id, ins_id, type_featured) VALUES ('', '$last_id', '$types [$i]', '$match')";
        mysql_query($q_add_types) or die(mysql_error());
}

The INSERT query does not run when I insert the inner parenthesis. Does anybody know why?

View Replies !
For Loop And While Loop. Which One Is Faster?
For loop and while loop. which one is faster?
I see many articles fighting over it and different people come up with
different results.

View Replies !
How Do I Construct A Loop Within A Loop?
Everytime I try this, the loop kills and I get 0 results. Is it possible to make a loop within a loop for example: Code:

View Replies !
Loop Isn't "processing" On It's Last Loop
I have a loop that pulls timestamps from a database, converts them to hours:minutes:seconds echo's that then adds all of them together and echo's that as well. The problem I have is on the final loop it isn't doing any of the math. The code will pull the timestamps and convert them and even display the converted timestamps. It just won't do the calcualtions and then echo it. Code:

View Replies !
For Loop In PHP
I am trying to print a HTML table using PHP (with a countdown counter) but I do not see the table being display. Can someone highlight the error i m making ...

<?php
$input=8;
print $input;
print "<table border=3 bordercolor=0084A5>";
for ($cnt=$input+1 ; $cnt = 1 ; $cnt=$cnt-1)
{
print "<tr>";
print "<td>$cnt</td>";
print "</tr>";
}
print "</table>";
?>

View Replies !
Help In Loop For
Suppose I have this:

for($i = 0; $i < count($data); $i++){
$blocked = isBlockedForMe($my_id, $account_id); // true or false
}

I want when the $blocked is true to SKIP to the next step, I dont want
to BREAK, I want something like this:

for($i = 0; $i < count($data); $i++){
$blocked = isBlockedForMe($my_id, $account_id); // true or false
if($blocked){
....SOMETHING HERE TO SKIP but continue in the loop
}
// I dont want to show/execute what is below
............
............
}

View Replies !
For Loop Q
I have a "for loop". In this "for loop" a variable called $reg is set.
Each iteration of the "for loop", $reg is assigned to a new value.
My question is: how I can store the values of $reg each iteration in an array?

Below is some pseudocode, which I hope further illustrates what I mean.

$count = 60;
for ($i = 1; $i <= $count; ++$i) {
$reg =
}

This has got me a bit stumped.

After I have managed to make the array.
I would then like to explode this array out into variables - each one assigned a value of $reg

I realise that this may be quite a basic Q. And i really do apoligise. I have read up on arrays and am having trouble applying it to this
situation. Thanks very much.

P.S A further complication that I would like to accommodate is that $reg may be assigned a number of values in a single "for loop". I would like to
collect all these values.
The pseudocode for this:

$count = 60;
for ($i = 1; $i <= $count; ++$i) {
$reg =
$reg =
}

If this post is difficult to follow - dont hesitate to post back and I will try my best to expand. It is just I didnt want to make this post too long and
put people off.

P.S It may be helpful to know what is actually in the "for loop":

for() {

$regex = "/(([A-Za-z0-9]+_+)?[A-Za-z0-9]+-+)?[A-Za-z0-9]+.+)?[A-Z
a-z0-9]+++))*[A-Za-z0-9]+@((w+-+)?w+.))*w{1,63}.[a-z
A-Z]{2,6}/";
preg_match_all($regex, $data, $reg))

}

View Replies !
If/Then In A While Loop
I tried a bunch of different things, but am I able to do an if/then within a while loop? Here is the code that I am basically trying to do... PHP Code:

View Replies !
While Loop...
I've been working on a relatively simple function, that just won't work. Here it is:
PHP Code:

View Replies !
For Loop Or While Loop
I was wondering if this could be achieved with a for loop or a while loop basically returning the time for up to 20 years: PHP Code:

View Replies !
While Loop
I have a while loop thats get comments on news articles from a database. I am using a class as my database connection method. It only gets the first record. Here is my code:

View Replies !
$i++ Loop
What I'm trying to do is echo a error message if a field(s) is left blank without having to do alot of if statements. The code I have now works but will only show one number
at a time. PHP Code:

View Replies !
For Loop?
I'm trying to limit the number of cells in a table to 4 across

echo "<table border=1>";
echo "<tr>";
while($result = mysql_fetch_array($sql)){
echo "<td><IMG SRC="$result[photo]""></td>";}
echo "</tr>";
echo "</table>";

so if there are 15 entries in the db, it gives me 15 cells in one row. How can i limit the cells in a row to 4, and have it generate however many rows to display all. I've been experimenting with for loops, but no luck.

View Replies !
Loop Through JS Using Php?
I am trying to loop through a JS script as below using php to get the contents for a drop down list but I cant seem to get the loop to work. Here's what I have been trying..

// Heres the JS for the drop down list. I cant have this static as it is here as there could be 10-20 results in the drop down list so I need to loop through my DB result and loop the below script also Code:

View Replies !
LOOP IN A LOOP
I am making a navigation system for a website and I want all the links to be in a table on a database so that the links can easily be added to or subtracted from when found necessary. The way the navigation works is that it is a horizontal navbar with drop down menus filled with sub categories Code:

View Replies !
Using A While Loop In A For Loop - Can This Be Done?
can you use a while loop inside a for loop; without contradicting or excluding your for loop? I would test it myself; except my server is having Server Error 500 issues right now. so I am not able to do a trial and error test at this time.

something like this:

for ($x = $skip2;$x<=$pagedisplay;$x++){
while ($myfield != $maxed_out) {
  echo " <a href="". $_SERVER['PHP_SELF'] ."?skip=$x">". ($x+1) ."</a> ";
 }
}

View Replies !
For Loop
I work mostly with flash but use php to talk to databases so I am not strong in php. I am passing some variables from flash that I want to add to a database. They are in the form of sid0=A&sid1=B&sid2=C and so on, n is the total number of variables passed. I believe the server I am working on uses PHP 4.1. Code:

View Replies !
Loop Only Gets 1 Value!
And it kicks out the results on the page in hyperlinks, all the zipid's are 14, they should be looping through and getting the search_id that matches the zipcode. Code:

View Replies !
While Loop And Div
I have some code which loops whilst there are some results in the database.  These are displayed inside a while loop. However any div inside the loop does not display. Code:

View Replies !
Loop
I'm trying to add the following link to my display page. 

<a href="applyforstake.php?item_id=1>Apply"

This is the code taken directly from the display page:

echo "<td>"."<a href="applyforstake.php?item_id=1">Apply"."</td>";

This code works well for displaying the link in my display page, however, I want the item_id to be equal to the auto_increment column on each row.  In other words, for the first row on the display page, the item_id will be 1, the second row item_id should be 2 and so on for however many rows are in the table. How do I accomplish this.

View Replies !

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