Jump to content

townclown

Members
  • Posts

    14
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

townclown's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Unfortunately that doesn't work for me i did try before when creating the function to stop the request. abort() just does not cancel it for some reason.
  2. Hi, I have an ajax function that calls a php script which loops until data in a database changes and returns xml to the ajax function -> which then calls itself again. Works a charm, but, if you refresh the page while the loop is running it takes AGES to reload. I assume the PHP script is waiting to timeout? I added a button which calls a function to stop the loop(will not get into it but it stops the PHP loop using session variables), after which you can refresh and the page reloads swiftly. Is there anyway i can call that function when the user refreshes the page - my php is 10 times better than my javascript im afraid. Thanks in Advance. Darren
  3. info:Windows, Apache, PHP5, SQL Server 2005 Hi, What is the quickest way to access a single value when querying a database. $getMsgID = mssql_query("SELECT TOP (1) msgID FROM dbo.messages")or die("Couldn't access table"); Is there a quicker way to access that single value then doing something like: $row = mssql_fetch_array($getMsgID); $latestMsgID = $row['msgID'];
  4. Nevermind then.. solve it myself! clearstatcache() the initial modtime gets cached when the loop starts. Using clearstatcache() in the loop fixes this issue.
  5. the time.txt file (the getTimestamp function returns its modified time)
  6. Hi guys/gals Having a bit of an issue here. What I am doing is using AJAX to check for a file getting updated. Now before I get flamed.. the problem has nothing to do with the AJAX, but rather the PHP script that it accesses. I don't claim to know too much about PHP so this might be an obvious one, but I tried for a few hours before turning to PHPfreaks. Basically, i want the following code to loop for a defined period of time (10 seconds here was just for testing, it will be increased) and when it detects that the file has been modified (the SESSION['timestamp'] variable is initialized prior to running the AJAX call) it must then just echo the new timestamp. Now, in the event that the file is modified prior to this script being called(but after the session var being set), it detects the difference between the session var and the new modified time and the loop echo's that out no problem. The issue is that once this loop has started(even if run for 60seconds) if the time.txt file is modified during that time, it is not detecting it and i do not know why. The getTimestamp() function works correctly. Thanks in Advance for any help. Hope i was clear enough. If someone has an easier way of doing this(wait till a file's mod time changes and echo a notification) i am all ears Darren. session_start(); function getTimestamp() { $target = "time.txt"; return date("YmdGis", filemtime($target)); } for($i = 1; $i <= 10; $i++) { $modTimestamp = getTimestamp(); if ($modTimestamp > $_SESSION['timestamp']) { $_SESSION['timestamp'] = $modTimestamp; echo $modTimestamp; break; } sleep(1); }
  7. Thanks, will try that; there is currently nothing in the else block other than the print.
  8. Hi, I am having an irritating issue when trying to check if exists/create a directory. Here is the code i am using: $dirname = "HE"; if (!is_dir("{$dirname}")) { print("Error: The directory <b>({$dirname})</b> doesn't exist"); mkdir("{$dirname}", 0777); print( " The directory {$dirname} has been successfully created."); } else { print "Directory Already Exists"; //more stuff to go in here } If the directory doesn't exist, it runs through the motions and creates it perfectly. My problem comes if the directory does exist, the browser opens the index of that directory instead of staying on the .php page that is running this script so anything in the else part( or anything that comes after the if statement) doesn't run. Any ideas? Thanks in advance.
  9. Works 100%, Thanks a million Jeff. You have saved me from tearing any more hair out(Not to mention 20 lines of unnecessary code. Darren
  10. Thanks mate, That looks a whole simpler as well, will try it now. Much appreciated. Darren
  11. Hi all, I'm relatively new to php(5)/mysql(5.0) and am having a problem with archiving a record. Entering the information the first time goes without a hitch. However when i want to move the row to an archive table, the single quotes used for apostrophes like " darren's " are throwing off the string used to insert the row. Is there a way around this? I'm rather confused that it inserts the string from the html form without throwing errors(with all the apostrophe's) but when i want to move it again it gives me that error. Here is my rather naive and possibly laughable code. Any help will be greatly appreciated. // ***ARCHIVE MATCH REPORT**** if (isset($_REQUEST['deleteid'])){ $id = $_REQUEST['deleteid']; $str = "SELECT * FROM match_report WHERE match_id = '$id'"; $qry = mysql_query($str); $array = mysql_fetch_array($qry); $name = $array['team_name']; $opp = $array['opp_name']; $date = $array['match_date']; $ko = $array['match_ko']; $wufares =$array['match_wufa_res']; $oppres =$array['match_opp_res']; $report = $array['match_report']; $goalscorers = $array['match_goalscorers']; $injuries = $array['match_injuries']; $venue =$array['match_venue']; $formation =$array['match_formation']; $copystr = "INSERT INTO arch_match_report (team_name, opp_name, match_date, match_ko, match_venue, match_wufa_res, match_opp_res, match_report, match_goalscorers, match_injuries, match_formation) VALUES ('$team', '$opponent', '$date', '$time', '$venue', '$wufascore', '$oppscore', '$report', '$goalscorers', '$injuries', '$formation')"; mysql_query($copystr) or die(mysql_error()); $del = mysql_query("DELETE FROM match_report WHERE match_id = '$id'") or die(mysql_error()); } The error i get is this: 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 's (,)', 'Enter the injured player's names(If any), separated by comma's (,)', '3' at line 1 This is a result of the string variable $injuries which contains the apostrophe. The entry as stored in the injuries field is: Enter the injured player's names(If any), separated by comma's (,) As i have said.. inserting it the first time round was not a problem, only when i want to move it to another table do i get this problem. Thanks, Darren.
×
×
  • 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.