Jump to content

cyberRobot

Moderators
  • Posts

    3,145
  • Joined

  • Last visited

  • Days Won

    37

Everything posted by cyberRobot

  1. Could you show the code for sidebar.php?
  2. Variable names are case sensitive. Try using $companyname The same goes for the other variables.
  3. The form action could be set to the same page. Then in the if test where the CAPTCHA is correct, you could use a header redirect to send valid submissions to sent.php. More information about the header redirect can be found here: http://php.net/manual/en/function.header.php
  4. $_SERVER['DOCUMENT_ROOT'] should already hold the information regarding your root folder. You should only need to modify what comes after the closing curly bracket. More information about the $_SERVER variable can be found here: http://php.net/manual/en/reserved.variables.server.php
  5. Side notes: Is there a reason you're using persistent connections? If you don't need them, you could just use mysql_connect(): http://us3.php.net/manual/en/function.mysql-connect.php Also note that the mysql_ function have been depreciated. It's time to start considering the alternatives: http://us3.php.net/manual/en/mysqlinfo.api.choosing.php
  6. If all the form fields are required, you could loop through the POST array. <?php foreach($_POST as $fieldName=>$fieldValue) { if($fieldValue == '') { print "<div>$fieldName is blank</div>"; } } ?> Side note: you'll also want to look into protecting your queries from SQL injections. One way is to use mysqli_real_escape_string(): http://php.net/manual/en/mysqli.real-escape-string.php
  7. If you want to use JavaScript, you could use PHP to populate a JavaScript array. Once PHP is done and the page is sent to the browser, JavaScript can then be used to reference the information. You could try the following search for some examples: https://www.google.com/search?q=populate+a+javascript+array+with+php Note that you could also look into using AJAX to grab information from the database.
  8. Try adding some code to make sure the database was selected. Example code can be found here: http://us3.php.net/manual/en/function.mysql-select-db.php
  9. Have you tried displaying the $row value in the while loop to see if it contains what you expect? You could use the same code as used in Reply 12. Of course, you would replace the $categories variable with $row.
  10. As I mentioned in Reply 9, it looks like you are overwriting the array. To avoid the new array from wiping out what's already in place, you could try something like this: while($row = mysql_fetch_assoc($result)) { if(!isset($categories[$row['sub_cat_id']])) { $categories[$row['sub_cat_id']] = array('name' => $row['sub_cat_name']); } $categories[$row['sub_cat_id']]['topics'][$row['sub_id']] = array('name' => $row['topic_title']); }
  11. Just add the line after the closing curly bracket of the while loop and before the foreach loop.
  12. Have you tried outputting the array to make sure it contains what you expect. You could try adding the following after your while loop which creates the $categories array. print '<pre>' . print_r($categories, true) . '</pre>';
  13. Overwriting $row shouldn't be the issue. The foreach loop isn't being executed in the while loop. Is the following line supposed to maintain all the topic titles? $categories[$row['sub_cat_id']]['topics'][$row['sub_id']] = array('name' => $row['topic_title']); If so, the issue is probably caused by the following line: $categories[$row['sub_cat_id']] = array('name' => $row['sub_cat_name']); Every time $row['sub_cat_id'] is the same, it overwrites the old value with the new array.
  14. You should also consider using the LIMIT clause so that MySQL doesn't keep looking through the database when a match is found. $query="SELECT `username` FROM `user` WHERE `username`='$username' LIMIT 1";
  15. The Google links provide examples on how to accomplish what you're asking. If you try it out and it doesn't work, feel free to post again with the updated code. Otherwise, perhaps someone else is willing to write the code for you. I honestly don't have the time. You could also consider posting something in the Freelancing forum. http://forums.phpfreaks.com/forum/20-php-freelancing/
  16. You can use CSS to change the color: https://www.google.com/search?q=html+input+value+color Of course, that will change the color of any text entered in the input filed. If you only want the placeholder text to be a certain color, you can change it dynamically with JavaScript: https://www.google.com/search?q=javascript+text+color+style
  17. I'm sure there's a better way, but you could try something like this: <?php $start = str_split($_POST['start']); foreach($start as $currKey=>$currLetter) { $start[$currKey] = "username LIKE '" . $currLetter . "%'"; } $result = mysql_query("SELECT * FROM $demo WHERE " . implode(' OR ', $start)); ?>
  18. That appears to be a feature of SQL and not MySQL.
  19. Perhaps the COUNT() function in MySQL will help: http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_count
  20. It would be easier to see what was going on if the code was indented properly. It looks like you're missing some closing-curly brackets. I would double check those.
  21. Which browser do you use? In Chrome and Firefox, you can right-click the "Showing all 2 results" text and click "Inspect element". This shows the source code for the text. From there you can see that the text is in a <p> tag with a class of "woocommerce-result-count". Just add some margin/padding to that class in your stylesheet.
  22. Your regular expression only tests if the name contains lower-case letters (a-z) and hyphens. Add "\s" for the name to include spaces. Your code also has the error message appear when the pattern is valid (aka: when you have a valid name). You'll want to add "!" (not) before the preg_match(): $pattern1 = '/^[a-z-\s]+$/'; if(!preg_match($pattern1, $memberName)) { echo "<p>Member name must contain only letters, space and hypen</p>"; } else { echo '<p>Good name!</p>'; } Also, note that you can make the regular expression case insensitive by adding an "i" after the pattern delimiter: $pattern1 = '/^[a-z-\s]+$/i';
  23. It looks like you already have the JavaScript in place. It could be modified as follows: <input type="text" name="keyword" id="sbi1" value="default value" onfocus="if(this.value=='default value') this.value='';"> You would just need to change both instances of "default value" to whatever you need the default value to be. To answer your other question, the input field can be widened with the "size" attribute. More information about the <input> tag and its attributes can be found here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input
  24. Moving to the Freelancing section.
  25. Which browser are you using to view the form? Note that the placeholder attribute doesn't work in older browsers like IE9. More information can be found here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input
×
×
  • 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.