Jump to content

premiso

Members
  • Posts

    6,951
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by premiso

  1. Where did you get the ziparchive class? Look for a method or property of the class that returns the ziparchive resource and call that inside the zip_close, or even maybe a close method of the ziparchive class and just call that instead of invoking the zip_close function.
  2. It can handle it, just create 3 more fopen handlers $fp1 $fp2 $fp3 outside the loop and it should be fine.
  3. The following method will not work in all browsers. It also may take a while to run but here it is: <?php $filename=$_POST['filename']; $path=$_POST['path']; $tablename=$_POST['tablename']; $header=$_POST['header']; $list=$_POST['list']; $dealer=$_POST['dealer']; $distributor=$_POST['distributor']; $central=$_POST['central']; $part=$_POST['part']; ini_set('max_execution_time', '999'); $db = mysql_connect('localhost', 'u', 'p') or die(mysql_error()); mysql_select_db('d') or die(mysql_error()); if($header==YES) { mysql_query("DELETE FROM {$tablename} LIMIT 1"); echo"Removing header....<br /><br />"; } mysql_query("DELETE FROM {$tablename} WHERE $list='0'"); echo"Removing rows where the retail price is zero.<br /><br />Writing File... Please wait.."; $fp= fopen("ftp://user:pass@myip/u/ssc/price/$filename", "a"); // moved out of loop to increase performance. $result = mysql_query("SELECT * FROM {$tablename}"); $i=0; while ($row = mysql_fetch_assoc($result)) { if (($i%100) == 0) { echo "."; ob_flush(); flush(); } $i++; $code="1038"; $partnumber=$row["$part"]; $targetChars=array('"', '$', ','); $partnumber=str_replace($targetChars, "", $partnumber); $tbp="TBP"; $stdpack="1"; $zero="0"; $listprice=$row["$list"]; $listprice=str_replace($targetChars, "", $listprice); $listprice = number_format($listprice, 2, '.', ''); $cost=$row["$central"]; $cost=str_replace($targetChars, "", $cost); $cost = number_format($cost, 2, '.', ''); $cost2=$row["$central"]; $cost2=str_replace($targetChars, "", $cost2); $dealerprice=$row["$dealer"]; $dealerprice=str_replace($targetChars, "", $dealerprice); $dealerprice = number_format($dealerprice, 2, '.', ''); $division=".95"; $distributorprice=$cost2/$division; $distributorprice = number_format($distributorprice, 2, '.', ''); //$row["$distributor"]; $outputstring = $code. "\t".$partnumber."\t".$tbp."\t".$tbp."\t".$stdpack."\t".$zero."\t".$zero."\t".$listprice."\t".$listprice."\t".$cost."\t".$dealerprice."\t".$dealerprice."\t".$dealerprice."\t".$dealerprice."\t".$dealerprice."\t".$distributorprice."\t".$zero."\t".$zero."\t".$zero."\t".$zero."\t".$zero."\t".$zero."\t".$zero."\t".$zero."\t".$zero."\t".$zero."\t".$zero."\t".$zero."\t".$zero."\n"; //print $outputstring;echo"<br />"; fwrite($fp, $outputstring, strlen($outputstring)); } fclose($fp); ?> You will also notice I moved to fopen out of the loop to increase performance.
  4. onunload is the only way I know how. The other option is using a timeout, after x minutes log the person out and query the DB. PHP does not know what the client does, only how to send data to the client.
  5. <?php $cnt = count($aa1); for ($i=0;$i<$cnt;$i++){ $expl=explode(chr(58),$aa1[$i]); You would just access the array element index with $i
  6. Well, I highly doubt this is the problem, cause I do it all the time too, but who knows. Try changing each form field id="fieldname_id" and see what that does. If that still does not work, are you sure your errors are turned on to display errors and see if any errors are coming through? The next step would be, in the PHP file, try removing an include and see if it displays anything, then add it back in and try the next. It could be an error in your pages, but why it would trigger on separate browsers I do not know. You could also try adding ob_start before the first include and see if it works or not.
  7. if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0) { $user = $session->username; $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } $UPDATE = "UPDATE images SET id ='$user', name='$fileName', size='$fileSize', type='$fileType', content='$content'"; $ADD = "INSERT INTO images (id,name,size,type,content ) ". "VALUES ('$user', '$fileName', '$fileSize', '$fileType', '$content')"; $sql = "SELECT id FROM images WHERE id = '$user' LIMIT 1"; $result = mysql_query($sql); if (mysql_num_rows($result) > 0) { $SET = $UPDATE; }else { $SET = $ADD; } mysql_query($SET) or die('Error, query failed'); echo "<meta http-equiv=\"refresh\" content=\"0;url=profile.php?user=$user\"/>"; echo "<br>File $fileName uploaded<br>"; } EDIT: Modified to do the update instead, mis-read the description...
  8. $rowcount = 0; $query = mysql_query("SELECT * FROM hrpartya"); echo "<TABLE width=\"70%\" bordercolordark=\"#000000\" bordercolorlight=\"#FFFFFF\" cellpadding=\"5\"><tr><td><center>Party Name:</center></td></tr>"; while($showparty = mysql_fetch_array($query)){ if (($rowcount%2) == 0) { echo "<tr bgcolor=\"#DDD2C3\"><td><p align=\"center\">".$showparty['party_name']."</p></td></tr>"; }else { echo "<tr bgcolor=\"#A49A8C\"<td><p align=\"center\">".$showparty['party_name']."</p></td></tr>"; } $rowcount++; } Modulus is what you want (the % operator).
  9. Try searching the forums, about 2-3 days ago a guy had the same problem with uploading and firefox, I cannot remember what the solution was, but maybe it will work here too. Found it: http://www.phpfreaks.com/forums/index.php/topic,230310.msg1067826.html#msg1067826 Edit: Linked to the answer of the post.
  10. Not sure why, I just ran the test on my server doing this: <?php $a['time'] = "17:00"; $newtime = date("H:i", strtotime($a['time'])+3600*2); // 3600*2 = 2 hours echo "The time should be 19:00 and (drum role) the time is: " . $newtime; die(); ?> Output: The time should be 19:00 and (drum role) the time is: 19:00
  11. $sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$encrypted_password' LIMIT 1"; For username selecting I always do LIMIT 1 to prevent anyone from trying to pull more than 1 row. As for what bluesoul said, if you trim the username/password when the user registers you should do the same to check the validity of their password/name etc. Especially with an MD5 hash it may not be as lienent as the username might be.
  12. Quick on the draw I thought I'd be dead, he put the gun to my head and this is what he said.... Hey, you did the code I just explained, props for complimenting my work ^.- lol EDIT: But remember this will only take effect for any new cookies. So you may have to logout etc to see the changed effects.
  13. Force users via .htacces to always use www. But really look at the setcookie function set the domain to .domain.com and specify the path as "/" and it should work.
  14. Ok, I hate that stupid strtotime function, but it should work in this aspect. <?php $newtime = date("H:i", strtotime($a['time'])+3600*2); // 3600*2 = 2 hours ?> That should work I believe.
  15. if (strtolower($mylocation) != strtolower($hislocation)) { // strtolower added to avoid mis-types of case. echo 'You cannot attack that player as they are not in the same area as you.'; exit; } Replace that if/else section with the above. If the users are not in the same area then that will display and exit. Whether this is what you want or not I do not know. You are too vague and cannot seem to grasp that the above code I have posted is what you want you just have to apply your own logic to it. Good luck!
  16. You have to echo it out using [m]date/m] <?php $newtime = strtotime("+2 hours",$a['time']); echo date('H:i', $newtime); ?> Should print it out right. Just remember, we usually provide examples, it is up to you to take those examples and implement them correctly in your code, IE replacing "$oldtime" to be $a['time'].
  17. I gathered that much. What does this: $result = mysql_query("SELECT `location` FROM `users` WHERE `username` = '$username'") or die(mysql_error()); $row = mysql_fetch_row($result); $mylocation = $row[0]; $result = mysql_query("SELECT `location` FROM `users` WHERE `username` = '$target'") or die(mysql_error()); $row = mysql_fetch_row($result); $hislocation = $row[0]; IF (strtolower($mylocation) == strtolower($hislocation)) { // strtolower added to avoid mis-types of case. echo 'Yes it still worked cause they can attack me! His Location: ' . $hislocation . ' MyLocation: ' . $mylocation; } else { echo 'Yes it still worked cause they cannot attack me! His Location: ' . $hislocation . ' MyLocation: ' . $mylocation; } return?
  18. <form enctype="multipart/form-data" form id="form1" name="form1" method="post" action="newrecipe.php"> Should be: <form enctype="multipart/form-data" id="form1" name="form1" method="post" action="newrecipe.php"> The rest look fine, try changing that and see if it fixes your results.
  19. Honestly, the three browsers should not make a difference in either. What most likely is the issue is your form, so post the HTML code for that form/page that you use for the upload process.
  20. You will have to define it, I would suggest, instead of using the month name, use the months numerical digit and do the order by that. I am sure you can use the mysql date function to do that bit too.
  21. Just a side note, not related to the problem: <?php require_once("includes/connection.php"); ?> <?php require_once("includes/session.php"); ?> <?php require_once("includes/functions.php"); ?> <?php confirm_logged_in(); ?> <?php Why do that? This would be much easier: <?php require_once("includes/connection.php"); require_once("includes/session.php"); require_once("includes/functions.php"); confirm_logged_in(); There is really no reason to put them in their own <?php ?> tags...
  22. while ($row = odbc_fetch_array($TrackerData)) { $dates = explode(" ", $row['TheDate']); $TheDate = str_replace("-", "/", $dates[0]); print("<br />" . $TheDate); } You could do that, or just simply use the strtotime one I posted, I think the above will be faster, but it is 2 extra lines of code, so yea. Strtotime method: while ($row = odbc_fetch_array($TrackerData)) { print("<br />" . date('Y/m/d', strtotime($row['TheDate']))); }
  23. Sorry: while ($row = odbc_fetch_array($TrackerData)) { print("<br />" . date('Y-m-d', strtotime($row['TheDate']))); } That would work, or a faster version, since strtotime is slow: while ($row = odbc_fetch_array($TrackerData)) { $dates = explode(" ", $row['TheDate']); $TheDate = $dates[0]; print("<br />" . $TheDate); }
  24. That code does not return the current date? The first line of your code is the current date....so how is that not returning the current date?
  25. $sql_category = ($category == 'all') ? "" : "AND category='$category'"; Try replacing that line. See what happens. Decided to add an explanation: Since you already have "WHERE" inside the query here: $qSearch = "SELECT * FROM history WHERE info LIKE '%$info%' $sql_category ORDER BY title desc "; Adding WHERE again in the $sql_category was causing the error, because you cannot have 2 where clauses in a SQL statement. Thus, you know the WHERE clause is going to be in there already, so there is no need to have it, which is why I took the where clause out of the $sql_category declaration.
×
×
  • 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.