Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. are you saying you want to automate making an array, like so? for ($x = 0; $x < 10; $x++) { $blah[] = $x; } // you now have an array called $blah // example to loop through array foreach ($blah as $val) { echo "$val <br />"; }
  2. Well I do admit that in the end we're just nickel and diming here
  3. True your method does preserve the file as a whole in case you need it I'll give you that one. Though, I can't really think of a situation off the top of my head where you'd actually need both. I mean, trying to parse one thing might be easier by the line, while trying to parse another might be better doing it as a whole, but you can accomplish any task from just one or the other, so in the end, having 2 copies of the same information loaded in memory is always gonna be harder on the computer than just executing another line of code.
  4. file breaks the file into an array line by line so you don't have to do the explode. The end result is the same it's just 1 less line of code.
  5. I edited my prev post I noticed that sorry.
  6. cooldude you explode everything into a giant array and then run a loop on each "word" and check if it matches $number and if it does it saves the array key for that giant array so your code will just return for example (in an array) "0 8 12 ..." jonsjava you also explode everything into a giant array and then run a loop on each "word" and check if it matches $number and if it does, it saves the array value from the position in that giant array so your code will just return for example (in an array) "00003 00003 00003 00003" -entropy: Assuming that the point of finding the line is to get the data on the line and separate it for use, here's my take: <?php $image = 'http://xx.x.xx.xx/######.png'; $server = 'http://xx.x.xx.xx/xxxxxxx.htm' $number = basename($image, ".png"); $list = file($server); foreach ($list as $key => $val) { if (stristr($val, $number)) { // accommodates if there's more than 1 row $row[] = explode($list[$key]); } // end if $number in $val } // end foreach $list edit: oops my bad both of you. For some reason I looked at \n as a space well anyways, you can skip the explode part by using file instead of file_get_contents
  7. pretty much the same way you do a login system, except have a field in your db called "level" or whatever, and only allow access to pages if level == "admin" or whatever. As far as adding/editing/deleting, basically all you need to do is first dump all the info you want out and associate it with a form. Make a button or link to specify deleting that row/account/whatever and check if it was clicked and delete where id == posted id or whatever. This tutorial shows how to do all that. All you really need to do from there is put your login and level check on top of that and you're good to go.
  8. Most people use "parse" and "execute" interchangeably (including myself, most of the time). But technically they are not the same thing. Parsing is a "phase" or "part" of the execution process. It is the act of breaking down the code into its blocks, expressions, etc.. so when you see a "parse" error, that means that during the part of execution when PHP is trying to parse the script, it runs into an error.
  9. well you only specified with numbers. If it could be anything just move the condition for / up and remove the elseif: $date = '19/07/2008'; $chars= str_split($date); foreach ($chars as $char) { if($char == '/') { echo '<img src="slash.jpg" />'; } else { echo '<img src="' . $char . '.jpg" />'; }
  10. No the problem is PHP is trying to parse your actual script and somewhere along the lines an unexpected thing happened that has to do with your actual syntax. Examples are missing quotes, extra quotes, missing or extra ;'s missing/extra opening or closing tags extra/missing opening/closing brackets. Extra/missing opening/closing ()'s or []'s or {}'s. Double typed or missing operands, commas, missing arguments for functions. Think of parse errors as the grammar police of PHP. There's something wrong with your code's grammar. Now these code chunks seem to work for all of us so there's got to be something specific to you that's doing it. That's why I mentioned your database data (because we don't have that). Or perhaps this file is being included in another file? It's got to be something specific to your situation that we can't duplicate.
  11. What he means is that here: your query string is assigned to $query but in your mysql_query you use $sql instead of $query. Okay well I ran the latest code block and still no parse error. I got several errors due to no db connection so I added that into it with a test table, and get a completely blank page (no errors). I assume my page is blank due to not having columns in my table called codename or max_columns. My next guess is...maybe you have some data in your vars that is somehow breaking your code, like quote marks?
  12. That's not code that's a sql dump.
  13. I don't really understand why you are getting that error either... I ran the codeblock on my test server and I do not get that error. I mean, I got lots of other errors because I don't have those files to include...maybe there is something in those included files that's breaking it? But you do say that your 2nd code block works just fine...so man, I really don't know...
  14. ...what? AFAIK phone browsers are the same as regular browsers, albeit a little bit stripped down. They request and render content same as any pc browser.
  15. How can that be your full code if the error says line 15 and you're saying line 15 is that $query = "..." which is line 3 in your code block?
  16. hey also you need ()'s after mysql_error $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR);
  17. We do not do people's homework nor do we write scripts for them. If you want to hire someone make a post in the freelance section. If you have an issue with your own script, make a thread asking about it, providing relevant code. Thread closed.
  18. Well you could for instance make a flatfile that holds your constants and just include the file in your script(s).
  19. Constants are like any other variables in that they are only defined for the currently executing script. They do not persist from page to page and they are unset when the script finishes executing. User B does not have access to user A's constants. User A does not have access to the defined constants of a previously requested script. If you want information to be accessible by several people, you need to store and retrieve the information in a database or flatfile. If you want information to persist from page to page for 1 user, you can use a database, flatfile, or use a session variable.
  20. google does not see your page unparsed. It sees what any user would see when accessing it from a browser.
  21. maybe if you were to make an activeX or java applet, but not with php or even js.
  22. Well here's one way... <?php // allowed extensions $allowed = array('.jpg','.gif','.bmp'); $ext = substr($ourfile, -4); if(!in_array($ext, $allowed)) { $error = "<font color=red>File type not allowed</font>"; } ?>
  23. we have stickies all over the forums including this one with book recommendations. thread closed.
  24. in a loop, run a query to select where data=$data if mysql_num_rows > 0 then it exists, skip insert. If not, run a query to insert.
×
×
  • 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.