Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. This topic has been moved to PHPFreaks.com Questions, Comments, & Suggestions. http://www.phpfreaks.com/forums/index.php?topic=310463.0
  2. Someone already posted in this thread what you would need to do - The variable has got to be a global variable to start with for the global keyword to make it available inside of the function. Variables created inside of a function, unless they are declared as static, are all stack based and are destroyed when the function returns/ends.
  3. It would take seeing the code that you wrote to save the changes. The code posted so far in this thread only produces the form. Edit: I'm going to guess that is what this other thread is for - http://www.phpfreaks.com/forums/index.php/topic,310456.0.html
  4. If you want to reference the result of count(upgrading) as $count_array['count'], you would need to use an alias name count in the query - Select count(upgrading) as count If you were developing and debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON, you would be getting an undefined error message when referencing $count_array['count'].
  5. The variable would need to be a main program (global) variable to get what you are trying to work. However, if you have variable that has meaning to both functions so that it would normally be shared between those functions, you should be using a class, not functions.
  6. Since the data is an array, just loop over the array - foreach($row as $value){ if($value != ''){ echo $value . '<br />'; } } If you don't want to do this for each element of the $row array or they are not in the order that you want, create an array of the index names in the order that you want and use the foreach() loop on this array of index names to let you iterate over the corresponding values in the $row array. Edit: The second method would look like - $index = array('address2','otherField','anotherField'); foreach($index as $key){ if($row[$key] != ''){ echo $row[$key] . '<br />'; } }
  7. $result isn't the data values that the query returns.
  8. In a way, that is kind of funny. "$name" is exactly what your rewrite rule is setting ?name= equal to. I think you meant to use $1
  9. http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html Usage is also a reserved keyword. Either rename your column to something else or enclose it in back-ticks `` every time you use it in a query.
  10. An example showing some data and the expected results for that data would certainly help.
  11. The problem is due to php's magic quotes - http://www.php.net/manual/en/security.magicquotes.php
  12. You should almost always use trim on data to eliminate white-space characters surrounding it.
  13. You most likely have a spelling error in the actual code. As always, in programming, if you want help with a problem in your actual code, you need to post the code that is actually exhibiting the problem. Also, are you developing and debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON so that php would help you by reporting and displaying all the errors it detects? You will save a ton of time.
  14. That's a different php problem. magic_quotes_runtime is causing that. You can and should turn off magic_quotes_runtime in your code.
  15. Yes it will remove user entered \ characters. You should only use stripslashes on get/post/cookie data IF magic_quotes_gpc is ON. There is a function to test the magic_quotes_gpc setting - get_magic_quotes_gpc
  16. Correct capitalization matters in programming, variable names are case-sensitive and session variables are $_SESSION
  17. A) You didn't show us how you are actually using this when it produces the incorrect output, B) You cannot output image data directly on a HTML web page. You must use an <img src="..." alt=""> tag for each image you put on a HTML web page and the src="..." attribute must be a URL that results in the image being output.
  18. Php simply outputs content (HTML, Javascript, CSS, media) to the browser. As long as that content it correct the browser can render it and display it. What is the actual php code being requested? Show the opening php tag that is in that file as well.
  19. You would need to add an is_file test in your if ($file != "." && $file != "..") conditional test if you only want to list files. If you want your code to actually transverse folders within your documents/ folder and list the files in each folder, you would need to use a recursive function.
  20. Your code is referencing three variables - $gid, $link, and $glink that are not being set in the code you posted. These alone should be producing errors. In one of your recent posts someone suggested setting the error_reporting/display_errors settings to specific values in your master php.ini so that php would help you. Apparently you did not bother to do that. Best guess is that your first query is failing due to an error in the query and all your code is being skipped over because the first while(){} loop is false.
  21. You are executing the query, but not fetching anything from the result set, so it will be a little hard to display anything.
  22. Neither do we, because you did not bother to state what you saw in front of you when you tried it.
  23. Your echo " ... ... "; statement is missing the closing semi-colon ; and would be producing a fatal parse error. You should be developing and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini so that all the errors php detects will be reported and displayed. You will save a ton of time.
  24. Slightly different method, same results - <?php $dir = "documents/"; if(isset($_POST['submit']) && isset($_POST['Del'])){ foreach($_POST['Del'] as $key => $value){ unlink($dir.$key); } } ?> <html> <body> <form action="" method="post" class="delete"> <?php if ($handle = opendir($dir)) { echo '<h2>List of Files in '.$dir.'</h2>'; echo '<table>'; while($file = readdir($handle)) { if ($file != "." && $file != "..") { echo '<tr><td><a href="'.$dir.''.$file.'">'.$file.'</a></td><td><input type="checkbox" name="Del['.$file.']" /></td</tr>'; } } echo '</table>'; closedir($handle); } ?> <br /> <input type="submit" name="submit" value="Delete Checked Files" /> </form> </body> </html>
  25. It would be much simpler if you use the filename as the name="Del['. ... .']" array index name. That way you won't need to pass the $DelFile[$i] from the code that makes the form to the form processing code. You also need to condition the form processing code so that it is ONLY executed when the form is submitted. You are kind of lucky that the code you posted did not delete all your files the first time you requested the page (to produce the form.) Edit: Also, if this is a real application (not just a learning experience), you will need to add some security to insure that the current visitor has the necessary permissions to both list the files in the form and delete the files in the form processing code.
×
×
  • 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.