Jump to content

markjoe

Members
  • Posts

    226
  • Joined

  • Last visited

    Never

Everything posted by markjoe

  1. while ($row = mysql_fetch_array($sql) { and while ($row = mysql_fetch_array($sql)) { are very different! My posted code was incorrect, I missed the fact that the query execution was missing. <?php $sql = 'SELECT * FROM `forums` LIMIT 0, 30 '; $sqlresult = mysql_query($sql); while ($row = mysql_fetch_assoc($sqlresult)) { echo 'Forum 1: '. $row['forum_name'] .'<br><br>'. $row['forum_desc'] .'<br><br>'; } ?>
  2. Well, first of all, what happens? Any error output? <?php $sql = 'SELECT * FROM `forums` LIMIT 0, 30 '; while ($row = mysql_fetch_assoc($sql)) { echo 'Forum 1: '. $row['forum_name'] .'<br><br>'. $row['forum_desc'] .'<br><br>'; } ?> mysql_fetch_assoc() VS. mysql_fetch_array() should not make a difference, I am just used to the former. -The closing ) of the while is missing. -Here is a quote form php.net regarding echo: hmm, 3 new replies already, oh well, have mine too. oh nice, I missed the lack of query execution...
  3. In PHP5 <?php $dirs=0; $x="."; $y=scandir($x); foreach($y as $z){ if(is_dir($z)){ $dirs++; } } echo "There are <b>$dirs</b> in directory $x"; ?>
  4. if($ref == "http://www.sitename.com/post1.php" || $ref == "http://www.sitename.com/post2.php"){ //enter page }else{ echo "Invalid Request"; } if($ref != "http://www.sitename.com/post1.php" && $ref != "http://www.sitename.com/post2.php"){ echo "Invalid Request"; }else{ //enter page }
  5. There appears to be 2 seperate problems, the first solved by the first reply (jscix). The second... How is the form submitted? What else happens (code wise) after the submissionis handled? If you are redirecting back to the page to display after inserting data, double check the value of $_GET['action']. I think we'll need some actual code to figure anything out.
  6. I am wondering why it got 3 slashes. I am not sure if the replies addressed this fully or not. When inserting, you want to use mysql_real_escape_string() (assuming you're using MySQL). When displaying (after a select), use stripslashes(). I do not use magic_quotes, and do not ever plan to (so, I do not know all the details of it). However, if yours is on, you should to read this: http://us2.php.net/magic_quotes Hopefully one of us hit it. If you are having further trouble, post the relevent code.
  7. Looks like a great start. It does need the -e to acknowledge the escape chars in the quotes, I remembered after a few confusing runs. Only issue with this is it only clears the number of characters needed to print next line. 1st echo "12345678" : 12345678 2nd echo "hello" : hello678 ...and so on. ok, it just occured to me, back from testing it: if I append a hand full of spaces to the end of the echo'ed string it looks perfect. Maybe not the most elegant way of doing it, but functional. People get uncomfortable not seeing any feedback, they start thinking something is wrong ( at least around here they do). Thanks alot, that will do it.
  8. I have a bash script that processes a number of files. I would like to print the name of the current file being read, then delete it and print the next. So you see the current file only, not a big list of all files. The only thing I could think of is echo the line, count the characters, build a string of that number of backspaces and echo that. Anybody know an easier way?
  9. That's an awesome answer. I don't think it's the answer OP was looking for, but I enjoyed it.
  10. (I know PHP, but new to Javascript) I have a form that is submitted by Javascript (so it can be submitted by onclick handler in span tag). I want to open the new window with no address bar, toolbar, etc. Is there a way to specify window features other than with the open() method? Or, would I be better off using open() and setting $_GET vars in the URL?
  11. I read that IE doesn't set the submit value when submitted with the return/enter key rather than the submit button. So it's more of an issue of handling the submission. When checking input, I check for the actual input fields, not the submit value. On a couple pages that have multiple forms, I will sometimes have a hidden field that I set and check for.
  12. It's not the same as stealing someones car. The car cannot be in two places at once, a wireless network can. Applies to the phone line thing also. I see nothing wrong with using an open network for typical, normal usage on occasion (which the network owner would never notice). I have seen quite a few networks left open on purpose, most are unknowingly open. If somebody is watching their paid-for cable TV on the porch, is it ok to stand on the sidewalk and watch it? The TV thing is not completely analogous, but it's closer than stealing their car or phone line. Ah, crap I can't believe I got sucked into this ancient debate...
  13. I make it a point to have separate php, html, and js (javascript) files. Although, I do mostly high function stuff easy on the 'pretty'. So not a whole lot of HTML to worry about. Still, if I need to stick a lot of HTML in the middle of php code, I would include it from external file. .php files are only php code, .js files are only javascript, and so on.
  14. It is not necessary to post your question 3 times (or more that I haven't run across).
  15. Curious what if you use print function instead of echo? Or if you open a page with nothing but "<?php?>"?
  16. Sidenote: Always a good idea to use proper tags "<?php", I'm surprised a 'training' manual suggested otherwise. Did you tell Apache what to do with the ".php" files? Are you missing this line in "httpd.conf": AddType application/x-httpd-php php
  17. While I think it's a better idea to handle persistent logins with cookies and DB entries... I believe you could simply change the default expiration time of the session cookie. ; Whether to use cookies. session.use_cookies = 1 ; Lifetime in seconds of cookie or, if 0, until browser is restarted. session.cookie_lifetime = 0
  18. I replied to this one: http://www.phpfreaks.com/forums/index.php/topic,152168.0.html The php.ini-recommended file is in the default configuration file location for your specific installation. When asking questions about a specific installation you should include the platform/distribution/version. There is always the option to use the search feature build into your OS.
  19. make a php script file: <?php phpinfo(); ?> when you go to the page the first section will show you what php.ini file is loaded. example: "Loaded Configuration File /usr/local/php5/lib/php.ini"
  20. http://www.gummy-stuff.org/Yahoo-data.htm There it is. It's really not an API, I just don't know what better to call it. It's just a different way to get the same data.
  21. Are you only trying to get stock prices, volume, etc? Yahoo provides an API (well, kinda) to do this rather easily. I have not done this myself but have seen it done and know tutorials exist to do it. Friend of mine wrote a trading simulator in VB using info from finance.yahoo.com (I'm 95% sure of this anyway), I don't think there was HTML parsing of any kind. I'm thinking it returned comma separated values...
  22. If this is the Greatest problem on Earth, there's a lot your leaving out. (hehe) I am new to regular expressions, but I believe I'm on the right track here. /action="(\w+.*\w+)"/ should match new.asp and similar. /name="(\w+)"/ should match any name value. You may want to add to the second one if you only want to find names of input elements.
  23. You can print (or 'echo') data with whatever formatting you want between the textarea tags. <textarea name="textarea" cols="100" rows="50"><?php while($row=mysql_fetch_row($result)){ echo $row[0]."<br>"; } </textarea> I'm not sure I understand the second part of the question. To make the text field 'respond' to the button...I'll take a stab here. Write a script that responds the way you want it to depending on what button was clicked, and print the results in the textarea.
  24. What does the nconvert.exe program return? As in when you use it in a command window, what does it print to the screen when it is finished converting? If it does not return something that translates to true, your script will always claim it didn't work even if it did.
  25. Define a regular expression pattern for the user name. "/[a-z]+[0-9]*/i" This would match anything with minimum 1 letter and 0 or more numbers. It is case-insensitive, but it can be changed to match anything you think of. if(preg_match("/[a-z]+[0-9]*/i",$input)){ //username is ok } Regular expressions can be difficult to get a hang of at first, but it is well worth the time and effort. In my opinion anyway. http://us3.php.net/manual/en/reference.pcre.pattern.syntax.php
×
×
  • 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.