Jump to content

Ninjakreborn

Members
  • Posts

    3,922
  • Joined

  • Last visited

Everything posted by Ninjakreborn

  1. I tried it, but it gave me the exact same issue I had before with my original script with every login, it doubles hte results, but I redid my script and everything works perfect, just with a lot of db calls I might try to fix some of the db calls, and clean it up some, but everything functions perfectly.  I haven't tested it once it goes negative but I am about to. [code]<?php // start if($_SESSION['controller'] === true) { // updates paid time period $select = "SELECT * FROM userinfo WHERE id = '$_SESSION[id]';"; $query = mysql_query($select);// query for info $row = mysql_fetch_array($query); // fetch array if ($row['timeperiod'] != "none") { // check status of timeperiod $currentdate = "08/23/06";  //date("m/d/y");// get's todays date $paydate = $row['paydate']; // get's db pay date $currentdate = strtotime($currentdate); // test later with later date $paydate = strtotime($paydate); $datetoupdate = "08/23/06"; //date("m/d/y"); $number_days = floor(($currentdate - $paydate)/86400); // 86400 = seconds per day $updatedversion = $row['timeperiod'] - $number_days; // new time period $checkforupdate = "SELECT timeperiod FROM userinfo WHERE id = '$_SESSION[id]' AND timeperiod != '$updatedversion';"; $checkquery = mysql_query($checkforupdate); if ($checkrow = mysql_fetch_array($checkquery)) { $update = "UPDATE userinfo SET timeperiod = '$updatedversion', paydate = '$datetoupdate' WHERE username = '$_SESSION[username]';"; $query2 = mysql_query($update); } } // Closes check for timeperiod equaling none. $selectinfo = "SELECT * FROM userinfo WHERE id = '$_SESSION[id]' AND timeperiod <= '0';"; $query3 = mysql_query($selectinfo); if ($rowforupdate = mysql_fetch_array($query3)) { $paid = "no"; $paypalid = "not applicable"; $paydate = "not applicable"; $timeperiod = "none"; $updatepayinfo = "UPDATE userinfo SET paid = '$paid', paypalid = '$paypalid', paydate = '$paydate', timeperiod = '$timeperiod' WHERE id = '$_SESSION[id]';"; $query4 = mysql_query($updatepayinfo); }// closes row to update payement information when number is 0 or below }// closes test to update paid ?>[/code] if you can help me fix some of those db calls now without breaking the functionality of the script it would help a lot.
  2. check the bugs as well, there are a few bugs with windows, related to exec, make sure it's not that, I wish I could help but this is getting too deep, I have never used exec, or system, maybe system has some functionality you can use.  fopen opens files, but I don't know about applications.
  3. [code]$newfile = "uploads/".basename($_FILES['file']['username']);[/code] I think this was what it was, I am still a little confused on file handling. You just put the name of the variable at $_FILES['file']['$variable'] I THINK. that is not 100% sure.
  4. I don't think there is a way to do this, you could save the temp address, when it's uploaded and try to echo it back on itself if it's on the same page if it's different pages however there is one thing.  Register sessions on each and every variable, then put the sessions back into the form on the other page, in the php ini put like 1 hour, it'll make sure the variables stay in place for that person
  5. http://drupal.org/node/14002 http://us3.php.net/manual/en/ref.exec.php read the user comments there, it has some stuff about windows. http://bugs.php.net/search.php?cmd=display&search_for=exec%28%29 this will definitely probably help some go over those too and see if you find anything.
  6. exec should be running it, just make sure it's not user based.  I don't understand why it's not, is the script with exec on the exact same directory as the program.  If not you have to tell it where to find it at.
  7. [code]<?php $dbh=mysql_connect ("localhost", "spyderw_Ashton", "ashton2004596") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("spyderw_dk"); $select = mysql_query("SELECT author,newpostdate,title, FROM spyderw_forum ORDER BY `newpostdate` DESC LIMIT 3"); $total=1; while($row = mysql_fetch_array($select)) { } if (isset($get['display'])) { echo $recentforum; // even here I like echo "{$recentforum}"; } ?>[/code] The code here doens't make sense to me though, your while statement is doing absolutely nothing.
  8. [code]<?php $dbh=mysql_connect ("localhost", "spyderw_Ashton", "ashton2004596") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("spyderw_dk"); $select = mysql_query("SELECT author,newpostdate,title, FROM spyderw_forum ORDER BY `newpostdate` DESC LIMIT 3"); $total=1; while($row = mysql_fetch_array($select)) { } if (isset($get['display'])) { echo $recentforum; // even here I like echo "{$recentforum}"; } ?>[/code]
  9. [code]if(isset($_GET['display'])) echo $recentforum;[/code] That is not good practice, I was shown this before, someone corrected if not I would have made a grave mistake it's always [code]<?php if (isset($get['display'])) { echo $recentforum; // even here I like echo "{$recentforum}";  just depends on preference } // or if (isset($get['display'])) { echo $recentforum; } // I prefer the top ?>[/code]
  10. [code] <?php $dbh=mysql_connect ("localhost", "spxxxrw_Axxxxn", "asxxxxxxx96") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("spyderw_dk"); $select = mysql_query("SELECT author,newpostdate,title, FROM spxxxxxw_forum ORDER BY `newpostdate` DESC LIMIT 3"); $total=1; while($row = mysql_fetch_array($select)) { } if(isset($_GET['display'])) echo $recentforum; ?> [/code]
  11. simple to capture current timestamp $variable = time(); to capture the current date or date from a time stape $variable = date("formathere"); check php.net for formats if you want to change a time stamp into date format $variable = date("formathere", $variable); // the variable would contain the time stamp.
  12. mark is right having them set to get is the stupidest thing you could do. Always use post on those kinds of things Also if you just use mysql_real_escape_string(); and whatever else maybe some extra safety, to make sure things don't go haywire, believe me strtolower() will stop all the upercase letters you can do trim(" variable ") which will prevent whitespaces also validate the material make sure it's not blank, ex cetera I know most people won't agree, but I feel having  1 login box, not really makes things secure, but it makes it easier to run scripts on login.  I always end up having a lot of scripts, where I have to check for various things for the user and update if necessary, if there is only 1 login area, then you can do that easier, than having it go to a login.php redirrect page every time.
  13. [code]It depends on how you wanted to display it, with tables it would be like <?php echo "<table>"; while ($row = mysql_fetch_array) { echo "<tr><td>$variable</td></tr>"; $controller = true; // or whatever variable } echo "</table>";// tables outside of while, or it redoes table every circle through ?>[/code] Just put the data in a formatted table, I can't do it for you, ebcause I don't have time and because I don't know how many fields you have, or you can use lists [code]<?php echo "<ul>" or echo "<ol>" // more of ul while ($row = mysql_fetch_array) { echo "<li>{variablename}</li>"; echo "<li>{varieblename2}</li>"; $controller = true; // or whatever variable } echo "<ul" or echo "<ol>" // more of ul[/code] of course each call you make to the db variable you have to use the variable you used to access it, in this case it would be $row['variablename'] or $row['variablenamer'] when extrapolating they teach you to leave off the ' ' like $row[variablename] $row[variablename2]
  14. table field name could be timeentry $variable = time(); to display it it's the same thing $select = "SELECT * FROM tablename SORT BY postdate, timeentry LIMIT 4;"; I don't remember what goes in between those and I don't have time to check it's either postdate AND timeentry postdate OR time entry postdate, time entry it's one of the three.
  15. well for most recent, you would probably want to have the date logged when they post, sort  by date, like have a field called postdate have it put a time stamp there whenever they post then on the homepage have $select = "SELECT * FROM tablename SORT BY postdate LIMIT 4;"; $query = mysql_query($select); while ($row = mysql_fetch_array) { // whatever to display $controller = true; // or whatever variable } if ($controller != true) { echo "There are no recent entries"; } you probably wouldn't need the message if it's a forum though because there will always be recent entries, just the last 3 posted entries.
  16. easy, do a select statement, have something in the database to differentiate, and do some calls to the db, just limit them so they don't overwhelm the visitor, like 20-30 per page.
  17. I also added in some functionality, I started updating the paydate, to the current date, and left a note for the user's that this is showing when the timeperiod was last updates, then it started doing those errors when I started commenting out the current date, and adding a date that was a few days in advance??
  18. I guess now I actually do need help, I worked on the script some more, I supposedly had it set up right, most of the functionality is there, but there are some quirks, I play around with one of the dates, to see what will happen when it updates tomorrow or the next day and it's acting up a little, it'll either throw the time period somewhere up in the thousands, or it will start increasing it by just a few.  Can someone help me understand what is causing this. [code] <?php if($_SESSION['controller'] === true) { // updates paid time period $select = "SELECT * FROM userinfo WHERE id = '$_SESSION[id]';"; $query = mysql_query($select);// query for info $row = mysql_fetch_array($query); // fetch array if ($row['timeperiod'] != "none") { // check status of timeperiod $currentdate = date("m/d/y");// get's todays date $paydate = $row['paydate']; // get's db pay date $currentdate = "07/29/06"; //strtotime($currentdate); // changes to time stamp $paydate = strtotime($paydate); $datetoupdate = date("m/d/y"); $number_days = floor(($currentdate - $paydate)/86400); // 86400 = seconds per day $updatedversion = $row['timeperiod'] - $number_days; // new time period $checkforupdate = "SELECT timeperiod FROM userinfo WHERE id = '$_SESSION[id]' AND timeperiod != '$updatedversion';"; $checkquery = mysql_query($checkforupdate); if ($checkrow = mysql_fetch_array($checkquery)) { $update = "UPDATE userinfo SET timeperiod = '$updatedversion', paydate = '$datetoupdate' WHERE username = '$_SESSION[username]';"; $query2 = mysql_query($update); } } // Closes check for timeperiod equaling none. $selectinfo = "SELECT * FROM userinfo WHERE id = '$_SESSION[id]' AND timeperiod <= '0';"; $query3 = mysql_query($selectinfo); if ($rowforupdate = mysql_fetch_array($query3)) { $paid = "no"; $paypalid = "not applicable"; $paydate = "not applicable"; $timeperiod = "none"; $updatepayinfo = "UPDATE userinfo SET paid = '$paid', paypalid = '$paypalid', paydate = '$paydate', timeperiod = '$timeperiod' WHERE id = '$_SESSION[id]';"; $query4 = mysql_query($updatepayinfo); }// closes row to update payement information when number is 0 or below }// closes test to update paid ?> [/code]
  19. I think I uncovered another issue. How am I going to check for it each day, because again, if today it checks, then checks again today, it won't update. But if tomorrow for instance, it will check again, and update more than necessary. I may have to factor in another date, that shows last time updated, or something?  hmm, I could update the current date, hmm any advice???
  20. [code] <?php if($_SESSION['controller'] === true) { // updates paid time period $select = "SELECT * FROM userinfo WHERE id = '$_SESSION[id]';"; $query = mysql_query($select);// query for info $row = mysql_fetch_array($query); // fetch array if ($row['timeperiod'] != "none") { // check status of timeperiod $currentdate = date("m/d/y");// get's todays date $paydate = $row['paydate']; // get's db pay date $currentdate = strtotime($currentdate); // changes to time stamp $paydate = strtotime($paydate); $number_days = floor(($currentdate - $paydate)/86400); // 86400 = seconds per day $updatedversion = $row['timeperiod'] - $number_days; // new time period $checkforupdate = "SELECT timeperiod FROM userinfo WHERE id = '$SESSION[id]' AND timeperiod != '$updatedversion';"; $checkquery = mysql_query($checkforupdate); if ($checkrow = mysql_fetch_array($checkquery)) { $update = "UPDATE userinfo SET timeperiod = '$updatedversion' WHERE username = '$_SESSION[username]';"; $query2 = mysql_query($update); } } // Closes check for timeperiod equaling none. $selectinfo = "SELECT * FROM userinfo WHERE id = '$_SESSION[id]' AND timeperiod <= 0;"; $query3 = mysql_query($selectinfo); if ($rowforupdate = mysql_fetch_array($query3)) { $paid = "no"; $paypalid = "not applicable"; $paydate = "not applicable"; $timeperiod = "none"; $updatepayinfo = "UPDATE userinfo SET paid = '$paid', paypalid = '$paypalid', paydate = '$paydate', timeperiod = '$timeperiod' WHERE id = '$_SESSION[id]';"; $query4 = mysql_query($updatepayinfo); }// closes row to update payement information when number is 0 or below }// closes test to update paid ?> [/code] I may not be a grand master yet, but I am getting a hell of a lot better, I figured it out, but thanks for hte help, I ran a check before updating to see if the current update had already been made, i have to think for a minute to figure out if checking another day is going to mess it up
  21. well actually it is functioning exactly like I told it, but it's not what I wanted.  Ok I did paypay integration,there is a time period on the database that is set to the number of days they paid for 30 or 365 which is 5.99 or 19.99. everything works on the site now, I test everything as I do it, I was trying to get this to work, and it looked perfect, but when I retested it, I found out it's not functioning like I envisioned. [code] <?php if($_SESSION['controller'] === true) { // updates paid time period $select = "SELECT * FROM userinfo WHERE id = '$_SESSION[id]';"; $query = mysql_query($select); $row = mysql_fetch_array($query); if ($row['timeperiod'] != "none") { $currentdate = date("m/d/y"); $paydate = $row['paydate']; $currentdate = strtotime($currentdate); $paydate = strtotime($paydate); $number_days = floor(($currentdate - $paydate)/86400); // 86400 = seconds per day $updatedversion = $row['timeperiod'] - $number_days; $update = "UPDATE userinfo SET timeperiod = '$updatedversion' WHERE username = '$_SESSION[username]';"; $query2 = mysql_query($update); } // Closes check for timeperiod equaling none. $selectinfo = "SELECT * FROM userinfo WHERE id = '$_SESSION[id]' AND timeperiod <= 0;"; $query3 = mysql_query($selectinfo); if ($rowforupdate = mysql_fetch_array($query3)) { $paid = "no"; $paypalid = "not applicable"; $paydate = "not applicable"; $timeperiod = "none"; $updatepayinfo = "UPDATE userinfo SET paid = '$paid', paypalid = '$paypalid', paydate = '$paydate', timeperiod = '$timeperiod' WHERE id = '$_SESSION[id]';"; $query4 = mysql_query($updatepayinfo); }// closes row to update payement information when number is 0 or below }// closes test to update paid }// close isset ?>[/code] 1. I test to see if my session is active, this is hte basis for all of this script to run. 2. It queries the database for information so I can use it in my script.  It calls the information using the user id number so there is no chance of error, I don't allow the same username in the database, but it's a safety precaution. 3. I check to see if timeperiod in the database is not set to none, if it's not then I run through an update script. 4. I pull all the date information together, and calculate it.( the intention is, I pull the date from the database, which is the date they paid, then I pull the current date, which is whatever today is, I then calculate the amount of days that passed in those time period, the timeperiod in the database is the days left on the active paid account.  After I calculate it, I subtract the new update, to the timeperiod, giving me the new appropriate sum.  and I look to see what itme period has, if it is less than or equal to 0 then I know the paid account is invalid, and do the proper actions to be able to change all teh information on the account to show there payment has been finished.  This also opens up the option for them to buy again on another page. This is what I want to happen, but I didn't take this into account until it was too late, when someone log's in, it runs this script, if they log in again it runs it again, what can I do "if anything" to modify this script to update it properly, but not reupdate it every time they login, this doubles it.  If it has been 3 days, The only thing that crossed my mind, I am going to try now, but I still wanted advice in case it doesn't work, the last idea I had was do a quick test in the middle of the script, to see if the updated number is already finished, but I won't know how to integrate that in there anyway.  Any advice?? 5. I do the database update to update the time period. 6. then I query the db again to make sure I have all updated information from my query,
  22. quick question about dates calculation, I have it setup where when someone I have paypal integration complete it records the date of the transaction depending on how much they paid it records either 30 or 365 days just as a number 30 or 365 I need to take the date, I have the date organized where it records m/d/y or mm/dd/yyyy actually and the timeperiod set to whichever is necessary I am pulling all this from the database for every login and trying to check the date, I ahve recorded, and the current date, and see how many days has passed and update accordingly but if all the days has passed them I am going to remove some fields, and reset that back to paid = no I don't want to know how to do anything I just wnated to know what is a good basis to start, being able to take 1 date and take another date and check to see how many days between those dates have passwed passed
  23. 1, doesn't really matter I suppose it might help some. 2. Lower most basic ones to varchar (80) instead, if it's something that won't require 80 characters limit it even more, whatever it's set to, it makes enough room in memory for that, you don't need it adding the extra memory use datatypes very wisely when building the database. 3. Click on 1 field and click index, don't index more than 2 fields, or it does worst than good.  1-2 htat you call frmo a lot will make it faster. 4. show your script.
  24. thanks for noticing, just change that part of the script to a capitol S
×
×
  • 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.