Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by HuggieBear

  1. My advice would be to seperate based on functionality. So have a user table that only stores user info, make sure it has and auto-incrementing ID field, you can use this as your primary key and use it to relate to other tables. Then have a messages_in table that contains only received messages, a message_out table that contains only sent messages, these tables can be linked via a column so that replies can be tied up with their original message. etc. etc. Regards Huggie
  2. Morning snakez. The first thing you MUST confirm is that your database has the correct results in it.  If you look at the tables in the database, are the links correct or are they all pointing to the first file? No point in checking the code on the page that pulls the info from the database if the database is incorrect (implying the code that inserts it is wrong). Regards Huggie
  3. It's a tricky one.  Unless you know what the AOL range of addresses is for their proxy servers, you could have problems. I think you're on the right lines though, maybe use a regular expression rather than substr().  Something like this: [code]if (preg_match('/^123\.456\.\d{1,3}\.\d{1,3}$/', $userdata['session_ip'])){   echo "IP Address OK"; } else {   echo "Your IP address is not in our acceptable range"; }[/code] What this does is check that the IP address is formed of the correct pattern.  In this case 123.456.nnn.nnn (where 'n' is any other number).  This assumes that AOL's IP address range for their proxies starts 123.456 So to evaluate the whole pattern for you (a bit on each line to make it easier to read)... [code]^        \\ Match start of line 123      \\ Match the first octet of IP address as 123 \.        \\ The backslash escapes the period as it has special meaning in a RegEx 456      \\ Match the second octet of the IP address as 456 \.        \\ Match the second escaped period \d{1,3}  \\ Match a minimum of one and a maximum of three digits \.        \\ Match the third escaped period \d{1,3}  \\ Match a minimum of one and a maximum of three digits $          \\ Match the end of line[/code] This may seem quite confusing, check out [url=http://www.php.net/manual/en/ref.pcre.php]RegEx's[/url] in the manual for further information. Regards Huggie
  4. Is it by any chance Hotmail that's moving it to the Junk folder? If it is, then the headers you use are more than likely affecting it.  Take the [b]to:[/b] field out of the additional headers if it's in there. If you look at [url=http://www.phpfreaks.com/forums/index.php/topic,107959.msg433816.html#msg433816]this post[/url], I provided some headers which Hotmail seems to like, maybe you could try them. Regards Huggie
  5. Markbett, I replied to your other post about this too, take a look back at that one as well. Regards Huggie
  6. I think the thing you're missing is that in the example, they're defining their entire array, you're not.  You're adding to yours on each iteration of your [color=green]while[/color] loop. So instead of [code=php:0]$guest_array = array(.....[/code] You need [code=php:0]$guest_array[$i] = array(.....[/code] As in my example above. If in each iteration of the loop you use the code you have, you're not adding to it, you're redefining it. I hope that helps. Huggie
  7. Markbett, I noticed that this post was linked to your last post "[url=http://www.phpfreaks.com/forums/index.php/topic,108250.0.html]Determine variable names for dynamic variables[/url]" I think that the code below is probably quite a good solution to what you're after.  Give it a whirl. [code]<?php // Get data from URL ... You could use $fields = $_GET (They do the same thing) foreach ($_GET as $key => $value){ $fields[$key] = $value; } // Import all of the array keys into the namespace extract($fields, EXTR_OVERWRITE); // Get the total number of guests $totalguests = count($fields)/2; // Populate array $i = 1; while ($i <= $totalguests){ $name = ${guestname.$i}; // Join the variable for name $email = ${guestemail.$i}; // Join the variable for email // The next line puts the values into a multi-dimensional array keyed on $i $guests[$i] = array('name' => $name , 'email' => $email); $i++; } // Output everything to show it's all worked ok. foreach ($guests as $key => $value){ echo "<b>Guest: $key<br>Name: {$guests[$key]['name']}<br> Email: {$guests[$key]['email']}<br><br></b>"; } ?>[/code] I liked the look of your post so I had a crack at it.  You can fit all your error checking in around it. Huggie
  8. It's so logical, I don't know why I didn't realise that in the first place. Thanks Wildteen. Huggie
  9. No, I think you're confusing session variables with cookies.  You don't need to use session_start() with cookies at all. Regards Huggie
  10. I want to put all of the parameters of URL into an array, no matter what they are called.  Is there a function for this? So if my GET url is index.php?firstname=richard&nickname=huggie I get an array created that would be equivalent to: [code=php:0]$url = array('firstname' => "richard", 'nickname' => "Huggie"); [/code] [size=8pt][color=red][b]Edit:[/b][/color][/size] Or even just the field names would be fine.  I'm currently investigating the HTTP extension Regards Huggie
  11. [quote] Thanks Huggie. I moved the quotes outside the second to the last bracket. [/quote] Sorry, was a long day yesterday :) and being up at 5am this morning didn't help either :( Can you post the whole of your code so we can check it? Huggie
  12. There's actually quite a bit wrong with this code, but don't worry, we can fix it :) I'll ask you a few questions, when you know the answers they'll help you to realise the mistakes. 1. If I go to login_form.php and my cookie is already set, what happens? 2. If I go to login_form.php with no cookie set, what parts of your code are going to run? As a side note, on login_success.php, you're setting the cookie and checking it on the same page.  That's not possible.  Until the page is reloaded (either refrshed, or revisited), the cookie won't be registered. Regards Huggie
  13. Yeah, that sounds good to me. [code] <?php if ($_COOKIE['authenticated'] != "y"){ header("Location: login.php"); } else { session_start(); } // Rest of code here ... ?>[/code] Regards Huggie
  14. You have to specify session_start() on every page.  Before any code is output to the browser. Regards Huggie
  15. OK, based on your column names, this is what you need: [code] if ($num_rows == 5) {   $result = mysql_query("UPDATE shoutbox SET message = '$message', time = now() WHERE artist_name = '$artist_name' AND time = (SELECT min(time) FROM shoutbox WHERE artist_name = '$artist_name')"); } else {   $result = mysql_query("INSERT INTO shoutbox (artist_name, name, message, time) VALUES ($artist_name, $name, $message, now())"); } [/code] Again, don't forget to change the variable names to those you're using. Huggie
  16. Is WAMP actually designed to be Internet facing, or was it initially just setup as something you could install to set yourself up a local environment.  I'd have thought with all the components, there's no reason why it shouldn't be, but just wondered. Regards Huggie
  17. Yes, you're missing code from the previous post, as I already mentioned.  I was still editing it.  Also, you've got WHERE TIME = ...  You don't have a time column. Copy the update statement from the previous post again and change the column names and variable names to your own. Huggie
  18. Sorry, I was still in the middle of updating the query in the previous post. Try again with the code that's there now.  Oh and don't forget to substitute the column names and variable names for those you're using Huggie
  19. Crzyman, There's no need to delete rows, just update old ones, as per my code Huggie
  20. Thanks redarrow, I've updated the code in the previous post now to reflect the correct WHERE clause on the UPDATE statement.  Before it was set to UPDATE WHERE min(id), so after the 5th post, you'll be overwritting the most recent post eact time.  Now it says WHERE min(date). Both the update and the insert statement make use of now(), allowing MySQL to do the date work for you. Huggie
  21. I'd say you were on the right track.  I'd have the following: [code] <?php mysql_connect("localhost","name","password"); mysql_select_db("news"); $artist_name = "Joe"; $result = mysql_query("SELECT count(*) FROM shoutbox WHERE artist_name='$artist_name'"); $num_rows = mysql_num_rows($result); if ($num_rows == 5) {   $sql = "UPDATE shoutbox SET message = '$message', date = now() WHERE artist_name = '$artist_name' AND date = (SELECT min(date) FROM shoutbox WHERE artist_name = '$artist_name')"; } else {   $sql = "INSERT INTO shoutbox (artist_name, name, message, date) VALUES ($artist_name, $name, $message, now())"; } [/code] This way you don't have to delete rows at all, [b]and[/b] you only update the info you have to, for instance, you don't need to update the artist_name each time as you know it's going to be the same. In addition to that, you're getting MySQL to deal with your date, you don't have to fiddle about with sorting it PHP side. Regards Huggie [size=8pt][color=red][b]EDIT:[/b][/color] I just noticed how you're inserting timestamps into MySQL... What type column is the date column, varchar()?  You're better off changing it to a datetime and using MySQL to log the time for you.[/size]
  22. OK, so that code wasn't hard at all... My bad. I was thinking of something completely different.  Multiple columns but still with results going vertically, like this: [code] |---|---| | 1 | 4 | |---|---| | 2 | 5 | |---|---| | 3 | 6 | |---|---| [/code] Over complicating things again :) Huggie
  23. It's possible, but not very easy. I think I have some code somewhere I picked up recently that does it. I'll look and post if I find it. Huggie
  24. Give it a dynamic name based on the row it's in... Are you able to post the code, and if you have a working example somewhere that would be excellent too. Regards Huggie
  • 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.