Jump to content

Anon-e-mouse

Members
  • Posts

    38
  • Joined

  • Last visited

    Never

Everything posted by Anon-e-mouse

  1. Evening, In simple, I have a script that loops through members when submitted and sends them a confirmation email for an event. However I don't want to send 200 emails one after the other because Google would get very upset. Thus! I attempted to use sleep() but that didn't function as I thought it would inside the loop. Causing the entire thing to wait for the amount of seconds times the result set. So. Whats would you suggest? Thanks.
  2. While you foreach through the values of the select menu itself you could add a third variable the function doesn't have to expect which is your "sticky variable"? So whenever you call it and you need to stick something to the menu you would simply put that field into the function. Something like: <?php function create_dropdown($array_name, $array_item, $sticky_item = null) { echo "<select name='$array_item'>\n"; echo "<option value='select'>Select…</option>\n"; foreach( $array_name as $v ) { if($v == $sticky_item){ echo "<option value='$v' selected>" . $v . "</option>\n"; } else { echo "<option value='$v'>" . $v . "</option>\n"; } } echo "</select>\n"; } See what I'm getting at?
  3. Hello, You could always start with checking to see whether they have included the "@" character in the post via.. <?php // If they dont have the "@" character.. if(!strstr($_POST['userEmail'], '@')){ // Do something. } ?>
  4. Next time wrap code in code tags, much easier to read. I was thinking more along the lines of the code you use to upload the file but ultimately save it in your table as that is the part thats missing. If you wanted to amend .pdf you could: <a href="<?php echo $rows['Question'].'.pdf'; ?>" target="_blank"> Should work. Although that then forces you to have each file a PDF.
  5. Do you have any code that you can post? It's a bit hard to help without seeing what you are actually doing at the moment..
  6. Hello, Are you uploading the file? If so, can you post how you are? Sounds like you are saving the filename but not the extension..
  7. Hiya, I think I'm reading it correctly but working our way out from the middle you have two array_diffs. Well the difference between the two arrays $a and $b are 0 and 10 being present in $b but not $a. Array_diff works by returning an array with the differing pieces from the two arrays you provide. The below is from php.net So in this case you are creating two new arrays that have both 0 and 10 as items within them which are then merged together and the items are counted. Which is why it returns 4.
  8. Well that is easily solved. If you had a page you could have an icon on each "comment" that would take you to an edit page and then do that for that specific comment, whilst at the bottom (as its usually done) you could have a form which allows you to then post a new comment regardless of whether they have one or not?
  9. Your button you use to submit the form is not contained within the <form></form> tags. Try placing it in and then submitting it.
  10. Or! Alternatively and what I think blacknight was getting as use backslashed to escape the speech marks when within speech marks. Otherwise you will generate that error. Below: <?php echo "</head><body onload=\"ajaxFunction()\";>"; ?> That said, whenever you use speech marks within an echo try and surround the entire thing in apostrophes ('), makes it a LOT easier.
  11. Going on what I've read if you were to store the users ID instead of their username as the session (not that you couldn't do both) you could then use that as your variable to differentiate when querying the tables. <?php $sql = "UPDATE `table1` SET `column1` = '".$toset."' WHERE `userID` = '".$_SESSION['userID']."'"; ?> So you then update the table with your information using the session you set when they first logged in, no reason to say you could assign the session to another variable as you have above and then use it in the query but thats just a quick example.. Hope it helps!
  12. Morning! The group by statement refers to a column, so surrounding it with apostrophes will make the column act as a value, if that makes sense. This should work: <?php $sql = "SELECT * FROM monsterpost GROUP BY mpmonth"; ?> Notice the group by clause is capitalized and the column name you are grouping is not surrounded by apostrophes. If you wanted you could surround it in backticks (`) but it isn't essential in this situation.
  13. Point. You have an extra comma after 'Uploadedfile' which should not be there.
  14. Morning (just), $run if you look is the query actually being executed instead of putting the query inside mysql_query() directly I built the syntax and then input it. So $run becomes the "query" in the sense that whenever you wanted to pull the results you would use that.
  15. Sure, <?php $sql = "SELECT * FROM ....."; $run = mysql_query($sql); while($get = mysql_fetch_object($run)){ if($wordyouarelookingat == $get->word){ function($wordyouarelooking at); } else { continue; } } ?> There you have a really basic example of what I was going on about. Simply you would query the table in order to get your list of words, run through the results and if the word you are searching for is the same as one in the table then you can pass it through the function otherwise it would skip that word and try the next..? Obviously I don't know how you will get the words to highlight in the first place but the above is just one way out of a possible trillion (most likely...) to attempt it. Hope it helps.
  16. Hardly, If you stuck the words you had in an array for example and foreach'ed through them, if a match was found then you could query a table for the definition and stick the replace script in there. In fact if you were to just query the table with your words and definitions in you would save doing the above as you could loop through the results and use the original query to power the string replace in the event of a match! That saves you.. for 1000+ definitions, a lot of copy and pasting.
  17. Explain clearly what you secondly want.. is it just to have the number of deliveries put before the "x" to make something like "2x"?
  18. Using the header function... <?php if($pull['date'] == $new_date){ header("Location: http://www.example.com"); } else { header("Location: http://www.example2.com"); } ?> Just make sure where you are redirecting to is valid of course and you should be ok.
  19. Well you've written the query for the table but you haven't actually executed it.. really the query will do nothing you want it to because you havent asked it to compare the date field with the date 'data' you have. Below! <?php $sql = "SELECT `date` FROM `availability` WHERE `date` = '".$date."'"; $get = mysql_query($sql); $pull = mysql_fetch_assoc($get); if($pull['date'] == $new_date){ echo 'Yes.'; } else { echo 'No.'; } ?> OR! <?php $sql = "SELECT `date` FROM `availability`"; $get = mysql_query($sql); $pull = mysql_fetch_assoc($get); while($pull = mysql_fetch_assoc($get)){ if($pull['date'] == $new_date){ echo 'Yes.'; } else { echo 'No.'; } } ?> The first will search for records that match the date and then go through the IF you wanted the second will run through ALL database records and then pair up the dates using the IF. Whenever you want to query a database you need to remember to actually execute it, its all well and good writing what you want to do (properly!) but if you don't then attempt to run the query it was a pointless effort: Write -> Execute (Or Error) -> Fetch results.
  20. Have a shared header file? So that whatever file you apply the header to will have that same CSS sheet? Thats how I would personally action that.
  21. Written in PHP you would need to refresh the page so the data is actually sent in the first place regardless however if you wanted to enter the information into the textbox and send it to the function without refreshing or doing anything to the page you could do it using AJAX. Thats another kettle of fish though.
  22. If you have a textbox within a form that "POST"s the data then simply need to put something like: <?php // Function... function writeName($var){ return $var; } // Grab it. $var = $_POST['textbox']; // Send it to the function. echo writeName($var); ?> Obviously changing the "textbox" with the actual name of the field.
  23. Morning, <?php ... $planet3 = "SELECT defender_planet FROM travel WHERE defender_planet = '" .($defender_planet')."'"; ... ?> An extra apostrophe in there which is why you are getting a fatal error. The query should be as follows.. <?php ... $planet3 = "SELECT defender_planet FROM travel WHERE defender_planet = '".$defender_planet."'"; ... ?> Hope it helps..
  24. Morning, You could always have two fields in a table whereby one dictates that an article is "published" and another "preview". So after they've written their piece and click on "preview" it would update to '1' or something the equivalent that says this article isn't actually published just in progress? And then update that to '0' and "published" to '1' when its confirmed as good to go? Seems the simplest way of doing something. Obviously you would then need to find some way of clearing out previewed articles that never went to print as it were unless you kept them for reference in the database which I can't imagine taking up a lot of room.. Hope it helps.
  25. Hello Debbie, Maybe I can help. You can look at formatting it the way you have with date() or you can use DateTime as below: <?php // Nice date.. $dt = new DateTime($dateyouareworkingwith); // Format! $dt->format("jS F Y") // Go. echo $dt; ?> For example using "jS F Y" as the format with the following timestamp: "2012-02-03 21:31:15" will format to "3rd February 2012". So with that all you need to put into DateTime is the timestamp you're working with and then format it in anyway you want without anything special. Equally with using date() you don't need to add blackslashes all over the place so.. <?php // Current datetime in Year-Month-Day Hour:Minutes:Second format.. echo date("Y-m-d H:i:s"); ?> That will echo out something like "2012-02-26 23:39:21" for me at the moment. The only reason the "-"'s are in there is to break up what would be just numbers and make it look semi-friendly. Hope it helps!
×
×
  • 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.