Jump to content

laPistola

Members
  • Posts

    245
  • Joined

  • Last visited

    Never

Everything posted by laPistola

  1. News isn't a reserved word as well is it?? It works without me exiting the word news. Thanks anyway!
  2. $return is not set unless $id is not empty try putting: $return = "" in the else of the condition if($id != ""):
  3. Do you have access to PHPMyAdmin on the MySQL server? If you do you can always just export the data including all the table config using the tabs across the top.
  4. Probably need more info but if I understand you just need to use a comma on your ORDER BY clause eg: ORDER BY premium, name ASC How ever you will need to switch the code value. If its a premium profile then it needs to be 0 and if not a 1.
  5. MYSQL: 5.1 Hello This is the line of code "SELECT * FROM news WHERE (show >= ".$tdate." AND expire < ".$tdate.") OR (show = 00000000 AND expire < ".$tdate.") AND (show = 00000000 AND expire = 00000000) ORDER BY `order`, title ASC" The error is You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'show >= 20111112 AND expire < 20111112) OR (show = 00000000 AND expire < 2011111' at line 1 show and expire are both date fields in the DB, $tdate is todays date in the format yyyymmdd Generally I need the record to show if both show and expire = 00000000, If show is of the days date or the date has pasted AND it hasn't gone past the expire date. Also I need the records to show if either date = 00000000 and there show on or expire condition is true. I have gone through many of websites, looked at examples and can't see where my issue is. Thanks in advance
  6. it works perfect now. If it helps anyone this is my code $file = urldecode($_GET['file']); if(file_exists($file)) { header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($file)); header("Cache-Control: no-cache"); header("Pragma: no-cache"); ob_clean(); flush(); readfile($file); header("Location: ".urldecode($_GET['return'])); } else { header("Location: ".urldecode($_GET['return'])."&status=fileErr"); }
  7. Thank you, Thank you and Thank you The mod_header wouldn't be ideal as the file could be one of about 30 different formats. Ill use the readfile() method, looking at the php manual its the perfect solution. Did I thank you
  8. Now I have done just this but its not working, but i bet that is my code which is at fault as I didn't think my method would work as it basically loaded a new page without the header info. My first way was: <?php // stop cashing header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); ?> <a href="file.doc" target="_blank">Click here</a> and my second was in it basic form <?php // stop cashing header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); header("Location: file.doc"); ?>
  9. Hello PHP 5.3 Im looking for a solution to a problem. A site im building stores documents. You can then upload a newer version of that document that overrides the old document. But if you viewed the first document when trying to view the new document it loads the old one up unless you clear your internet files inbetween. Is there a way to make the site not download the file to the clients computer or a way to delete the clients local temp version before downloading and opening the new document?
  10. PHP 5.3 MySQL 5.1 Hello Im building some software for a training company and they require that there students upload evidence documents. Each document needs an id number starting from 1. Each student needs to start from 1. I have one table that holds all the data for the evidence so using a auto increment in the DB column is not suitable. In the students table there is a column "file_tally" that starts from 1 and increases every time they submit evidence. This tally number is stored in the evidence row also. This is the code: // find tally value mysql_select_db($dbn,$db); $tsql = "SELECT file_tally FROM students WHERE sid = ".$_SESSION['student_id']; $tquery = mysql_query($tsql,$db) or die(mysql_error()); $tally = mysql_result($tquery,0); intval($tally)++; // update tally $utsql = "UPDATE students SET file_tally = '".$tally."' WHERE sid = ".$_SESSION['student_id']; if(isset($_SESSION['student_id']) && !empty($_SESSION['student_id'])) { mysql_query($utsql,$db) or die(mysql_error()); } // insert record $sql = "INSERT INTO evidence (`file`,sid,tally) VALUES ('".$name."','".$_SESSION['student_id']."','".$tally."')"; mysql_query($sql, $db) or die(mysql_error()); Now it works fine but it had occurred to me that if a staff member was uploading a document for the student at the every same split second (unlikely I know) they may both then get the same tally value and two documents get inserted into the DB with the same tally number. Is there a way we can write the first command $tsql = "SELECT file_tally FROM students WHERE sid = ".$_SESSION['student_id']; In a way where it increases the tally value in the command string? This could then keep that value in reserve and if there is an error I could adbopt the script to then "give" that value back by decreasing the value in the students file_tally.
  11. After finding the sticky to an article that explained quiet well how to write rewrites I did this: RewriteEngine On RewriteRule ^blogs/article/([0-9]+)/?$ blogs.php?bid=$1 [NC,L] And it worked great!
  12. Please see this thread for more details http://www.phpfreaks.com/forums/index.php?topic=234739.0;topicseen . I stumbled to it after a Google search. Server: Apache/2 PHP: 5.3.6 PHP is ran as CGI. Im trying to achieve a friendly URL for a blog im writting. ie the url looks like domain.com/blogs/article/1 where as blogs is the .php file After a ForceType not working due to my host using CGI to run php files I found this solution and inserted it into my .htaccess file: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] which just made a redirection of domain.com/blogs/.php (it entered a / slash between blogs and .php) So after reading the above linked to thread I changed my .htaccess file to: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule (.*)/?$ $1.php [NC,L] Which like the OP in that thread I received an 500 error. This is the log error: Now I only really what this on the blogs.php file as the rest of the site is fairly static. Any help would be great thank you.
  13. Yes I was thinking about doing it anyway to make the software more flexible with future expansion. Even more so to prevent more tables getting created that stores the sid and I or someone forgets to add it to the delete scripts.
  14. Hello I have been looking for the very same solution and after trying your amendment in my htaccess file I got the 500 error. My logs state this: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
  15. Show us the code you have. If you don't want empty cells the only other way would be to use colspan like eg if(!empty($row['accounts'])) { echo "<td>$row['accounts']</td>"; echo "<td>$row['paid']</td>"; } else { echo "<td colspan=\"2\">$row['paid']</td>"; } This properly isn't what your after but untill I see code I don't understand anymore what your after.
  16. <tr> <?php if(!empty($row['accounts'])){ echo "<td>".$row['accounts']."</td>"; } else { echo "<td> </td>"; } ?> </tr> I have added the extra code and used the empty function rather then just a compare
  17. So if im right you are saying the only real way would be to run a SELECT command on the COLUMNS table within the information schema eg SELECT TABLE_NAME FROM COLUMNS WHERE COLUMN_NAME = 'sid' Then run a loop that does a query on each table_name returned? If so this would run one more query then if I just manually told the script which tables to target.
  18. Im writing some software for a training company and one of the features is to delete a student from the system. Now just deleting a student from the students DB table would cause errors as the information regarding what course they was on and which units had been assigned to them and IV forms and list goes on. All this would still be in the DB and come up on some pages within the application, but when clicked on an error would appear as it wouldn't be able to find the student in the DB. So instead of doing a few queries to target and delete the rows that contain there id from each table, I wondered if there was a faster way not just to write it (this way would only take 5 mins to code anyway) but server load times. There are a few times where a command such as I have inquired about would be an advantage. Mostly when deleting information.
  19. MySQL 5.1 Is there a command that can find every table that contains a given field name and then delete every row that contains a given value within that field. I know the below don't work (after trying) but it may help explain what im look at doing. DELETE FROM * WHERE id = 1 Thank you.
  20. Cheers No idea why i haven't came across upload max filesize before.
  21. Hello Im trying to upload mp3s from a form. In the form I have the MAX_FILE_SIZE set at 90000000 (so big to make sure it wasn't my maths). I have checked with phpinfo() and the max upload is set at 8mb. The mp3s will be between 3-4mb in size. I have uploaded small mp3's successfully (440k) so i know the script is working fine, however when i try to upload one at around 3mb it fails, even tried different file sizes in the same ball park size. I suspect the server is blocking them. Any ideas on a fix? Thank you. No script posted as i say its all working.
  22. Haha i have been hit by that one tonight as well!
  23. Strange i check for whitespace about 4 times when echoing $typre but this has worked fine. Thank You very much.
×
×
  • 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.