Jump to content

Larry101

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Everything posted by Larry101

  1. Unfortunately the actual loop script is commercially sensitive and very long so I cant publish it BUT do you think if I removed the 'for' loop it would solve my problem? In reality the loop runs 10k plus times in the script.
  2. I have striped the code to this... basically the on a long run the echos dont output and the browser gets stuck. <? $sql = "select * from table where processed_state = \"Pending\" limit 1000 "; $qry = mysql_query($sql, $conn) or die ("FAILED: " .mysql_error()); while($rows = mysql_fetch_assoc($qry)){ // loop through Pending data - OUTTA LOOP ************************************************************* echo " OUTPUT DATA HERE"; for ($i=1; $i<=500; $i++){ // INNER LOOP ------------------------ //more code echo " OUTPUT DATA HERE"; //more code //more code //more code echo " OUTPUT DATA HERE"; } // for - INNER LOOP ------------------------------------ //more code //more code echo " OUTPUT DATA HERE"; //more code }// while - OUTTA LOOP *********************************************************************************************************************** echo " OUTPUT DATA HERE"; ?>
  3. Hi - I have a script that does lots of work in loops in loop using a database. I have coded lots of echo's to out put as it goes, problem is.. it doesn't output until the very end of the task - whgick is OK on a short run, but when it processes a really long loop it just doesnt out put anything and gets stuck. I have tried ob_start and ob_flush but it didnt make any difference. Any ideas on how to make a long script process output as it goes?
  4. Thanks again Insecure... that did work!!
  5. Thanks Insecure but there is no variable in the URL so I cant use the $_GET[] function.
  6. Hi if the URL is http://www.domain.com/?somedata how would I get "somedata" into a variable?
  7. Tried all sorts but eventually wrote this... bit long winded but seems to work $domain .= $_SERVER['REQUEST_URI'];// $domain = /TestArea2/members/index.php $domain_arr = explode('/', $domain); $arr_len = count($domain_arr);//get length of array for ($i=1;$i<$arr_len-2;$i++){ //loop through except last 2 $url_path .= "/" .$domain_arr[$i]; } echo $_SERVER['HTTP_HOST'] .$url_path ."<br>"; //prints www.domain.com/TestArea2
  8. Thanks but the realpath returned the absolute path but not the URL. Is there an equivalent to return the URL?
  9. I am trying to find the URL to a directory TWO levels above the script level (if you know what I mean). For example.. the script sits at http://www.domain.com/TestArea2/members/index.php BUT I need to find the path to http://www.domain.com/TestArea2/ the nearest I get is... $domain = $_SERVER['HTTP_HOST']; $domain .= $_SERVER['REQUEST_URI']; echo $domain; // outputs www.domain.com/TestArea2/members/index.php Is there a simple method to do this or have I got to split the string and work backwards? Many thanks
  10. Thanks guys.. I am reassured
  11. Hello I am updating a SQL database - basically adding to an account field as follows... $sql1 = "select * from member where username = \"$owner\" limit 1 "; $result1 = mysql_query($sql1, $conn) or die(mysql_error()); $row1 = mysql_fetch_assoc($result1); $total_commissions = $row1['total_commissions']; $total_commissions = $total_commissions + $_SESSION['cost_per_token']; //add to data $balance = $row1['balance']; $balance = $balance + $_SESSION['cost_per_token']; //add to data #-------------------------------------------------------------------------- #Update db $sql1 = " UPDATE member SET total_commissions = \"$total_commissions\", balance = \"$balance\" WHERE username=\"$owner\" "; $result1 = mysql_query($sql1, $conn) or die(mysql_error()); is there a way to add to the data from the UPDATE query? e.g; $sql1 = " UPDATE member SET total_commissions = \"$total_commissions\ + $_SESSION['cost_per_token'] ", balance = \"$balance\ + $_SESSION['cost_per_token']" WHERE username=\"$owner\" ";
  12. Thanks guys... The error was "Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/xxxx/public_html/TestArea2/admin/ad_tokens.php on line 26" but when i used curly brackets it worked with no error. Thanks for the help.
  13. Hi everyone I just getting back to PHP after a break but have forgot how to build a HTML table row. Here is the part of the code that builds up rows for a html table... while($rows = mysql_fetch_array($qry)){ $table .= " <tr> <td><input type=\"checkbox\" name=\"C1\" value=\"ON\"></td> <td width=\"87\">$rows['ref']</td> <td width=\"178\">$rows['transactionReferenceNumber']</td> <td>$rows['totalAmountReceived']</td> <td>$rows['myItemQuantity']</td> <td>$rows['flag_1']</td> <td>$rows['flag2']</td> </tr> "; } This causes an error as you might expect. Please tell me the best way to place the html code into $table
  14. Thank you very much Muddy_Funster. I didn't feel comfortable leaving off the quotations.
  15. Hi all... once again I am trying to re-educate my self into PHP after a long gap. I do not have a problem as such just a question... here is part of my script that doesnot work; <? $sql= "INSERT INTO member ( username, email ) VALUES ( \"$_SESSION['nm_username']\", \"$_SESSION['nm_email']\" )"; ?> The above errors because there are single quotation marks in the session variables. When I remove them the script works and the values of the variables seem to be correct! My question is - do I NEED the quotation marks in the variable and if so how should I write the query? Regards
  16. hallelujah... solved it... thanks for your help Ken2k7 you pointed me in the right direction. Coz I haven't been on PHP for a few years I was trying to retrieve the variable without using the $_COOKIE[" "]. When I implemented that into the actual script I was trying to fix it fixed the problem. :D
  17. The output was woot!Cookie Set OK...... When I run test1.php I get this.... Welcome guest! Array ( [logintheme] => cpanel [cprelogin] => no [cpsession] => closed ) OK.......
  18. I am using this to set the script.. test.php <?PHP setcookie("user1", "Alex Porter", time()+3600); echo "Cookie Set (supposeably!)<br />"; echo "OK....... "; ?> and then I am using this script to retrieve the info (I am running it from a seperate browser session)... test1.php <?PHP $the_date = date("m/d/y: H:i:s",$timestamp); if (isset($_COOKIE["user1"])) echo "Welcome " . $_COOKIE["user1"] . "!<br />"; else echo "Welcome guest!<br />"; print_r($_COOKIE); echo "OK....... "; ?> But it fails to pick up the cookie data plus I can't physically find a cookie in the files.
  19. Sorry.. the cookie doesn't seem to be setting.
  20. Can anyone see anything wrong with this code? I just cant seem to get it to work and I've tried it on 2 PC's :'( <?PHP setcookie("user1", "Alex Porter", time()+3600); echo "Cookie Set <br />"; echo "OK....... "; ?>
  21. Hi all, I want my affiliates to send traffic to my wordpress blog using their affiliate code located in the URL; e.g. mydomain.com/?id=theirID. I then want wordpress to replace [tags] on the page with theirID. This way, they will be affiliated with links on the blog. Is there a plugin for this or does anyone know how I may achieve this with PHP? Regards Larry.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.