Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. You might want to define 'not working'. What happens? What doesn't happen? In any case, you should be quoting those strings being uses as array indexes (e.g. $selaps['aps']). An unquoted string is a constant. Though php guesses that you meant to use a string if the constant is undefined, it may cause you problems depending on your error_reporting level. And it's bad practice.
  2. There is a difference, though in this case either works. Including a file is (almost) identical to having the contents of that file in the one that did the including. Using file_get_contents returns a string with the file contents in it. So, if you wanted to run some code in another php file, you'd want to include it. If you wanted to look through the code and find out if a variable was in it, for example, you'd need to use file_get_contents.
  3. No doubt $name and $match[1] are strings - as such you need quotes around them: $st = "SELECT * FROM aps WHERE name = '$name'"; In future, you should try debugging your queries. Do something like this: $sql = "SELECT * FROM..." $result = mysql_query($sql) or trigger_error(mysql_error().'<br />Query: '.$sql,E_USER_ERROR); That way you'll actually be able to find out what went wrong.
  4. You mean like you see on the phpfreaks homepage? Try using substr_replace
  5. If you need to grab some data from the page before you can submit it, then it's obviously going to take two requests. It's not possible with one. How does this work if you do it manually? I think we might need more information.
  6. As far as i can see $_SESSION['user'] isn't set. You're using this as the value for a hidden field, so that'll be blank. Incidentally, why are you putting session variables in hidden fields? That's just asking for the user to manipulate them. If they're in sessions, you can access them on the next page anyway.
  7. In any case, it's perfectly valid to use an apostrophe after a character/symbol if is clarifies meaning. For example, if i were to be talking about the letter a (and, in particular, if there was some reason why i should only be using lowercase) and i want to talk about lots of them, it would almost certainly be better to use "a's" than "as".
  8. Not asking a question isn't usually conducive to receiving an answer...
  9. That's assuming those values are in seconds - i.e unix timestamps. Otherwise you'll need to convert. Where does the data come from?
  10. That's called a variable variable. That is, the variable that you are using is itself variable. In this case, the OP is using it to extract all of the data from the $_POST array - indeed, the code is equivalent to extract($_POST); As for the original question - could we see some actual code? There's no reason why that shouldn't be working, so perhaps there's something else amiss.
  11. I'm not entirely sure what you mean. Are you asking to how to select data from multiple tables? If so, you need to learn about joins. I'd start with this excellent tutorial: http://www.phpfreaks.com/tutorial/data-joins-unions
  12. Assuming you're still working with your data like this: Array ( [8] => Array ( [mildsteel] => Array ( [qty] => 1 [size] => 4.5 ) [stainless] => Array ( [qty] => 1 [size] => 4.5 ) ) ) The following should work for you: <?php foreach($array as $id => $materials){ foreach($materials as $material => $details){ echo "ID: $id Material: $material "; foreach($details as $detail => $value){ echo "$detail: $value"; } echo '<br />'; } } ?>
  13. Sounds like you're after a multidimensional array. In essence, each element of the array is an array itself. Consider something like this: $array[0] = array('foo','bar'); $array[1] = array('blah'); $array[2] = array(array(1,2,3),4,5); echo '<pre>.print_r($array,1).'</pre>'; As you'll see by the last element, there's no reason why we're limited to 2 dimensions
  14. Ok, so what actually happens when you increase the length of the variable? Do you get an error? Have you tried checking the value of curl_error? Can you make requests with data this long manually?
  15. I'm first going to assume that this line: echo $user['name']; Was supposed to be: echo $name['name']; Since $name is the row. In any case, this wont work, owing to variable scope - if you google that, you'll find plenty of material. In short, the variable $name is not available inside the function unless it's global (bad) or you pass it as a parameter, like so: <?php $name_q = mysql_query("SELECT * FROM users where name = 'Andrew'") or die(mysql_error); $name = mysql_fetch_array($name_q); function test($row) { echo $row['name']; } test($name); ?>
  16. I suggest you try posting your actual code. It's a bit difficult to help you otherwise.
  17. I wrote a tutorial on doing this kind of thing: http://www.phpfreaks.com/tutorial/working-with-checkboxes-and-a-database See if you can follow that. It shouldn't be too hard to apply it to your situation.
  18. Indeed. Store it in a DATE field. And yeah, just implode it.
  19. Erm, if you want to match a specific number, you dont need like: $var = 23; $result = mysql_query("SELECT * FROM pointzone WHERE range = $var") or trigger_error(mysql_error(),E_USER_ERROR);
  20. You want to run all the code through htmlentities
  21. That's a pretty inefficient way of doing it. You'd be far better off sticking them in an array and imploding them. That way you can do it with just one insert statement: $emails = file("sql.txt"); $emails = implode("','",$emails); $sql = "INSERT INTO emails (addy) VALUES '$emails'"; mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); Edit: You ought to check for any injection attempts though: $emails = file("sql.txt"); array_walk($emails,'mysql_real_escape_string'); $emails = implode("','",$emails); $sql = "INSERT INTO emails (addy) VALUES '$emails'"; mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR);
  22. I've a feeling i used that in the past and it had some problems with it not actually behaving as IE did. I can't remember if it was to do with some ajax or stylesheets though. So yeah, that was a little vague
  23. You do it'd take the average user until, roughly, the second coming to upload a 2gb file, right?
  24. i'm not that newbie . Well why did you link to it then? lol. Anywho, i'm confused. Bogus.image obviously isn't a png image. So surely the script is performing correctly?
  25. Well that depends. Do you want there to be duplicates as long as they're not happening just because someone's refreshed the page? If not, you should check to see if the value exists in the database before trying to insert it. If you do allow duplicates, you could set a session variable when the form's successfully submitted and check the value of this variable prior to inserting a new row.
×
×
  • 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.