Jump to content


Staff Alumni
  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by jcbones

  1. So, $start1, $start2, $start3 has nothing to do with posting the form, it is only database call? Yet, you are using that to determine the state of the button? So, you should either. 1. Check the form submission to set the button. OR, 2. Move the include for safe.php BELOW your updates, so that you pull the info AFTER you update it. (currently you update the info after you pull it).
  2. Where do you create the variables. $start, $start2, $start3?
  3. Questions should be clear and concise, leaving 0 margin for doubt. The reason you are getting no response is: No One Knows What You Are Talking About! 1. Brief statement of what you are desiring to do. 2. Any code that is relative to the problem. 3. How the output is different than what is desired. Follow those steps, and you will get replies.
  4. You include connect.php in your poll.php file with a relative file path. This will work if you are accessing poll.php itself, but will not work if poll.php is included in another file, as that file will do the include. So, PHP is looking in the pages/ folder for the file connect.php. You should put an absolute file path to the connect file. require_once ('absolute/path/to/connect.php'); This is the exact reason that so many of us stress that you must use absolute file paths to every included file.
  5. So you want to allow 1 space, but no more? The above code given will remove ALL spaces. 1 space but no more is: preg_replace('~\s\s+~','',$username);
  6. If he hasn't opened a connection, then his query wouldn't work. So the fix is to open a connection.
  7. That is correct. What do you mean by "not working"?
  8. Sorry, it is hard to part sarcasm into a post.
  9. delimiter being talked about is the semi-colon after your variable. And, you are echo'ing it, but judging from your post, you are wanting to know how to remember it's checked state. 1. A checkbox is either on or off. 2. You shouldn't use short tags, as it is being removed, and is not very portable. 3. You need to use the POST array to set the checked value. 4. You need to know which checkbox you are inquiring about, so use indexes. Example <input name="status[1]" id="pending" value="Shouldn't be a POST variable" <?php if(isset($_POST['status'][1])) echo 'checked'; ?> />
  10. Did you echo the type out, and see what it was? I know that IE sents png's as x-png and jpeg's as pjpeg. If I were you, I would echo out the file types (in all browsers) to make sure I covered them all.
  11. Replace mysql_clean() with mysql_real_escape_string().
  12. Yep, both split() and explode() did the same thing, so they dropped split(), same for join() and implode().
  13. The header() function cannot be used after output has been sent to browser. This includes any HTML outside of PHP, and whitespace outside of PHP, or any echo, print, print_r, etc. (any function or construct that outputs to the page, including errors, notices, etc.).
  14. Your query is failing, this should tell you why. <?php error_reporting(-1); ini_set('display_errors',1); $link = mysql_connect('localhost', 'root', ''); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully<br />'; $arr = array(); $rs = "SELECT `id`, `title`, `author`, `date`, `imageUrl`, `text` FROM `items`"; $rs_return = mysql_query($rs) or trigger_error($rs . ' has encountered an error: <br />' . mysql_error()); while($obj = mysql_fetch_array($rs_return)) { $arr[0] = $obj['id']; $arr[1] = $obj['title']; $arr[2] = $obj['author']; $arr[3] = $obj['date']; $arr[4] = $obj['imageUrl']; $arr[5] = $obj['text']; } //numbering the array indexes, will only return 5 array indexes EVER. All indexes will be over written on each loop. echo '{"items":'.json_encode($arr).'}'; ?>
  15. I don't "see" anything that would cause an error, unless the data you are pulling has an illegal character in it. You will have to use some de-bugging tools (echo mainly) to find it. Or look at the page source.
  16. Un-Tested: <?php error_reporting(-1); ini_set('display_errors',1); include('mysql_connection_info.php'); if(isset($_POST['submit'])) { $state = mysql_real_escape_string(trim($_POST['state'])); $county = mysql_real_escape_string(trim($_POST['county'])); foreach($_POST['city'] as $value) { if(empty($value)) { continue; } $city = mysql_real_escape_string($value); $parts[] = "('$state','$county','$city')"; } if(is_array($parts)) { $sql = "INSERT INTO locations (state,county,city) VALUES " . implode(',',$parts); if(mysql_query($sql)) { echo 'Successful<br />'; } else { echo $sql . ' has encountered an error: <br /> ' . mysql_error(); } } else { echo 'You must submit at least one city.'; } ?> <form action="" method="post"> <input type="text" name="state" id="state" placeholder="State" /><br /> <input type="text" name="county" id="county" placeholder="County" /><br /> <?php for($i = 0; $i < 5; $i++) { echo '<input type="text" name="city[]" id="city' . $i . '" placeholder="City" /><br />'; } ?> <input type="submit" name="submit" value="Submit" /> </form> Table structure CREATE TABLE IF NOT EXISTS `locations` ( `id` int(11) NOT NULL AUTO_INCREMENT, `state` varchar(100) NOT NULL, `county` varchar(100) NOT NULL, `city` varchar(100) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM ;
  17. What are you looking for in the string? This function will have to be changed from a POSIX pattern to a PRCE pattern.
  18. Reading comprehension is required to understand the manual.
  19. http://www.php.net/manual-lookup.php?pattern=mysqli_stmt_close&lang=en&scope=404quickref
  20. There is absolutely no reason to use globals. Using a standard variable, and passing arguments to functions is how it should be done. Passing a global to a function defeats the purpose of using a function, as you have just tied a specific variable to a function. Dropping that function into another script, will cause headaches, or a function re-write. All other super-global arrays are available in functions anyway ($_POST,$_GET,$_REQUEST), but due to the reasons stated above, shouldn't be used in functions. *hope I didn't mis-understand the question*.
  21. I am astonished there is not one mention of programmers notepad. While not my favorite editor, it offers things that notepad++ doesn't, and allows for quite a bit of customization. http://www.pnotepad.org/
  22. There is nothing inside of your div that you are hiding. So it will not show either way, as you cannot see an empty div (unless it has a border).
  23. Most Mobile phone providers will let you send sms through email, which can be accomplished with PHP using the mail() function. Take a look here Other than that, you will need a SMS gateway, which usually charges per message sent. These also require you to jump a few hoops to user their service, including un-subscribe links in every message <- and it must work.
  • 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.