Jump to content

snowman15

Members
  • Posts

    79
  • Joined

  • Last visited

    Never

Everything posted by snowman15

  1. The process would look something like this in chronological order: go to upload site upload file store id,filename,expiredate in database spit back download page with ?id=# from the file just uploaded go to download.php?id=# page performs check for expiration, deletes if necessary, or spits out the file optional: delete database record AND file on expiration optional: check/delete all files regardless of incoming ID every page load, slower, but files stay more up to date ^^this is a more simple option And like matthew said, you could use something like 'cron' to automatically do it reguardless of people visiting your page. But thats up to you.
  2. If I were you, I would create a database with an id,filename,endtime From there you could have a page that takes in a get variable such as mysite.com/getfile.php?id=4 This page would then check the database endtime for that id against the current date, delete the file if necessary and spit back an error, or show the file because it is still in the timeframe. Basically nothing would be done automatically, but everytime someone tries to access the page, it does the check so it appears as though it was deleted at its expiration time. another option would be to check every single file/delete them in the entire database per every page request, so it would most likely be a little more up to date. Hope this plants an idea, let me know what you think.
  3. ^^ he is right I didn't see that. Enjoy!
  4. theoretically if you keep reallocating space, it should be fine! Enjoy!
  5. PHP will automatically clear up any resources when the script ends anyway. So technically imagedestroy should not be needed. However, If you are running a script that processes multiple images at once and takes a decent chunk of time, you might want to use it during the script to free up memory during your script, and possibly freeing up some server memory.
  6. you should repost the most current code
  7. The only problem with the above code is that it does not account for mail failure. Either one will work though. I would try to start your better php habits now though.
  8. Yes, you can use an if statement with the mail function, to forward users to a thank you page upon mail success. (Mail function returning true: ) if ( mail($recipient, $subject, $formcontent, $mailheader) ){ header('Location: http://www.mysite.com/thankyou.php'); } else { die ("error"); }
  9. zero is not a number per say, it's a concept
  10. You could loop through all your input fields, checking for input, then if input fields !empty(), you could set $array[field] = value. then when your building your query, you can foreach ($array as $key =>$value){ sql .= $key .' = '. $value; } I didn't take a ton of time to read and think about what you were saying, but im pretty sure a simple array and foreach loop could take care of your problem, cheers
  11. Hey there, Ok so I wrote a script to conceptually display how to parse through a curl return. You can mess with it yourself and put the two $url variables above and below each other to see how I handle it. This is the concept but I'm leaving it up to you to figure out how to search through and find what data you want. One pointer I'll give you is to echo the full $page variable, look at the source, and see exactly what tags you need to find to parse your data. With a little bit of studying, you'll be able to pull out whatever data you want. Here is my code that you can mess around with: <?php $url = 'http://www.keywordspy.com/research/search.aspx?tab=domain-organic&market=uk&q=abc.co.uk'; $url = 'http://www.keywordspy.com/research/search.aspx?tab=domain-organic&market=uk&q=notfoundforme.co.uk'; $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //make sure you put a popular web browser here (signature for your web browser can be retrieved with 'echo $_SERVER['HTTP_USER_AGENT'];' curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.12) Gecko/2009070611 Firefox/3.0.12"); curl_setopt($ch, CURLOPT_URL, $url ); $page= curl_exec($ch); //echo $page; if (strpos($page, '0 - 0')){ echo 'No Results'; } else { $startpos = strpos($page,'<div id="OrgKeywords">'); $endpos = strpos($page,'<table id="ctl00_contentHolder_ctl00_GuestFooter_FreeUsersFooter"',$startpos); $table = substr($page,$startpos,($endpos-$startpos)); echo $table; } ?>
  12. in amend.php and delete.php you would probably want some database code. You need to be more specific to receive some help.
  13. I'm pretty sure if you put that function in a class and then made it a private function to that class, it might not give you that error. Please expand on what your trying to do. Something tells me you shouldn't be structuring it like this anyway.
  14. can you explain a little more in depth what your actually trying to pull with what input data? Thanks!
  15. that would suggest that your query isn't working for some reason. try to echo the mysql_connect and the mysql_select_db lines to see if they come back as true or false. if you echo everything, you can tell that the first thing that comes back false is probably the weak link in the chain.
  16. I would gather all the ID's your looking for in an array, then use a loop to build an sql statement with lots of 'id=id1 OR' (then repeat) and do one single query.
  17. I would use a $_GET variable that carries a variable for the different layouts. ex: index.php?layout=1 You can now use $_GET['layout'] to decide where you want to go from there. this is also a link friendly version of moving variables around because you can code your links like: <a href="mypage.php?layout=3" /> happy coding
  18. I'm pretty sure that error would be thrown if your result doesn't match anything. I suggest var_dump($result); to see if it is actually returning anything, then you'll know for sure.
  19. I believe preg_match() is the alternative but someone can correct me if i'm wrong. http://www.php.net/manual/en/function.preg-match.php
  20. your missing a quotation mark on this line: $db_name="****3***36_mail; // Database name cheers!
  21. I would google " Mysql delete duplicate records " or whatever database you are using.
  22. I'm not really sure what your trying to accomplish here (probably because this is a dumbed down version of your code), but when you declare 'mailform.php' as your action to your email form, it is going to pass the $_request variables to 'mailform.php'. Your code is trying to pull the form variables from the page the form is actually on. This would only work if you declared your action='test_product_list.php'. So you have two options the way I see it, 1. you create mailform.php and make sure its in the same directory on your server as test_product_list.php. You will then be able to write php code in mailform.php to use the $_REQUEST variables. again this is because you defined your form action as mailform.php. Another suggestion is to use the $_POST variables for your forms. Read up on them here: http://www.w3schools.com/php/php_post.asp 2. your second option is to set the action to the same page as your form (more advanced version). This would require you to set your form action as the same page (test_product_list.php). This allow you to check if the $_REQUEST variables are set and run your email code. Without either of these options, your $_REQUEST variables are NOT EVER entering the email script because the email script is not on the page that your form ACTION= is set. These variables also disappear after they've reached your ACTION= page. Hope this helps!
  23. Have you found out how to? I am also looking for how this would be done.
  24. Ok i changed it and I get this error: Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/11/6328911/html/test/classes/database.class.php on line 21 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/content/11/6328911/html/test/classes/database.class.php on line 21 Here is my new code: <?php class database{ function connect(){ $hostname='hookahreview.db.6328911.hostedresource.com'; $username='hookahreview'; $password='Hellodolly123'; $dbname='hookahreview'; $connection=mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.'); mysql_select_db($dbname,connection); if ($connection){ return 1;}else {return 0;} } function query($query){ $sql = "".$query.";"; $result = mysql_query($sql); return $result; } } ?> <?php include "database.class.php"; class membership{ private $db; function __construct(){ $this->db= new database(); } function createNewMember($username,$password,$password2,$email,$month,$day,$year,$location,$setup){ //BAD DATA CHECKS if ($password != $password2){return "The passwords do not match!";} if (!$this->check_email_address($email)){ return "The email address given is invalid!";} //END BAD DATA CHECKS $emailcode=123; $result = $this->db->query('INSERT INTO `hookahreview`.`users` (`id`, `username`, `password`, `email`, `location`, `birthday`, `num_reviews`, `setup`, `date_added`, `email_code`, `active`) VALUES (NULL, \''.$username.'\', \''.md5($password).'\', \''.$email.'\', \''.$location .'\', \''.$year.'-'.$month.'-'.$day.'\', \'0\', \''.$setup.'\', CURDATE() ,\''.$emailcode.'\', \'0\');'); } } ?>
  25. Hello. The problem I am having is using my custom database class in my membership class which creates memberships with a mysql query. There must be something wrong with the scope or something because whenever i create the new database object with $this->, mysql denies my connection and says I'm not using a password? And sometimes it tells me that my $db->query() is calling a member function on a non-object. I can't figure out how to use my database object to run the createNewMember function and query() the mysql query. I am PRETTY sure my database class works when it is just being called from test.php by itself, not 100%. membership.class.php: <?php include "database.class.php"; class membership{ function __construct(){ $db= new database(); //OBJECT SCOPE NOT BEING FOUND } function createNewMember($username,$password,$password2,$email,$month,$day,$year,$location,$setup){ //BAD DATA CHECKS if ($password != $password2){return "The passwords do not match!";} if (!$this->check_email_address($email)){ return "The email address given is invalid!";} //END BAD DATA CHECKS $emailcode=123; $db->query('INSERT INTO `hookahreview`.`users` (`id`, `username`, `password`, `email`, `location`, `birthday`, `num_reviews`, `setup`, `date_added`, `email_code`, `active`) VALUES (NULL, \''.$username.'\', \''.md5($password).'\', \''.$email.'\', \''.$location .'\', \''.$year.'-'.$month.'-'.$day.'\', \'0\', \''.$setup.'\', CURDATE() ,\''.$emailcode.'\', \'0\');'); // THIS QUERY SAYS IT BEING CALLED ON NON-OBJECT } } ?> database.class.php <?php class database{ function connect(){ $hostname='localhost'; $username='root'; $password='######'; $dbname='hookahreview'; connection=mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.'); mysql_select_db($dbname,connection); if ($connection){ return 1;}else {return 0;} } function query($query){ $sql = "".$query.";"; $result = mysql_query($sql); return $result; } } ?> My test.php !! <?php include "classes/membership.class.php"; $membership= new membership(); $membership->createNewMember($username,$password,$password2,$email,$month,$day,$year,$location,$setup) ?> [attachment deleted by admin]
×
×
  • 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.