Jump to content

joel24

Members
  • Posts

    760
  • Joined

  • Last visited

Everything posted by joel24

  1. i'd definitely look into using a mysql database for this site hey, your codes just going to get harder if your pulling/deleting/updating records from .txt files and searching records etc etc. do you mean the form posts to different pages depending on the option selected... or the form always posts to processor.php which redirects the user to a page depending on options selected? if so what options?? you'd have to have a thing like switch ($_POST['pageOption']) { case 'Big Snake': header('location: bigsnake.html'); exit(); case 'Small Snake': header('location: smallsnake.html'); exit(); default: header('location: error.html'); exit(); } or you could do the same with if statements, but switch is better for this situation... http://php.net/manual/en/control-structures.switch.php
  2. could you post the contents of "processor.php"?
  3. https://www.google.com/adsense/ i'm sure it will explain it all there.
  4. thats because when you save it you're using serialize() and the array is retaining its structure, then later on you pull that from the DB and unserialize() and then try to echo it when you can't echo an array. for your submit you may want to have a for loop and store only values, not an array. then you won't need to use serialize(); is it the entire form that is replicated? or just individual elements... i.e. would the occurrences of element1 be the same as the count of element 2? if the entire form is replicated, you could do something like if (isset($_POST['submit'])) { $org = $_POST['curEmpName']; $des = $_POST['curEmpDesignation']; $start_month = $_POST['curEmpStartMonth']; $start_year = $_POST['curEmpStartYear']; $end_month = $_POST['curEmpEndMonth']; $end_year = $_POST['curEmpEndYear']; for ($i = 0; $i < count($org); $i++) { $query="Insert into artus_test values('','{$org[$i]}','{$des[$i]}','{$start_month[$i]}','{$start_year[$i]}','{$end_month[$i]}','{$end_year[$i]}')"; $result=mysql_query($query); if ($result) { echo 'success'; } else { echo 'something failed...';} $i++; } } then get rid of the "unserialize" when you pull the data from the DB.
  5. why would you want to store the password in the session? you'd just verify it to start the session... if ( $_POST ['Submit']) { $user = ($_POST ['usernm']); $username = strtolower($user); $userpassword = ($_POST ['userpw']); session_start(); $_SESSION['username'] = $user; } and then you'd use session_destroy(); in the logout script to end the session. http://www.php.net/manual/en/book.session.php
  6. do you get an error? or just nothing happens. try error_reporting(E_ALL); if its not on already.
  7. http://php.net/manual/en/function.popen.php linux machine php ini set to safe mode??!
  8. the error is in your HTML. you have [] in the name attribute of your form elements.. that tells the PHP that the form element values being passed is an array.. i.e. <select name="curEmpEndMonth[]" > ... unless you have multiple elements with the same name and hence you need to pass an array of values, change it to <select name="curEmpEndMonth" >
  9. the atitles from the first loop are remaining the second loop. you need to unset the $atitles array i.e. <?php foreach ($_POST['questions'] as $q) { if (trim($q) != '') { $qtitles[] = $q; } } foreach ($qtitles as $qtitle) { $query = "INSERT INTO questions (qtitle) VALUES ('$qtitle')"; $result = mysql_query($query) or die("ERROR: $query. ".mysql_error()); $qid = mysql_insert_id(); unset($query); unset ($result); unset($atitles); foreach ($_POST['options'] as $o) { if (trim($o) != '') { $atitles[] = $o; } } foreach ($atitles as $atitle) { $query = "INSERT INTO answers (qid, atitle, acount) VALUES ('$qid', '$atitle', '0')"; $result = mysql_query($query) or die("ERROR: $query. ".mysql_error()); } } ?>
  10. $query = mysql_query("SELECT id, reg_id FROM `bidding_details` where bid_id='$bid_id' and sortbid = '1' and username='$username' ORDER BY bid_price DESC") or die(mysql_error()); $last = ''; $count = 0; while($line = mysql_fetch_assoc($query)) { if($last == $line['reg_id']) $count++; else { $last = $line['reg_id']; $count = 1; } if($count > 9) { $id = $line['id']; $sql_delete="update bidding_details set sortbid = '0', rank = '0' where id = '$id'"; mysql_query($sql_delete)or die(mysql_error()); } } there would be much cleaner ways to do it, but that should work? you might be better off just deleting that row? rather than making it "false".. i.e. $sql_delete="DELETE FROM bidding_details WHERE id = '$id'"; EDIT: i didn't put in a limit 50 on the select because this script will only delete rows if a user has more than 9 entries in that auction, and they should be deleted regardless of if they're in the top 50 or top 200....
  11. what is the foreign key for the items..? i.e. does reg_id associate the bid with an item.. or bid_id?? or something else also what are reg_id and bid_id?
  12. what exactly do you want this part of the script to do? get the first 50 rows... then you should order them by price "ORDER BY bid_price DESC" ?? then you want to check if a user has more than 9 bids in those 50? and if so make the smallest bids false..? whats your primary key for the bids??
  13. @Mchl... but if the while loop only gets to the first execution and then hangs that won't have any effect... @agravayne...have you've looked at set_time_limit()? http://php.net/manual/en/function.set-time-limit.php in saying that, it wouldn't end the script gracefully...
  14. and why do you have an "order by" clause in the update query?? and shouldnt " if($count > 9) { " be " if($count < 9) {" ... if you only want the first 9?? i'm totally lost as to what you're trying to achieve
  15. i don't entirely understand what you want... but you should order the select ... do you have a bid date field? i.e. add "ORDER BY DATE(bid_date) ASC" before "limit 50"
  16. sorry i was using 2 different variables for the timestamp ($expired and $timestamp) try this n see if it works. also, copy and paste what it prints in here, so I can see if the dates are going in correctly from the DB. <?php include('config.php'); $sql_rdate="SELECT * FROM table WHERE status='1' "; $rs_dt=mysql_query($sql_rdate) or die (mysql_error()); while($row= mysql_fetch_assoc($rs_dt)){ $date = $row['rDate']; $date = explode("-", $date); $day = $date[2]; $month = $date[1]; $year = $date[0]; $expired=mktime(0,0,0,$day + 90, $month, $year); //check date is going in correctly print_r($date); echo "<br />"; //check timestamps echo "exp: $expired<br />now: " . time() . '<br />'; if (time() >= $expired) { $expiry = date("d/m/y", $expired); echo"Your listing ".$row['Url']." expired on $expiry<br>"; } else { / /get days - divide timestamp (seconds) by 60 to get minutes, etc $days = ($expired - time()) / 60 / 60 / 24; echo "there are $days days left till expiry"; } } ?>
  17. what exactly are you trying to find? the amount of days between now and the expiry... ? if (($timestamp == $expired) that will only be true for one second in all of eternity. the mktime function shows how many seconds have passed since jan 1st 1970... AKA a unix timestamp... its a number like 328947239847 the time() function returns the current unix timestamp so if you changed that to <?php include('config.php'); $sql_rdate="SELECT * FROM table WHERE status='1' "; $rs_dt=mysql_query($sql_rdate) or die (mysql_error()); while($row= mysql_fetch_assoc($rs_dt)){ $date = $row['rDate']; $date = explode("-", $date); $day = $date[2]; $month = $date[1]; $year = $date[0]; $expired=mktime(0,0,0,$day + 90, $month, $year); if (time() >= $expired) { $expiry = date("d/m/y", $expired); echo"Your listing ".$row['Url']." expired on $expiry<br>"; } else { / /get days - divide timestamp (seconds) by 60 to get minutes, etc $days = ($timestamp - time()) / 60 / 60 / 24; echo "there are $days days left till expiry"; } } ?>
  18. i'm assuming you mean you want to find how many days between now and the 90 day expiry date? not between date in the db and the 90 day mark.. which would be 90days? make the database date into a unix timestamp usking the mktime() function.. http://php.net/manual/en/function.mktime.php //get date from db, i just put in a mock date, this is in mysql db date format $date = "2009-10-06"; $date = explode("-", $date); $day = $date[2]; $month = $date[1]; $year = $date[0]; $timestamp= mktime(0,0,0,$day, $month, $year); if (($timestamp - time()) < 0) { //it has expired } else { //get days - divide timestamp (seconds) by 60 to get minutes, etc $days = ($timestamp - time()) / 60 / 60 / 24; echo "there are $days days left till expiry"; } also if the date in the DB still needs 90 added to it, you can change the line $timestamp= mktime(0,0,0,$day, $month, $year); to $timestamp= mktime(0,0,0,$day + 90, $month, $year);
  19. you've got while infront of the mysql_fetch_array but theres no commands being executed within that while loop... its being ended by the semi-colon straight after it... use this if theres only one row per IP... <?php $ip = $_SERVER['REMOTE_ADDR']; $date = date('M,d,Y'); $host = "localhost"; //database location $user = "user"; //database username $pass = "pass"; //database password $db_name = "ip"; //database name //database connection $link = mysql_connect($host, $user, $pass); mysql_select_db($db_name); $check = mysql_query("SELECT * FROM ip WHERE ip='$ip'"); $row = mysql_fetch_array($check); if ($row['ip']=="$ip" & $row['date']=="$date") { mysql_close($link); } else { mysql_query("INSERT INTO ip (id, ip, date) VALUES ( NULL, '$ip', '$date' )") or die(mysql_error()); mysql_close($link); } ?>
  20. the ajax keeps updating the db every 30 seconds, so if the user has logged out the timestamp will be older than 30 seconds. and on top of that i'd also put a bit in my logout script saying $sql = @mysql_query("UPDATE users SET loggedIn = 0 WHERE userID = $userID"); and then for the script to see if users are logged in $userID = whatever; $sql = @mysql_query("SELECT loggedIn, timestamp FROM users WHERE userID = $userID"); $userDetails = mysql_fetch_array($sql); if ($userDetails['loggedIn'] == 1 && ((time() - $userdetails['timestamp']) < 30)) { //user is logged in, echo logged in image or whatever you want to do } else { //user is logged off }
  21. yourNewPhpPage.php will be a simple php page with this code, you'll have to set up the $user_id variable so it gets the userid from the $_SESSION correctly... if you have it stored in there? //security measures up here? i.e. if (isset($_SESSION['logged_in'])) { raghh } $user_id = $_SESSION['id']; $sql = @mysql_query("UPDATE users SET timestamp = UNIX_TIMESTAMP() WHERE userid = $user_id");
  22. you'd have a PHP page with a script like //security measures up here? i.e. if (isset($_SESSION['logged_in'])) { raghh } $user_id = $_SESSION['id']; $sql = @mysql_query("UPDATE users SET timestamp = UNIX_TIMESTAMP() WHERE userid = $user_id"); then i'd have a jquery script in the <head> of each page like so <script> jQuery(document).ready(function() { function pageLoad() { //ajax for automatic pageload, change the .php page to whatever you make $.post("yourNewPhpPage.php"); //call 30sec timeout setTimeout(pageLoad(), 30000); }; pageLoad(); }); </script> jquery isn't my specialty, but that *should* work... **EDIT** to run this you'll need to have the jquery file linked to your site... jquery.com
  23. ... not that i can see? only problems i can see are HTML errors with your <tr> and <td> tags? if the 'else' block executed, the first table row wouldn't have an opening <tr><td>, just a closing <tr><td> try <table> <?php if (tep_session_is_registered('customer_id')) {?> <a href="<?php echo tep_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>" class="headerNavigation"><?php echo tep_image(DIR_WS_IMAGES . 'buttonlogout.jpg', HEADER_TITLE_LOGOFF); ?></a> <a href="account_history.php"><img border="0" src="images/orderhistory.png"></a> <?php }else{ ?> <tr><td><?php echo tep_draw_form('login', tep_href_link(FILENAME_LOGIN, 'action=process', 'SSL'));?></td></tr> <tr><td>Email :<?php echo tep_draw_input_field('email_address');?></td></tr> <tr><td>Password:<?php echo tep_draw_password_field('password');?></td></tr> <tr><td><?php echo tep_image_submit('button_login.gif', IMAGE_BUTTON_LOGIN); ?> </td></tr> <?php } ?> </table>
  24. ... you could have an automatic ajax script which sent a request to a PHP page every 30seconds or 1minute or so? and that would update the timestamp in the database...
×
×
  • 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.