Jump to content

Eiseth

Members
  • Posts

    58
  • Joined

  • Last visited

Everything posted by Eiseth

  1. Try using is_array() to check whether the next element is an array foreach ($name_array as $arr) { // only arrays will process if (is_array($arr)) { $arrays = $arr; } } print_r($arrays); // array([0]=>'cat')
  2. Do you have any good file structure tutorials I suck at organizing my files
  3. Use function function get_value($var) { return (isset($_SESSION[$var]) && !empty($_SESSION[$var])) ? $_SESION[$var] : $_POST[$var]; } // then on your html <td><input name="windows" style="background-color:#FFFFCC;width:60px;" maxlength="10" value="<?php echo get_value('windows'); ?>"type="text"> <td><input name="other_input" style="background-color:#FFFFCC;width:60px;" maxlength="10" value="<?php echo get_value('other_input'); ?>"type="text"> <td><input name="another_one" style="background-color:#FFFFCC;width:60px;" maxlength="10" value="<?php echo get_value('another_one'); ?>"type="text">
  4. Try laravel (http://lorib.me/2013/03/04/laravel-learning-resources/) or learn MVC and design patterns and create your own mini framework
  5. Is F3 (https://github.com/bcosca/fatfree#readme ) good? Any feedbacks? thanks
  6. Why not upload your application on some free hosting sites? I believe you need to do some port forwarding to be able to access your localhost by other networks
  7. Hi, If you're learning try PDO instead of mysql_* extension, mysql_* extension was already deprecated http://php.net/manual/en/book.pdo.php Using PDO, it is much easy to insert row on your database // Create instance of PDO so you can perform your query (e.g. insert rows, fetch datas, etc.) try { $dbh = new PDO('mysql:host=yourhostname;dbname=yourdbname;charset=utf8', 'yourdbusername', 'yourdbpassword'); } catch (PDOException $e) { // Catch errors, such as invalid username/password/dbname/hostname/etc... // you can do what you want here with the errors, I just use die for simplicity die('Cannot connect to database: ' . $e->getMessage()); } // If successfull, we can now perform query // Names starting with ":" are just placeholders // Using the query method, PDO will sanitize input before it store the datas in the database to prevent SQL injection $query = 'INSERT INTO ho_add_stock_proforma (supplier, inv_no, day, month, year, product_name, descrpt, qty, cost, hawker, wholesale, retail, total) VALUES (:supplier, :inv_no, :day, :month, :year, :product_name, :descrpt, :qty, :cost, :hawker, :wholesale, :retail, :total)'; // Perform the query inside the try & catch so we can handle if there's an error on our code try { $stmt = $dbh->prepare($query); // We can now bind the value in our query $stmt->execute(array( ':supplier' => $_POST['supplier'], ':inv_no' => $_POST['inv_no'], ':day' => $_POST['day'], // insert your other $_POST data... )); } catch (PDOException $e) { // Again, we need to catch if there's an error on our query die('Cannot perform the query: ' . $e->getMessage()); } // If successful, perform your other code...
  8. Are you sure you save it as .htaccess? If you're working on localhost, make sure your apache is rewritable I have similar problem before http://phpcollection.com/mod-rewrite-windows-wamp-xampp/ - windows http://blog.valugi.ro/2008/05/29/htaccess_internal_server_error_apache2_ubuntu/ - ubuntu Or if you want an easy solution, try putting each pages into folder and rename the files to index.php For example the about.php page will be about/index.php, so whenever you link to about page it will load the page without the "index.php"
×
×
  • 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.