Jump to content

Adam

Moderators
  • Posts

    5,717
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Adam

  1. Prior to PHP5, passing by reference meant the referenced variable would contain the actual object. Now however only a reference kind of ID to the object is stored within the variable. Returning that by reference would mean a reference to a reference, which basically dereferences to the same thing (..and is why PHP has made it deprecated). So yes, you can remove the ampersands without any worry.
  2. Adam

    PHP Random

    What do you mean by tolerant exactly? Between 1000s of options rand() will server it's purpose, however the result is not truly random. Really no computer can generate a random number based on mathematical formulas. Unless you have some legal obligation to prove you're generating a 100% organic random number though, rand() should be adequate for you.
  3. That won't work here given that the "c_id" field isn't an auto incremented field.
  4. I don't think he does? Granted, but it's better to make the function reusable and pass in the argument.
  5. Your logic's just a little mixed up. You validate the email address format, the passwords match, and then that the email address isn't taken here: <?php if(isset($_POST['send']) && (!validateEmail($_POST['email']) || !validatePasswords($_POST['pass1'], $_POST['pass2']) || !validateRegister())): ?> At which point only if there's a problem do you proceed to validate the captcha in the next series of validation calls: <?php if(!validateEmail($_POST['email'])): ?> <li><strong>E-mail invalid:</strong> Introduceti o adresa de email valida.</li> <?php endif ?> <?php if(!validatePasswords($_POST['pass1'], $_POST['pass2'])): ?> <li><strong>Parole invalide:</strong> Parolele nu se potrivesc sau sunt mai mici de 5 caractere!</li> <?php endif ?> <?php if(!validateCaptcha($_POST['code'])): ?> <li><strong>Cod invalid:</strong> Cod invalid.</li> <?php endif ?> <?php if(!validateRegister()): ?> <li><strong>Exista:</strong> exista.</li> <?php endif ?> You could add the validateCaptcha() call to the first if condition, but personally I'd restructure the code to be more like: if (isset($_POST['send'])) { // perform validation here, if there's // a problem store the $error message } // check if there was a validation error if (!empty($error)) { // register user } else { // display form } Seems like a much cleaner structure.
  6. You just need: echo $xml->channel->item[0]->title;
  7. You need to escape double quotes used within a string delimited by double quotes, however it's easier to use single quotes to delimit the string when working with HTML: echo '<td align="center"><a href="#" onmouseover="alert(\'' . $customer . ' <br /> ' . $address . '\');return false">' . $customer . '</a></td>';
  8. Adam

    Storing Tags

    No problem. You could even increase performance by adding a unique constraint across the two fields, which will also prevent duplication. Something like: create table tags ( article mediumint unsigned, -- use same data type as ID column in articles table tag varchar(20) not null, unique(article, tag));
  9. Adam

    Storing Tags

    Storing the tags within 1 column will prevent (or at least impede) you performing any 'intelligent' queries on them. Consider how you'd return the most popular tag if they're all strung together? Or even selecting articles matching that tag? You should store each tag within a separate row, linked to the article by the ID. Don't worry about using plenty of rows, MySQL is more than capable of handling it.
  10. I was asking for the structure as it makes things quicker / easier. Tend to end up going round in circles asking questions trying to understand how the data is structured. As you've tried Where screen IS NOT NULL, there must be a value within the screen column; NULL does not equal an empty string. I'm guessing there could be a default value assigned to the filed, or during your 'insert' process you're passing an empty string. You can't use char_length() within the 'where' condition of your statement.
  11. From what I can tell, the jQuery datepicker widget doesn't have an option that'll let you do this.
  12. Hard to say without knowing the structure of the two tables.. However storing the value 'colorset_1' in a column called `colorset` seems a little pointless to me. Why not just store 1 (as an integer) and use that as the colorset ID within the colorsets table? You'll most likely need to modify it a little, but this should point you in the right direction: select items.*, colorsets.value from itemsjoin colorsets on (items.colorset = colorsets.id)where items.id = '3R1';
  13. Adam

    ajax help

    From your own code: // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ document.myForm_away.time.value = ajaxRequest.responseText; } } That will attempt to store the response within the 'time' input of your 'myForm_away' form.
  14. jQuery UI has a great 'droppable' component for this kind of thing.
  15. Well it looks to me like you're trying to get the object before it's even been created. Try this: var boxHeight;function getHeight(){ boxHeight += 90; return boxHeight = boxHeight + "px"; }$(document).ready(function(){ boxheight = $('content-area').height(); if (boxheight > 200){ $.fn.colorbox({inline:'true', href:'#content-area',width:'700px', height: getHeight() }); }});
  16. There doesn't appear to be a problem with the rewrite rule, but you're using relative paths to your external JavaScripts and stylesheets. For example: <link href="style.css" rel="stylesheet" type="text/css" /> The browser will try to find the stylesheet relative from the current URL, effectively "play/200/style.css". You need to use an 'absolute' path that doesn't need to change in any directory... For example: <link href="/style.css" rel="stylesheet" type="text/css" /> That will look for "style.css" within the document root.
  17. Actually just to add to that.. if you specify a value for the image input then "login" would be passed too.
  18. It means you've used all the computer's memory available to PHP. Are you working with large amounts of data?
  19. Your code should work, given that just $_GET['child'] in the IF expression will check if it's true/1. Try adding some debugging: elseif (isset($_GET['forum']) && $_GET['child']) { exit('foo'); include 'modules/pages/children.php'; } If you don't see "foo" then you know the problem is with your logic. A possible problem could be if you have just isset($_GET['forum']) in a previous expression, then obviously this else-if expression won't ever get evaluated.
  20. You can use the modulus operator: if (3 % 4 == 0) { // 3 is a multiple of 4 }
  21. Whoops, missed off your where clause: SELECT c.* FROM charis_admin_module_content c JOIN charis_admin_module_allocation a ON (c.id = a.id) WHERE a.id_page_name = '$current_page_name' OR a.id_page_name = 'ALL' ORDER BY a.sort_order; That was a little syntax error too.
  22. I'm not actually sure why you're using a sub-query here. This can be done using a faster join, and without the need for the duplicate 'title' column: SELECT c.* FROM charis_admin_module_content c JOIN charis_admin_module_allocation a ON (c.id = a.id); ORDER BY a.sort_order; Not tested that but it should work. You can remove the `id_module_title` column from the content table now. Also I'd suggest removing the auto increment from the content table's ID column, in-case the data ever gets out of sync or you wish to change the ID to a specific value.
  23. Why are you using a sub-query to select the field..? Also I find it more readble to break up and indent the query, and also assign aliases: SELECT DISTINCT * FROM charis_admin_module_content c WHERE c.title IN ( SELECT a.id_module_title FROM charis_admin_module_allocation a WHERE a.id_page_name = '$current_page_name' OR a.id_page_name = 'ALL' ORDER BY a.sort_order ASC )
  24. Joomla and Zend are completely different. Zend is a PHP framework, meaning you still write applications in PHP but using the framework. Joomla is basically a CMS (content management system) used to administrate websites, where there's little - if any - PHP knowledge required. They're aimed at completely different end-users. CakePHP and Zend are both frameworks, but fundamentally different.
×
×
  • 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.