Jump to content

trq

Staff Alumni
  • Posts

    30,999
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by trq

  1. <?php $lines = file('name.txt'); foreach ($lines as $line) { $arr = explode(' ', $line); $ids = $arr[0]; $auth_keys = $arr[1]; echo "$ids = $auth_keys"; }
  2. <?php echo '<a href="">' . get('field-name') . '</a>'; ?>
  3. You only create $link if db_mysql doesn't already exist, if it does exist, $link doesn't actually exist outside of the db_mysql class. Your function also has a $config variable which doesn't exist.
  4. Sounds like you would be better of actually querying your database for 1 random record.
  5. This topic has been moved to Other Programming Languages. http://www.phpfreaks.com/forums/index.php?topic=322013.0
  6. mysql_fetch_array returns 1 record each time it is called until there are no records left. Instead of.... $mixed = mysql_fetch_array($result2); $advert = shuffle($mixed); You would need.... $mixed = array(); while ($row = mysql_fetch_array($result2); $mixed[] = $row; } $advert = shuffle($mixed);
  7. This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=321997.0
  8. This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=322001.0
  9. Sounds like you might not be very knowledgeable about php all round. Just point the search form at a script like..... <?php if (isset($_POST['search'])) { echo "You searched for " . htmlentities($_POST['search']); }
  10. This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=322008.0
  11. I haven't bothered looking through all that code but the idea is quite simple. Firstly, you need a form which will take a users long url, this part is simple. Once you have this long url, you need to store along side it in the database a unique random string, (again a simple task). From there all you need is to create a script which excepts the unique string through $_GET and looks that up in the database to find the actual long url. Something like.... <?php if (isset($_GET['key'])) { $key = mysql_real_escape_string($_GET['key']); $sql = "SELECT url FROM urls WHERE key = '$key' LIMIT 1"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { $row = mysql_fetch_assoc($result); header ("Location: {$row['url']}"); } else { echo "Sorry, that key does not match any url in our database"; } } } You then just create a simple mod_rewrite rule to rewrite the short url to a query string. RewriteEngine on RewriteRule ^([^/\.]+)/?$ /redirector.php?url=$1 [L] This would then allow users to type address such as http://short.com/he8dne to be redirected to whatever address is stored with the key of he8dne.
  12. This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=322006.0
  13. trq

    php header

    It doesn't sound like your code is well organized to me. WE would need to see your code to be able to help but basically, (and Ive said this before) it makes no sense to output data if your going to redirect anyway.
  14. This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=321957.0
  15. You use the header functions to set a Location header to do a redirect.
  16. trq

    NEWS ADD

    Are you missing some of this post? I don't understand the question / problem.
  17. If you are redirecting them to the success page there isn't much you can do. You could store a flag in the $_SESSION array but it seems like a bit of overkill to me.
  18. According to the HTTP specs, the Location header should be a complete uri, not just a file name or path to a file.
  19. trq

    php header

    It makes perfect sense. Always did. The difference is we do not redirect users to a login page if they are not logged in and are trying to access our index. This is what you seem to be doing. Google cannot index pages it can't access, eg, it cannot index our admin pages because it can't login. If you want your pages to be open to Google they need to be open to the public. Now, 1 more time. You cannot send data to the browser and then send headers.
×
×
  • 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.