Jump to content

berridgeab

Members
  • Posts

    112
  • Joined

  • Last visited

Everything posted by berridgeab

  1. Are you talking about a user hitting the back button and resumbiting the POST information?
  2. Try below first and see if the data is actually there in the first place foreach ($data as $key => $value) { echo "key: " . $key . ': =' . $value . '<br />'; }
  3. $avq = "SELECT avatarcount FROM users ORDER BY score DESC LIMIT 0,10"; $avq = "SELECT id, name, score FROM users ORDER BY score DESC LIMIT 0,10";
  4. You should issue an exit() or die() after a header() because it is the browser that executes the redirect. PHP can continue parsing code after the redirect hence you should kill it, thats what I have read anyway.
  5. The session_start() will come before the redirect. Then once the session has started you check to see if the user has logged in after the session_start(). You can do this my doing an isset() on $_SESSION['uid']. If its set then send the header() and exit() to prevent further output.
  6. Nothing visibly wrong with the code whats the error?
  7. Have you dumped the contents of variable text in the anonymous function to make sure the data is there?
  8. You need something called AJAX, similar to what this other guy has just asked. http://forums.phpfre...e/#entry1383550 Plenty of stuff on google too. Below is a basic example of what you have to do with jQuery. $.post({ url: url, data: data, success: function(data, textStatus, jqXHR) { //Do something with PHP response here, assign it to DIVs in page, whatever }, dataType: 'html' });
  9. You need to send a response back to the javascript that could then be put into the page. I.e. You use PHP to respond back with a valid html string saying "Success" or "Error" and then take that response and put it into a div or something. I personally use a jquery plugin called taconite which lets me post a response back using xml to target the nesscary html tags. The xml syntax is really cool because it follows the jquery selector format. http://www.malsup.com/jquery/taconite/ It has examples and demos on that site how to use it. Also use Firefoxs FIrebug plugin to debug the responses sent by the GET/POST.
  10. 500 lines is nothing. You should think about grouping your different functions into related files (i.e. file for string related functions, etc) that would be a good start as it helps maintain your code. If functions are unique to the page / file using that particular function then you may as well keep it within the same file. Honestly though your overhead will be minimal at the moment if your just beginning.
  11. yes but i got rid of most of your original code you will have to put it back in
  12. Yeah most likely if the algorithim is just crunching numbers based on pixels and colors but it would probably be quite slow. Also PHPs floating point precision is not so good if that is a factor too. If your look at the PHP manual at the PHP image librarys that might be a good starting point. http://www.php.net/manual/en/refs.utilspec.image.php
  13. Yes but the way your updating is wrong. When it goes through the loop $id will get overwritten everytime. When you come to update it, it will only update the last id chucked out from the loop, not all the records. Also your connecting twice to the database, no need to do that your already connected. You have two options, move the update within the loop (but this will mean many update querys which can be slow if you have 200+ updates) or you could save all the ids into an array and update them in one database call (more efficient). Something like if($info = mysql_fetch_array( $data )) $id=$info['id']; $arrayIds[] = $info['id']; } $updateQuery = "UPDATE completed SET followupsent = NOW() WHERE id IN ("; foreach($arrayIds as $id) { $updateQuery .= "$id, "; } $updateQuery = rtrim($updateQuery, ", ") . ")"; $update = mysql_query($updateQuery) or die(mysql_error()); Basically use a PHP loop to build up the MySQL statement.
  14. Glad to here you have progressed If your worried about the initial database column being NULL then i suggest you add whats called a default value to the field in question. Basically when the record is created (inserted) if you don't assign a value to the field it will assign a pretermined value automatically i.e.'Uncomplete'. If you wish to simply update an existing record to 'incomplete' then simply issue this statement <?php $query = "UPDATE tableName SET field1 = '$value', field2 = '$value2', WHERE id = '$id'; ?>
  15. You solved it yourself, I just confirmed it Also something to bare in mind is that some $_SERVER variables are simply not available from the commandline, I forget which ones, but a print_r($_SERVER) will tell you.
  16. I would also remove your login details from your post this is a public forum.
  17. The problem is that you are trying to redirect to your next script using a header, this wont work for the cronjob, because its running from the commandline not a url. You need to combine the script into one script or include the second script with an include / require statement. I would really combine the two scripts I see no reason why they should be split into two.
  18. Yes the delete statement looks ok and should work. Though I don't know the nature of what your database / web app is used for or its table structure, but would it not be better just to have an extra field in the needs table called status, then just update the status to be 'Incomplete', rather than copying the entire row to another table? I only mention this because you say your new to this.
  19. Press "More Reply Options" by the "Post" button and you will see your post preview.
  20. In the SQL statement below there are two tables, tableA and tableB which I have aliased to A and B. tableB contains a reference to tableA stored in the tableAId field. This references the primary key of tableA which is called id. LEFT JOIN will attempt to join two tables together on them two fields. As long as a record exists with an Id of 1 in tableA, then that row will always be returned. If a row in tableB on field tableAId matches id, then that row from tableB will be returned and joined to the end of tableA. However if tableAId from tableB doesn't match id from tableA then all the fields from both tables are still returned, however all of tableA fields will be filled with data while all of tableB fields will be NULL. $query = "SELECT * FROM tableA as 'A' LEFT JOIN tableB AS 'B' ON B.tableAId = A.Id WHERE A.id = 1"; A JOIN works in a similar manner, however a record must exist in both tableA and tableB for a row to be returned. $query = "SELECT * FROM tableA as 'A' JOIN tableB AS 'B' ON B.tableAId = A.Id WHERE A.id = 1";
  21. Yes, Server A creates the file, Server B requests it and then writes it to its own location with whatever permissions you desire. I'm assuming both servers are running versions of PHP cabable of doing this.
  22. Your question isn't very clear. Where is the replacement name for the link coming from? The user, or is PHP mean't to generate it? If you already have the raw link from the user its just a case of echo "<a href = '$linkFromUser' target = '_blank'>My Link Title with no HTTP</a>";
  23. So the server is responding, however it is actually telling you that you have not submitted the data? Have you run a print_r() on the data that you build before actually sending it to check its being built correctly?
  24. Tbh it sounds like a problem with the configaration of your local mailserver. As I said its a pain to configure and get working properly locally. It should work live if you upload to your production server.
  25. Sure you can do a redirect by $ToEmail = 'postmaster@localhost'; $EmailSubject = 'Details'; $mailheader = "From: ".$_POST["email"]."\r\n"; $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $MESSAGE_BODY = "Name: ".$_POST["name"].""; $MESSAGE_BODY = "Address Line 1: ".$_POST["address1"].""; $MESSAGE_BODY = "Address Line 2: ".$_POST["address2"].""; $MESSAGE_BODY = "Town name: ".$_POST["town"].""; $MESSAGE_BODY = "County/state: ".$_POST["countystate"].""; $MESSAGE_BODY = "Postcode: ".$_POST["postcode"].""; $MESSAGE_BODY = "Message: ".$_POST["persmes"].""; $MESSAGE_BODY .= "Email: ".$_POST["email"].""; if(mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader)) { header("Location: replaceWithFilename.php"); } Alternatively you could just keep the success / fail msg in the same page. if(mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader)) { echo "Success"; } else { echo "Failure"; }
×
×
  • 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.