Jump to content

Zoombat

New Members
  • Posts

    8
  • Joined

  • Last visited

Zoombat's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I also saw something wrong in your collation: CHARACTER SET latin1 COLLATE latin1_bin; A collation determines how the relational operators (<, >, etc.) and ORDER BY clauses sort strings. Issues considered by collations are: Are uppercase and lowercase letters considered equivalent? Is whitespace significant? Do accented letters sort equal to the unaccented versions, after the unaccented versions, or at the end? Are digraphs like "ch" and "ll" sorted like separate letters? Are Unicode compatibility equivalents like AᴬⒶA�������������������������� treated the same? Reference manual MySQL says: You'd better be aware that when you use latin1_bin, your TEXT becomes a BLOB. bin > binary You'd use latin1_general_ci or latin1_general_cs, this depends on your choise. ci > case insensitive cs > case sensitive http://en.wikipedia....ry_large_object http://www.joelonsoftware.com/articles/Unicode.html
  2. Hi, For indexes on BLOB and TEXT you need to specify a index prefix length. So: CREATE TABLE `thistable`.`search_test` (`id` INT(11) NOT NULL, `name` TEXT(255) NOT NULL, `description` TEXT(255) NOT NULL, `price` INT(11) NOT NULL, `img` TEXT(255) NOT NULL) ENGINE = MyISAM CHARACTER SET latin1 COLLATE latin1_bin; For CHAR and VARCHAR, a prefix length is optional. Also TEXT and BLOB fields are stored off the table with the table just having a pointer to the location of the actual storage. VARCHAR is stored inline with the table. VARCHAR is faster when the size is reasonable, the tradeoff of which would be faster depends upon your data and your hardware, you'd want to benchmark a realworld scenario with your data Read about string types here: http://dev.mysql.com...e-overview.html
  3. So my silex application did run for a good time, but now it's disfunctional, and I do not know exactly why, because I believe nothing changed.. It should be a little website with administration page. - This is a snippet of the code, the total code is still in concept phase. - For the full code: http://pastebin.com/myXwF4nT - Other code parts on request. - Controller::invoke() is called from the index.php Thanks in advance! require_once __DIR__.'/vendor/autoload.php'; require_once __DIR__.'/const.php'; require_once __DIR__.'/route.php'; require_once __DIR__.'/../model/database.php'; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\HttpKernelInterface; class Controller { public static $appProvider = null; public static $expireTime = 5400; public static $timeStamp = null; public static $routeArray = null; public static $routeMatched = null; public static $subRouteMatched = null; public static function getSilex() { if(self::$appProvider == null) { self::$appProvider = new Silex\Application(); // Twig Service Provider self::$appProvider->register( new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__.'/../view/', 'twig.options' => array('cache' => __DIR__.'/../cache'),)); self::$appProvider['debug'] = true; } return self::$appProvider; } public static function invoke() { // example $silex = self::getSilext()->run(); } .... }
  4. Exactly, that's what I ment, actually it was just a comment on common practice. When you actually use multiple javascripts you don't want global variables, so it's prohibited to enclose your script inside an anonymous function. Let's say there's a global variable inside an external .js file and inside the DOM you redefine this.. what will happen is that you broke the script. So when you can, wrap it inside a anonymous function.
  5. Maybe you could manage it by output buffering?
  6. Or a SIAF (Self-invoking-anonymous-function) <script type="text/javascript"> (function() { $('.dateclass').each(function(index, value){ $(this).datepicker(); }); })(); </script>
  7. Neil is right, also I suggest to analyze this code snippet. The form must be on a seperate file, after this code you can put HTML to echo the $errorMsg or display a link to te file if it's succesfully uploaded. Description: Code: <? /* --- HTML CODE FOR UPLOAD FORM --- <form enctype="multipart/form-data" action="uploadHandler.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="number of bytes" /> <label for="fileInput">Label text</label><input name="fileInput" type="file" /><br /> <input type="submit" value="Upload" /> </form> */ // Max file size $maxSize = (number of bytes); $uploadRequired = true; // Declaring the variables for the upload directory and page. $uploadDir = null; $uploadPage = null; // Only php version 5.3.0 and bigger support '__DIR__'. if(version_compare(PHP_VERSION, '5.3.0', '>=')) { $uploadDir = (__DIR__.'/directory_to_be_uploaded_to/'); $uploadPage = (__DIR__.'/url_to_upload_page'); } else { $uploadDir = (dirname(__FILE__).'/directory_to_be_uploaded_to/'); $uploadPage = (dirname(__FILE__).'/url_to_upload_page'); } // Defining error messages define('ERR_SIZE', 'Error, file size limit exceeded.'); define('ERR_NO_SEL', 'Error, no file selected.'); define('ERR_PARTIAL', 'Error occured during the file upload.'); define('ERR_UNKNOWN', 'Unknown error occured during file upload, retry <a href=\'{ $uploadPage }\'>by clicking here.</a>'); define('ERR_MIME', 'Error, unallowed mime type of file, retry <a href=\'{ $uploadPage }\'>by clicking here.</a>'); define('ERR_REPL', 'Error occured during file translocation'); // Array containing allowed MIME types. $allowedTypes = array( 'image/jpeg', 'image/pjpeg', 'image/png', ..., ... ) // Error message: This variable($) will contain the error message. $errMsg = null; // This variable will contain the file information collected from the form. $fileInput = null; // Start the loop first, because we want to break it before we start uploading. // Loop keeps on repeating during upload. do { if(!isset ($_FILES['fileInput'])) { $errMsg = ERR_NO_SEL; break; // Break the loop, we don't want to go any further now.. } else { // Store the POST data from $_FILES['file_loaded'] into a variable. $fileInput = $_FILES['fileInput']; } // The index 'error' will return any error during upload. switch($fileInput['error']) { case UPLOAD_ERR_INI_SIZE: $errMsg = ERR_SIZE; break 2; case UPLOAD_ERR_PARTIAL: $errMsg = ERR_PARTIAL; break 2; case UPLOAD_ERR_NO_FILE: $errMsg = ERR_NO_SEL; break 2; case UPLOAD_ERR_FORM_SIZE: $errMsg = ERR_SIZE; break 2; case UPLOAD_ERR_OK: { if($fileInput['size'] > $maxSize) { $errMsg = ERR_SIZE; } break 2; } default: $err_msg = ERR_UNKNOWN; break 2; } // Check if file input has allowed mime type. if(isset(allowedTypes)) { if(!in_array($fileInput['type'], allowedTypes)) { $errMsg = ERR_MIME; break; } } } while(0); $randPrec = rand(0,255); $newFilename = $uploadDir.$randPrec.'_'.$fileInput['name']; if(!$errMsg) { if(!move_uploaded_file($fileInput['tmp_name'], $newFilename)) $errMsg = ERR_REPL; } ?>
×
×
  • 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.