peipst9lker
-
Posts
81 -
Joined
-
Last visited
Never
Posts posted by peipst9lker
-
-
One last thing. In my form I have some <select> elements with many many options. In order to make the <select> fields to have the values before submission I have to put a small code snippet like this below in each option?
Yes you have, but I'd rather create option-tags via loop.
Another little tip for you, always put html-attributes in ""-quotes not single ones.
// somwhere on top of the script $options = array(1 => 'Cheeseburger', 2 => 'Hamburger', 3 => 'BigMac'); $selected = $_POST['selectname']; // inside your <select> foreach ($options as $val => $option) echo (isset($selected) && $val == $selected) ? '<option value="'.$val.'" selected="selected">'.$option.'</option>' : '<option value="'.$val.'" >'.$option.'</option>';
-
Place this 3 lines on top of your processor.php
You should see errors then. If not check your error.log of the webserver.
(Linux default Apache2 error.log: $ watch tail /var/log/apache2/error.log)
error_reporting(E_ALL | E_STRICT); ini_set('display_errors', 1); ini_set('html_errors', 1);
-
Usually an exported table is just 2 querys (CREATE IF NOT EXISTS and a huge INSERT INTO).
Read those into a string then split them e.g $createTable and $tableData then execute them.
Querys are sperated by a semicolon that should be enough to split the querys.
Notice that a query often has more then 1 line!
-
You should not use die() then
Maybe you can use try-catch blocks to catch error's and give them out to the user.
You have to always check are my data's correct, do my function calls return the right values etc.
-
Very very very basic example
<form action="example.php" method="POST"> <input type="text" name="example" value="<?php echo (isset($_POST['example'])) ? htmlentities($_POST['example']) : ''; ?>" /> </form>
-
Just some very basic stuff I quickly wrote down.
Imagine products are renting servers and stuff.
Table customers (id, name, email, locked, registration_date)
Table products (id, name, price, description, picture)
Table active_products (id, customer, productid, duration_date)
Table invoices (id, customer, productid, creation_date, due_date, paid)
Your cronjob will INSERT a new row INTO invoices FOREACH active_products WHERE duration_date > today.
In your application you SELECT invoices WHERE paid = 0 and customer = logged in user, and if there's any row -> tell the user.
Edit: Just to clearify, when a customer buys a server for 1 month you INSERT a row into active products with duration = date+30days or so
-
Echo the sent GET/POST variables (escape them to avoid XSS-vulnerabilities) into the value-attribute and you're done?
-
You'll need cronjob's or some other technique to create those monthly/weekly/whatever-ly invoices.
That cronjob should start a PHP script which creates your invoices (DB entries) - loads a template of a PDF fills some information in (there are thousands of PDF-librarys out there) and sends it via mail.
For what do you need a tutorial now?
-
As already indirectly pointed out, you can use a domain name to connect, it just maps across to an IP address. You can also put "localhost:3306" as the host as its the correct way to define a port on the end of a host. Have you eer considered how MySQLi does it behind the scenes? Just like that.
Thanks, I didn't know that, I just knew there is an extra parameter for it - so why not using it.
mysql_connect('remotesite.com:3306', 'user', 'password') or die(mysql_error());
It show "Connect failed: Unknown MySQL server host 'seovalley.com:3306' (1)" error.
Looks like the server can't resolve the domain - do you get any other error when you try the IP instead?
-
Do you mean some kind of div-overlay or a new small browser window?
For the overlay check out jQuery.ajax()
For the browser window this here might help
function popup (url) { var pop = window.open(url, "popup title", "width=400,height=300,resizable=yes"); pop.focus(); return false; }
-
That's weird - can you post the whole script?
If it's too big put in on a nopaste or something.
-
You can do it in 2 different ways
Way 1
Whenever a formfield looses focus you do an AJAX-request to some kind of validation.php (GET/POST parameter for the type and value of the field)
If u go that way I'd rather write ur own jQuery Extension for this (kinda easy)
Way 2
Use a client-side and a server-side validation. 1 Javascript which watches your fields and when the data is sent your PHP script checks everything again (incase someone just turns off JavaScript or modifies the request)
-
I guess a Firewall or something is blocking the connection there. Do you have (shell-)access to both servers ?
Also, have you checked the connection-resource for any error's ? (when using mysqli)
var_dump($connection);
-
If you're using jQuery.ajax() you can use beforeSend, success and error options.
$.ajax({ url: "target.php", beforeSend: function () { // show "Please wait"-popup }, success: function (a) { /* ... */ }, error: function () { /* ... */} })
-
jQuery FTW!
var foo = { name: 'sparta' }; $(document).live('click', function(){ alert('THIS. IS. ' + foo.name); });
-
Yes, break is the right way to stop a loop.
The function will return the index of the letter in your querty array - I don't know if that's what you want
But array_search does the exact same thing, consider using that one!
-
You should use the IP instead of domain (To get the IP of a domain simply ping it)
Have you tried Mysqli instead of standart mysql class?
Edit: The Port would be another parameter, dont put it behind the IP.
Edit2: Here is a small example of Mysqli (replace the $db-vars with your's!)
$connection = @new mysqli($db->host, $db->user, $db->pass, $db->name, $db->port, $db->socket);
-
Use substr to only get the first character.
function get_first_letter($this_word) { return substr($this_word, 0, 1); }
-
Which line is 48?
-
Donald you still need to use mysql_fetch_assoc() in this case.
-
$str = 'Name-of-the-tshirt-A123456789'; preg_match('/-A([0-9]+)$/', $str, $match); echo $match[1]; // match[1] will now hold your ID, in this case 123456789
-
You need to provide an identifier in catch-blocks e.g
try { $this->hooksFired++; call_user_func(array($this->$hook, $method)); } catch (Exception $e) { // error handling code }
-
Have u looked over your database with PHPMyAdmin or something like that - are there really entries in the database?
If yes place this line above your first echo (inside the while)
var_dump($row);
Execute the script and check the output.
-
Thanks for your reply xyph, benchmark results (using microtime() to get the exact time differences):
5000x Parsing xml-file: 1.3933548927307 5000x Unserializing cache-file: 0.56393098831177
Parsing serialized data is a lot quicker then parsing XML data, so parsing it once and saving serialized data once is totally worth it
Of course u can only do it when the XML-file is always the same (which is, in my case).
Pagination with search results
in PHP Coding Help
Posted
I can recommend DataTables.
It's an jQuery extension which automatically provides pagination, livesearch box and tons of more features (highly configurable and extendable)
You should take a look at it