Jump to content

PHP Monkeh

Members
  • Posts

    409
  • Joined

  • Last visited

    Never

Everything posted by PHP Monkeh

  1. Quite easily, change your foreach() line to this: foreach($Data as $key => $var) That will allow you to use $key.
  2. That's some pretty awful design, but the error probably lies in the ret11() function.
  3. Alright well you'll need to do a bit more work for the second option, but here's the rough outline: 1) Create a new 'flags' table with the fields: id, venueId, userId, reason I hope your venues table has an ID field as you'll need something to uniquely identify it. 2) Set up your page to allow visitors to flag up a venue and specify which reason 3) Do some checking once the user has submitted the flag: do a query on the venueId, and current user's ID, and make sure that there isn't a row in the 'flags' table containing both. If the check passes, then submit the flag to the table and you're done (this handles re-submissions from the same user for the same venue). 4) As for your CRON script, you'll probably need to use a JOIN if you want to do it pure MySQL (and I must admit I'm hopeless with JOINs). Or if you wanted to do it with some PHP: $query = "SELECT id, COUNT(*) FROM `flags` GROUP BY `id`"; Loop through that query, check whether COUNT(*) is greater than or equal to 5 and then perform another query to delete the row. Not going to write the code for you, but that should at least get you on the right track.
  4. Primary Key A primary key is an auto-incrementing number which is unique to each row of the database table. It allows you to uniquely identify each row, as other values may change. )";//do I need to remover the ; what is the purpose of that? just wondering because my book examples have them I didn't mean that line of code, I meant the entire variable. It's called $slq rather than $sql, and I wondered whether you changed the name of it so that it wasn't used. $result=mysql_query ($sql, $connection)//isn't this the $result variable? It is, but your if() statement is looking for $results.
  5. There are two routes you can go down, either adding another field to the table you current have, or creating a new table specifically for storing 'flags'. Considering you only want to know if there are 5 flags, and not extra info like date/time submission of flag, who flagged it up, their reason etc, I'd go with the extra field option. So: 1) Add another field to your current table called 'flags' 2) Set up your page so that the user can add 1 to this flag field, you might want to use sessions/cookies to prevent multiple submissions - though if you're afraid of abuse you may wish to go with the 2nd option I suggested above 3) Create a script (which the CRON will call) that does a query on all rows which have a 'flag' value of 5 or more, and delete them The second option will be a bit more complex, if the above isn't what you were looking for I can go in to more detail.
  6. I'm trying to figure out whether this is a joke or not. Anyway, you'll need to show us some actual code if you want us to help. There's no use mentioning that something is in an 'endless loop', when the code you've shown doesn't actually contain a loop. And please spell-check your posts before posting as they're hard to understand.
  7. Though you marked the topic as solved, you could always look at using sessions.
  8. Gotcha, look into multipart emails - there are quite a few tutorials from a google search for 'php multipart emails'
  9. Haven't tested or used, but found: http://www.getid3.org/
  10. If you want to see all your errors, remove your error supressions (@ symbol) from the beginning of function calls. I'll give you a hint though, there are quite a few. Just to point out the ones I spotted: <?php $sql="CREATE database hombudget"; $connection= @mysql_connect ("localhost","spike", "9sj7En4") or die (mysql_error()); $result=@mysqlquery ($sql, $connection) or die (mysql_error()); mysql_select_db("homebudget", $connection) $tbl= "CREATE TABLE 'estimate' ( Category varchar (10), Description varchar (30), Budget int )"; // You might want a primary key $slq = " DROP DATABASE IF EXIST 'homebudget' CREATE TABLE 'expenses' ( Category varchar (10), espenseData DATE, expenditure INT )"; // Did you leave this in intentionally? $result=mysql_query (4sql, $connection) // 4 rather than $ sign or die (mysql_error()); if ($results) { // Variable doesn't exist $msg = "</P>Database Homebudgethas been created </P>"; // Where's the beginning P tag? } ?> <HTML> <HEAD> <TITLE>Homebudget Database</TITLE> </HEAD> <BODY> <?php echo "$msg"; // No need for quotation marks here ?> </BODY> </HTML> Quite frankly without trying to sound rude, it's quite a mess in there.
  11. I don't know how to do it personally, but look in to PayPal's IPN (Instant Payment Notification).
  12. If you want to know whether the user can read HTML emails, the only way to do that is to ask them (it's common to ask whether the user wants HTML/Plain Text emails).
  13. Alright so you want to do it without MySQL, that's fair enough. So where do you want this data to be coming from that you're matching up? Text file? External web-page? Embedded in the code?
  14. Put it anywhere on the page which is handling the form submission, as it will show you what the $_POST array contains (and so you can see if 'submit' is in there).
  15. I take it the form which is submitting this data: a) is using the POST method and b) has a field named 'submit'
  16. It depends whether your form method is POST or GET: $email = $_POST['Email Address']; or $email = $_GET['Email Address'];
  17. Provide some code so we can try and understand what it is you're referring to.
  18. Have you just tried setting it to: '/whatever' ? That should (if you're allowed) access the 'whatever' directory from the filesystem root.
  19. Just replace: <?php echo '$third_total' ?> with <?php echo $third_total; ?> Though I don't really agree on what's being done on the first page (why wrap it in a function in the first place?) this should solve the error you're getting.
  20. Apart from encoding all your files, there's nothing stopping them. Though if a hacker managed to 'slip a file within the apache server' they will probably just be able to open up your file anyway. If someone managed to get access to your server, your database config details are the last thing you really need to worry about
  21. I'm struggling to understand your question as well. Do you want to keep the same structure but just change the sprite image? <style type="text/css"> #pagtop_info { background-image: url('result.png'); } </style> That would replace the image of #pagtop_info while keeping the other values in place. You would then need to give your new DIV an ID of 'pagtop_info'
  22. You could either re-size the image when they upload it, or if they aren't uploading but just including images you could easily restrict the size with plain HTML or CSS.
  23. $_POST['events'] is an array because you have multiple checkboxes. So you'll need to loop through each of the checkboxes when doing your insert: for($i=0; $i<count($_POST['events']); $i++) { mysql_query("INSERT INTO user (events) VALUES ('" . $_POST['events'][$i] . "')", $connection); }
  24. You coud do an not-so-elegant str_replace() on commas in $FreeSpace I guess - it would be better though if you did this when you were initialising the $FreeSpace variable. Or if it's being pulled from a database, removing the comma before inserting the value to the DB.
  25. I'm not great at maths but does this achieve what you want? $val = 309 / 397; echo number_format($val * 10, 2); Seems awfully simple so I'm not confident in my answer!
×
×
  • 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.