Jump to content

Mutley

Members
  • Posts

    765
  • Joined

  • Last visited

Everything posted by Mutley

  1. Thanks, I've nearly got it! I filter the dates like this: <?php $sql = "SELECT date, event FROM calendar WHERE YEAR(date) >= $thisyear AND MONTH(date) >= $thismonth ORDER BY date DESC LIMIT 10"; $result = mysql_query($sql); while(list($date, $event) = mysql_fetch_row($result)) { ?> Which works great, just how do I with PHP select just the 'day' from the date SQL field? If I do date('j',$date); It doesn't work. Which I guess is because it isn't a time stamp. I can set new DATE_FORMAT in the query but it's a lot of extra code to do it for each day/month/year.
  2. Ah, of course. So it's just a simple insertion of: $date = '$year-$month-$day'; Then can you use date() to select them? If I wanted to select just the month would I just do date('m'); or doest that only work with stamps? Thanks a lot, Nick.
  3. Thanks a lot, now how would I match these results? Say in a SQL query I want to find a certain row of a certian Day/Month/Year, say 10th Jan 2003. I guess you would do a similar thing but in reverse. Kind Regards, Nick.
  4. <script language='javascript'> var name = confirm("Are you sure you wish to purchase a <?=$conMan?> <?=$conNam?>?"); if(name==true){ window.location.href='shop.php?cat=<?=$cat?>&prod_id=<?=$prod_id?>&confirm=1'; }else{ window.location.href='shop.php?cat=<?=$cat?>'; } </script> It pops up but when you select "Okay" it doesn't do anything... like it isn't true?
  5. I'm soon to programme a site, then have someone else design it. What's the best practical way to do this, to make it as easiest as possible for the Designer? Do I literally just do a script with no formatting, or do I do the layout myself and let the designer go in and alter it all? Anyone else have experience of Programmer+Designer cooperation? Any tips or suggestions appreciated. Thanks in advance, Nick.
  6. Thanks alot! That worked! Do you know why?
  7. It echos the extension. It says on the Save As popup: application/octet-stream As I said, it picks up the .PSD or .PDF file extensions fine.
  8. There is no extension. Which is odd, as PDF/PSD works fine. Office is installed on the machine.
  9. I use the following to get files off the server as downloads... $file = spreadsheet.xls; It popsup as an Unknown file? It seems with Microsoft Office documents it does this but I've tried PDF and PSD and they display fine and open with the correct application. header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($file)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); ob_clean(); flush(); readfile($file); exit; Any ideas? Thanks, Nick.
  10. I agree with a timestamp but how would I convert the day/month/year figures into that?
  11. Which is the best method to select and store Dates. I have 3 dropdowns, for Day, Month and Year. So do I save these to 3 separate fields or use 1 field and convert it into a "date" style format. What I'm wanting to down the line, is compare the date entered to the current date (using a simple date('d-M-Y') style thing and I imagine using 3 separate fields wouldn't work as how would I convert it to a date for use in comparing to the PHP date function? Thanks, Nick.
  12. Hmm, don't think so but here are my functions: <?php //MySQL Query Function function Query($Query = NULL){ $Return = @mysql_query($Query, $this->conn) or $this->Error(mysql_error(),'Executing MySQL Query - '.$Query); //Increase number of queries $this->Queries++; //Set last query $this->LastQuery = $Query; //Insert query into Query List array_push($this->QueryList, $Query); return $Return; } //End Query() //MySQL Fetch Array Function function FetchArray($Query = NULL){ $Query = $this->Query($Query); $Array = @mysql_fetch_assoc($Query) or $this->Error(mysql_error(),'Fetching data array using - '.$Query); return $Array; } //End Fetch_Array //Function to return MySQL Numrows function Rows($Query = NULL){ //If empty then use query in cache if(empty($Query)){ $Query = $this->Query; } else{ $Query = $this->Query($Query); } $Rows = @mysql_numrows($Query); return $Rows; } //End Rows() //MySQL Result Function function Result($Query, $Row, $Field){ //Return Filed Valie $return = @mysql_result($Query, $Row, $Field); return $return; }//End Result() //Output list of queries to the browser function QueryList(){ //Only execute if debug mode is on if($this->DebugMode){ echo '<table>'; echo '<tr><td>'; echo 'Query ID'; echo '</td><td>'; echo 'Query'; echo '</td></tr>'; //Loop through all query's stored foreach($this->QueryList as $id => $qry){ echo '<tr><td>'; echo $id; echo '</td><td>'; echo $qry; echo '</td></tr>'; } echo '</table>'; } }//End QueryList() //Function to Display Error Message function Error($MySQL_Error,$Notes){ if($this->DebugMode){ echo 'The following error occured whilst forming the following operation - '; echo $Notes; echo '<br />'; echo 'The server returned the following message:'; echo '<br /><br />'; echo $MySQL_Error; exit; } else{ die($this->ErrorMessage); } } //End Error() }; ?>
  13. SQL is v5.0.67 I think and yes I'm using MyISAM. Here is the table SQL: CREATE TABLE IF NOT EXISTS `product_products` ( `product_id` int(11) NOT NULL auto_increment, `cat_id` int(11) NOT NULL, `product_name` varchar(255) NOT NULL, `product_slug` varchar(255) NOT NULL, `product_image0_name` varchar(255) NOT NULL, `product_image0_s_width` int(11) NOT NULL, `product_image0_s_height` int(11) NOT NULL, `product_image0_m_width` int(11) NOT NULL, `product_image0_m_height` int(11) NOT NULL, `product_image1_name` varchar(255) NOT NULL, `product_image1_s_width` int(11) NOT NULL, `product_image1_s_height` int(11) NOT NULL, `product_image1_m_width` int(11) NOT NULL, `product_image1_m_height` int(11) NOT NULL, `product_image2_name` varchar(255) NOT NULL, `product_image2_s_width` int(11) NOT NULL, `product_image2_s_height` int(11) NOT NULL, `product_image2_m_width` int(11) NOT NULL, `product_image2_m_height` int(11) NOT NULL, `product_image3_name` varchar(255) NOT NULL, `product_image3_s_width` int(11) NOT NULL, `product_image3_s_height` int(11) NOT NULL, `product_image3_m_width` int(11) NOT NULL, `product_image3_m_height` int(11) NOT NULL, `product_image4_name` varchar(255) NOT NULL, `product_image4_s_width` int(11) NOT NULL, `product_image4_s_height` int(11) NOT NULL, `product_image4_m_width` int(11) NOT NULL, `product_image4_m_height` int(11) NOT NULL, `product_image5_name` varchar(255) NOT NULL, `product_image5_s_width` int(11) NOT NULL, `product_image5_s_height` int(11) NOT NULL, `product_image5_m_width` int(11) NOT NULL, `product_image5_m_height` int(11) NOT NULL, `product_image6_name` varchar(255) NOT NULL, `product_image6_s_width` int(11) NOT NULL, `product_image6_s_height` int(11) NOT NULL, `product_image6_m_width` int(11) NOT NULL, `product_image6_m_height` int(11) NOT NULL, `product_image7_name` varchar(255) NOT NULL, `product_image7_s_width` int(11) NOT NULL, `product_image7_s_height` int(11) NOT NULL, `product_image7_m_width` int(11) NOT NULL, `product_image7_m_height` int(11) NOT NULL, `product_image8_name` varchar(255) NOT NULL, `product_image8_s_width` int(11) NOT NULL, `product_image8_s_height` int(11) NOT NULL, `product_image8_m_width` int(11) NOT NULL, `product_image8_m_height` int(11) NOT NULL, `product_description` varchar(255) NOT NULL, PRIMARY KEY (`product_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=50 ; I've also attached the PHP file that does the uploading with this script in. Hopefully you can figure out what it could be? I really appreciate your help. Regards, Nick. [attachment deleted by admin]
  14. Or yourself, it's a horrible feeling pretending you know something you don't.
  15. I tried the auto-increment field and still no luck... they are inserted into the rows automatically anyway. I just can't figure it out. Is there something I'm missing out that could be causing this? I really appreciate your help so far.
  16. Thanks alot but still no luck unfortunately. It outputs: Paste that into my SQL form in phpmyadmin and voila, it works fine? ???
  17. I've tried renaming them but it still does not work. Completely bizarre. The query output is incorrect from the array, I've just noticed it duplicates the fields and doesn't do the _m_ or width fields. Not that this would be causing it.
  18. Grrr! Same again, it makes so little sense to me. Thanks a lot for your time with that code kenrbnsn. Here's the output:
  19. Any ideas? It's really starting to boggle me why the query works but not via a PHP script. Thanks, Nick.
  20. This isn't making any sense to me, why would the query fail in PHP but fine through phpmyadmin? The output doesn't display any special characters that would break it either.
  21. Thanks, Nick.
  22. I recieve this error: Unknown column 'product_image0_name' in 'field list' But the SQL seems to insert fine if I copy the output and paste it into PHPmyAdmin, so curious why the PHP script generates this error. Query below: <?php $Query = "INSERT INTO `product_products`( `cat_id`, `product_name`, `product_slug`, `product_image0_name`, `product_image0_s_width`, `product_image0_s_height`, `product_image0_m_width`, `product_image0_m_height`, `product_image1_name`, `product_image1_s_width`, `product_image1_s_height`, `product_image1_m_width`, `product_image1_m_height`, `product_image2_name`, `product_image2_s_width`, `product_image2_s_height`, `product_image2_m_width`, `product_image2_m_height`, `product_image3_name`, `product_image3_s_width`, `product_image3_s_height`, `product_image3_m_width`, `product_image3_m_height`, `product_image4_name`, `product_image4_s_width`, `product_image4_s_height`, `product_image4_m_width`, `product_image4_m_height`, `product_image5_name`, `product_image5_s_width`, `product_image5_s_height`, `product_image5_m_width`, `product_image5_m_height`, `product_image6_name`, `product_image6_s_width`, `product_image6_s_height`, `product_image6_m_width`, `product_image6_m_height`, `product_image7_name`, `product_image7_s_width`, `product_image7_s_height`, `product_image7_m_width`, `product_image7_m_height`, `product_image8_name`, `product_image8_s_width`, `product_image8_s_height`, `product_image8_m_width`, `product_image8_m_height`, `product_description`) VALUES ( '$cat_id', '$product_name', '".Word2Slug($product_name)."', '".$product_image_name[0]."', '".$Image[0]['small']['width']."', '".$Image[0]['small']['height']."', '".$Image[0]['medium']['width']."', '".$Image[0]['medium']['height']."', '".$product_image_name[1]."', '".$Image[1]['small']['width']."', '".$Image[1]['small']['height']."', '".$Image[1]['medium']['width']."', '".$Image[1]['medium']['height']."', '".$product_image_name[2]."', '".$Image[2]['small']['width']."', '".$Image[2]['small']['height']."', '".$Image[2]['medium']['width']."', '".$Image[2]['medium']['height']."', '".$product_image_name[3]."', '".$Image[3]['small']['width']."', '".$Image[3]['small']['height']."', '".$Image[3]['medium']['width']."', '".$Image[3]['medium']['height']."', '".$product_image_name[4]."', '".$Image[4]['small']['width']."', '".$Image[4]['small']['height']."', '".$Image[4]['medium']['width']."', '".$Image[4]['medium']['height']."', '".$product_image_name[5]."', '".$Image[5]['small']['width']."', '".$Image[5]['small']['height']."', '".$Image[5]['medium']['width']."', '".$Image[5]['medium']['height']."', '".$product_image_name[6]."', '".$Image[6]['small']['width']."', '".$Image[6]['small']['height']."', '".$Image[6]['medium']['width']."', '".$Image[6]['medium']['height']."', '".$product_image_name[7]."', '".$Image[7]['small']['width']."', '".$Image[7]['small']['height']."', '".$Image[7]['medium']['width']."', '".$Image[7]['medium']['height']."', '".$product_image_name[8]."', '".$Image[8]['small']['width']."', '".$Image[8]['small']['height']."', '".$Image[8]['medium']['width']."', '".$Image[8]['medium']['height']."', '$product_description')"; ?> Thanks in advance, Nick.
  23. The function is: <?php //Write File function WriteFile($File, $Data){ $handle = fopen($File, 'w'); fwrite($handle, $Data); fclose($handle); } ?> Thanks, Nick.
  24. Thanks for your reply! The form is correct and the folders are set to CHMOD 777, the PHP.ini is okay too... it seems it doesn't upload the file to begin with, hence the error, when I look for it on the server, it isn't there either.
×
×
  • 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.