Jump to content
Larry Ullman's Book Forums

Jonathon

Members
  • Posts

    1064
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Jonathon

  1. Well I did think about that but then started to think, in my mind that I couldn't see a problem with declaring a property in the abstract class. Something like private $side; But then didn't put those 2 ideas together into a form of an answer as I confused myself. Thought it was best to wait for a difinitve answer
  2. Yes you will need $sides again, but this is one of the underlying principles of more advanced OOP. The parent class is a framework for the sub class to take minimal information from and develop it's own set of methods for that particular shape. The $sides property can never be used by the Shape class and overwriting the Shape property each time you extend the class goes against the ideas of how OOP should be used.
  3. You can actually just export the file. If you go to the PHPMyAdmin and view the database you want to copy, there should be an export tab, click it and save the file to your desktop, then you can just copy all the SQL commands into the other hosts PHPMyAdmin under the SQL tab and dump all the data in like that. That's what I do.
  4. Well in that case it is the single quotes I just assumed it was because you're accessing an array rather than a string.
  5. Regular expressions? They are incredibly useful, but can be confusing to start with. You can use them in .htaccess files to make pretty urls and more importantly help validate types of input of varying types of complexities. Check out regexlib in Google, you'll where they're used. Things like validating telephone numbers, post codes and a lot more.
  6. It isn't the single quotes that causes the problem. The bottom is just a string, as long as you match the quotes properly it's all good. The top line is an associative array and can't be called as such. print "{$_POST['name']}" should work. print() doesn't need to take the parenthesis and to call an associative array inside a print or echo you need to wrap it in curly brackets. As far as I know
  7. There are several php.ini files in XAMPP, you need to find which php.ini is loaded, which is present on the phpinfo() call. Then you know which one to alter
  8. Thanks, I get that I need use post to submit the data, but do you need to use 'get'to check the validity of each form input?That's what I was confused on?I thought I would need to as yes I'm posting the data eventually but I need to check that each input is valid so assumed that I should use a 'get' for these?
  9. I'm just thinking of the logic behind a complete Ajax form validation. And wanted some advice, this will be pure JS and not JQuery. My concerns are 2 fold really, what's the most efficient way to write this code? For instance: This is the general code that I have seen used in Larry's books if (ajax) { if (document.getElementById('results_title')) { document.getElementById('individual-listing').onchange = function() { var title = document.getElementById('title').value; ajax.open('get', 'individual-listing-ajax.php?title=' + encodeURIComponent(title)); ajax.onreadystatechange = function() { handleResponse(ajax); } ajax.send(null); return false; }// End of anonymous function } // Emd of DOM check } // End of ajax if }// End of init() function function handleResponse(ajax) { if (ajax.readyState != 4) { var results = document.getElementById('results_title'); results.innerHTML = '<img src="images/spinner.gif" />'; results.style.display = 'inline'; } else { if ((ajax.status == 200) || (ajax.status == 304)) { var results = document.getElementById('results_title'); results.innerHTML = ajax.responseText; results.style.display = 'inline'; } else { document.getElementById('individual-listing').submit(); } } } This simply checks the input of a title field and returns a tick or cross to state whether the field has an acceptable value. But when you want to do this across multiple fields what is the most efficient way?? Using a for loop in the .js file? My problem is slightly different to Larry's because what I want to do is validate each field and place an image next to indicate its success rather than place all the errors into 1 <div> Secondly, the form at some point does need to be posted to a database, I was a little unsure of how to then make the form actually submit as I'm using the $_GET variable to check that the inputs are ok. The example I based this code on was just the browsing employees section of the Ajax book. Thanks in advance Jonathon
  10. mysql are the older functions MySql. Basically they have no 'i' and are slightly differently constructed
  11. This problem has been massively enlarged by not providing the correct information about your system. Very early on I asked you if you were using a live server aka your domain or a local server aka XAMPP. You said XAMPP.
  12. This is not a permeanet fix and I've never tried it either. I don't know if it will work, but maybe it will But try this at the start of the file <?php ini_set('mysqli.default_host', 1);
  13. At this stage I would start echoing out values to see what's being passed to the form. I sadly can't replicate your entire set up with DB (Well I could) but unfortunately I'm fairly busy today. But check all your conditionals, even the if(isset($_POST['submitted'])) so for instance: if (empty($_POST['first_name'])) { $errors[] = 'You forgot to enter your first name.'; } else { $fn = trim($_POST['first_name']); echo $fn; } Go through like this trying to find where the script fails. I did read over your file and it looked ok, but I'm doing it here minus a text editor, but I would imagine you're using one, so it would be able to pick up any parse errors.
  14. Sorry I posted a solution by mistake that was wrong, so had to delete it. So this post is void currently.
  15. I found this really useful the other day. Not so much for server side work, but for working with javascript/css/html. Check it out, you can paste portions of the said languages and save the 'fiddle' which will generate you a shortened url much like bit.ly does that directs people to your fiddle. This means that you can share the fiddle with others in a live like environment, others can then manipulate your code quickly and help you debug. I think that such a tool may become very useful to the people who frequent this forum especially when Larry's JavaScript book comes out.
  16. I think you need to look at this to adjust the path of you php.ini file config. Though I'm not actually sure how to implement it, perhaps somebody else may have more experience.
  17. I don't really know what to tell you, I can't see how it's saying that it's pulling in a php.ini file from a location that doesn't exist, at this stage I would think that it must be there, but you don't know where it is. What windows are you running. Have you tried taking the location C:\Parallels\Plesk\Additional\PleskPHP5\php.ini and putting it into the run command bar? If you run windows 7 you can just type it it in letter by letter and it will work through the folders to get to it.
  18. Remove the @ symbol from this $dbc and the mysqli_query($dbc, $q) line also your SQL query you've put $q = "INSERT INTO users (first_name, last_name, email, pass, reqistration_date) VALUES ('$fn', '$ln', '$e', SHA1('$p'), NOW() )"; have you spelt registration that way on purpose? Also, try running the query in the phpmyadmin console but replace the variables with dummy text and see if it executes. like: INSERT INTO users (first_name, last_name, email, pass, reqistration_date) VALUES ('Elvis', 'Presley', 'elvis@isntdead.com', SHA1('password'), NOW()) If it doesn't execute what errors does it return?
  19. <?php $link = mysql_connect('localhost', 'root', 'root'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_close($link); ?> you need to change that to $link = mysqli_connect('localhost', 'username', 'password', 'database_name'); if (!$link) { die('Could not connect: ' . mysqli_error()); } echo 'Connected successfully'; mysqli_close($link); That should connect you to the database using mysqli then try the query
  20. Are you actually submitting the HTML form to the the handle_form.php or just running handle_form.php straight away?
  21. Are you sure that it's where you say it is. Please check where it is configured. See the image.
×
×
  • Create New...