Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. I really don't see your point. People shouldn't be forced to limit their posts, that's like limiting knowledge. No one is forcing you to read anything.
  2. For debugging you should place error_reporting(E_ALL); at the top of your scripts. Glancing at the query it appears that you're missing the closing " for description=" $sql = 'UPDATE schedule SET subject="' . $_POST['subject'] . '", date=' . $_POST['date'] . ', location="' . $_POST['location'] . '", description="' . $_POST['description'] . '" WHERE id=' . $_GET['id'];
  3. I don't see what's wrong with long posts. If that's what needs to be done to get the point across so be it; sure some people may not completely read long posts but that's their loss then. I can only see this having negative effects because as you mentioned, it would "reduce the amount of intelligence in a post".
  4. I think you're meaning to do: if($accesslevel['accesslevel']=='2')
  5. You can create a loop and utilize the second to last parameter of file_get_contents() (and the last parameter if you know that the name will be within ~X characters) to only grab a specific part of the file.. Ex: for($i = 0, $position = 0;$i < count($accepted);$i++) { $content = file_get_contents('somefile.txt', 0, null, $position); preg_match('...', $accepted[$i], $matches, PREG_OFFSET_CAPTURE); $position = $matches[1][1] + strlen($matches[1][0]); } Where $matches[1][1] would be the starting position of the match.
  6. Going it over it kind of fast I could only name ~20.
  7. The issue(s) is with this query: $query = "INSERT INTO subjects ( menu_name, position, visible ) VALUES ( '{$menu_name}', {$position}, {$visible} }"; Because you're not using arrays with string-based indexes (or anything involving objects) there's no need to use curly braces (It's not illegal, but it's not a good habit do unnecessary things). You're also trying to close the VALUES ( with }. Finally if position and visible aren't of some type of int field they should have quotes (but I'll leave them out since I'm not sure) $query = "INSERT INTO subjects ( menu_name, position, visible ) VALUES ( '$menu_name', $position, $visible )";
  8. As your code only loads the same image over and over.. it makes little sense! Lmao, I didn't even realize that.. I should actually take 5 seconds and look at the code. But yea, you're not going to want to use readfile().. If you're trying to output an image using that (assuming you have the right Content-type header set) only the first image output will actually be displayed. I'm not completely sure, but I'm assuming this is what you want. <?php // Connect to DB require_once('include/configure.php'); // Connect to the server $db->connect(); // Root Dir. $fulldir = "/root/d74156a/home/docs/files/"; $ext = strtolower(substr(strrchr($file_name,'.'),1)); // Below are just mime type settings. I deleted it because it isn't revelant to what I'm going to ask you. $result = mysql_query("SELECT * FROM allfiles"); // Loop through the files while($row = mysql_fetch_array($result)) { // This checks if the file name's are all images. If they are not images, cancel out the non-image file to prevent it from being displayed. if(ereg("(.*)\.(jpg|bmp|jpeg|png|gif)", $row['file_name'])) { $file_name = $fulldir.$row['file_name']; echo "<img src='$file_name' alt='' />"; } } ?> Notice that defining of $file_name is within the loop, this is because it needs to be altered with every iteration.
  9. <hr>s? How is that even possible.. Is there other code that you're not showing us, and are you sure that $file_name contains the data you're expecting?
  10. So you want to show all images returned? readfile() won't be the way to go then. readfile() puts the data directly to the output buffer, so you can't output multiple files images. In your case I think you want to do something like this: <?php // Connect to DB require_once('include/configure.php'); // Connect to the server $db->connect(); // Root Dir. $fulldir = "/root/d74156a/home/docs/files/"; $file_name = $fulldir.$row['file_name']; $ext = strtolower(substr(strrchr($file_name,'.'),1)); // Below are just mime type settings. I deleted it because it isn't revelant to what I'm going to ask you. $result = mysql_query("SELECT * FROM allfiles"); // Loop through the files while($row = mysql_fetch_array($result)) { // This checks if the file name's are all images. If they are not images, cancel out the non-image file to prevent it from being displayed. if(ereg("(.*)\.(jpg|bmp|jpeg|png|gif)", $file_name)) { echo "<img src='$file_name' alt='' />"; } } ?> It's also not a good idea to use ereg because it's depreciated and removed as of PHP6, a better alternative would be preg_match().
  11. That's interesting, I read about forking processes in PHP to replicate threading a while ago, but there didn't seem to be a whole lot of material on it. I'm gonna have to mess around with that
  12. I wrote this while you were writing your solution... Maybe it'll help, if you need an explanation just ask. <script type="text/javascript"> var qnum = 0; var anum = 0; var questions = new Array('Question 1', 'Question 2', 'Question 3'); var answers = new Array('Answer 1', 'Answer 2', 'Answer 3'); function nextStep() { if(anum == answers.length) qnum = anum = 0; if(qnum == anum) { document.getElementById("question").innerHTML = questions[qnum++]; document.getElementById("answer").innerHTML = '???'; document.getElementById("next").value = 'Next Answer'; } else { document.getElementById("answer").innerHTML = answers[anum++]; document.getElementById("next").value = 'Next Question'; } } </script> <div> Question: <span id="question"></span><br /> Answer: <span id="answer"></span><br /> <input type="submit" value="First Question!" id="next" name="next" onclick="nextStep();" /> </div>
  13. Typically I would go with C++ and make it multi-threaded, but in this case the amount of information being sent and received will be very limited. I can't imagine that it would be more than .5KB at a time. I was just worried about the processing speed of PHP. Thanks for shedding some light on this, it's really appreciated
  14. Seems like it, preform print_r() on $matches to see what it contains.
  15. Yes, that's the correct way to call a parents constructor.
  16. Np, just remember to mark the topic as solved, there's a button at the bottom left to do this.
  17. There are no quotes around the limit. I also suggest you at least preform mysql_real_escape_string() on that variable before passing it directly into the query. $Var = mysql_real_escape_string($_POST['limit']); $query_users = mysql_query("SELECT * FROM test LIMIT $Var") or die(mysql_error()); It's also a bad idea to develop code on a live environment..
  18. I don't see anything immediately wrong with it (Besides the fact that you have * around your table sub-query? Or did you just put that there for the post?); why don't you try it?
  19. I'm not quite sure about that, perhaps you're referring to the fact that in PHP6 to access specific characters in strings you'll have to use [ ] vs { }.
  20. When using arrays in strings who's indexes are also surrounded by quotes you must use curly braces ({ }) to tell PHP where the variable starts and ends. $fp = fwrite($myfile,date("Y/m/d").",{$_SERVER["REMOTE_ADDR"]},$_POST[r1],$_POST[r2],$_POST[r3] "); In the future you should use [code] or [php] tags, it makes things easier to read.
  21. Well isn't the problem clear then? It's exactly what the error message says, within the MySQLDB class there is no method named 'emailTaken'.
  22. Because PHP, being an interpreted language, will always be slower than a compiled language such as C++ or C#, I'm wondering what's a bigger factor in determining how many connections a server can handle: The Speed of the language (Interpreted vs. Compiled) or the processing power of the computer and the ability of the internet connection of the server. In short, is it feasible to make a socket server using PHP CLI that can maintain a large amount of connections, or would it be more practical to go with a compiled language?
×
×
  • 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.