Jump to content

mikesta707

Staff Alumni
  • Posts

    2,965
  • Joined

  • Last visited

Everything posted by mikesta707

  1. my bad <?php $dir = "your/dir/here"; //$glob = glob("path/to/*.*"); $glob = glob("*.*"); $thelist = ""; foreach($glob as $file){ $name = explode('.', $file); array_pop($name); $name = implode('.', $name); $thelist .= '<li><a href="'.$dir.''.$file.'">'.$name.'</a></li>'; } echo $thelist; ?> that should work better
  2. something like this should work <?php $dir = "your/dir/here"; $glob = glob("path/to/*.*"); $thelist = ""; foreach($glob as $file){ $name = explode('.', $file); array_pop($name); $file = implode('.', $name); $thelist .= '<li><a href="'.$dir.''.$file.'">'.$file.'</a></li>'; } echo $thelist; ?> just edit as needed
  3. Well if you don't have the exact code its hard to tell you where the syntax error is... but in the code you just posted its on the line $okay=$false you are missing a semicolon after this line. It would help to see the code ABOVE the line you first posted
  4. what ever type of quote you surround any string with (" or ') you need to escape any occurrences of that character inside the string with the escape character (\) for example this is good $string = "he said \"hey\" to me!"; //more code bad $string = 'my name is o'neil'; //more code notice the difference in syntax highlighting.
  5. if its in a file you can use something like $code = file_get_contents("path/to/file"); you could also just surround it with quotes. Make sure to escape any quotes inside the code
  6. instead of using readdir to get all the files in a directory, you could use glob. You can just use a wildcard for the name and extension like so $glob = glob("path/to/*.*"); foreach($glob as $glob){ echo $glob."<br />"; } http://us2.php.net/glob then you wouldn't have to worry about getting directories. After that you would apply any filters you wanted to. You could also edit the pattern to only get certain types of files, and things like that. Check out the manual for more information
  7. Notepad++ has a regex search mode you could probably use
  8. you have a syntax error above that line. You probably missed a semi colon or something. post the code above that line
  9. wouldn't something like <?php if ($page == 'home') include('middle.php');?> work if you change $page to $_GET['page']? $_GET['page'] has the value you want I think
  10. Oh, sorry. You could use that condition to decide whether or not to give the body tag an id. IE <body <?php if (!(is_page('home_page'))) { echo 'id="page" '; } ?> > <!-- rest of page -->
  11. you can give your body tag a unique id. like body id="unique"> in your case you would probably want to change the id to "page"
  12. <?php $files = glob('*.php'); if (isset($_GET['page'])) { foreach ($files as $file) { if (strtolower($_GET['page']) . ".php" == $file) { include($file); //include middle if (strtolower($_GET['page']) . ".php" == "home"){ include("middle.php"); } }//end if }//end foreach }//end if else { include 'home.php'; include "middle.php"; } ?> something like that is probably what you want to do
  13. woot for turkey day
  14. Depending on the structure of your database, and how exactly the form is created for each user, an HTML array as Cosizzle suggested would probably be fine. However, without more information about your problem its hard to give much better advice than that
  15. Please use code tags... Do you have a server set up? If not you can't run PHP code. What system are you on? LAMP or WAMP would probably be the easiest setup for you to run
  16. http://php.net/manual/en/language.variables.variable.php there is an ambiguity when using variable variables with arrays. try $memb_node->${$field}[0]['value'] = 123;
  17. A good way to pinpoint where something is wrong with your code is to have PHP help you as much as it can. For example, turning error reporting on fully, and displaying all errors can help a lot. If you don't already have error reporting turned on, you can add this at the beginning of your code error_reporting(E_ALL); ini_set("display_errors", 1); Another good idea, is when you are dealing with queries, while developing/learning, add an "or" clause to the end of the query. For example $query = mysql_query("my query") or trigger_error(mysql_error()); What that will do is show an error if the query failed. Another good idea is to output variables that are troubling you. You would use echo, or print, or as aba said, print_r to show the variables. This way you can see what their value is at that point of the code, and you can compare that to what you expect it to be. by the way, print_r is for objects (like arrays) and shows their structure, and the values of their different elements or attributes It looks like this is the problem tho $result = mysql_query("SELECT * FROM $tablename WHERE County = $County"); when you pass in a string to a query (when comparing columns to values), you need to surround it with single quotes. otherwise, mysql thinks its a variable, or command, and it becomes invalid sql syntax. $result = mysql_query("SELECT * FROM $tablename WHERE County = '$County'"); see if that helps
  18. If you want them to change on the fly (IE without a page reload) you will have to use Javascript. However, a little more information would be nice. How exactly do you build you tables? are they hardcoded in? or are they dynamically generated. Will the tables always look like they will in your example (IE 5 rows 5 columns) or might they be different?
  19. Its not about not showing the user any errors, its about catching errors, and trying to code your script to handle errors elegantly. To a hacker, error messages can give them clues to vulnerabilities in your server, so you definitely want to never display errors (for the most part) but to a normal user, a cryptic error message means the same thing as a page that you just let error our (and become blank, or break the page). They will get confused and probably leave. Consider Facebook, when something goes wrong, they have a user friendly message that states that something went wrong. and tells them to try to reload the page. Just a simple explanation and some advice can mean the different between users staying at your site. Another thing, error reporting, and displaying errors are different. You DONT want to display errors (IE in the browser) how ever, you still want to keep error reporting on, and have them go to a log or something so you can check them (they can also help you pinpoint vulnerabilities and hack attempts)
  20. If you want to have a single PHP page that handles a few different form submits you can have each different form have the same name for the submit button but different values. For example. say I had two forms I wanted to submit to one page. Lets call them form1.html and form2.html form1.html <form action="process.php" method="post" > <input type="text" name="Name" /> <input type="submit" name="Submit" value="form1" /> form2.html <form action="process.php" method="post" > <input type="text" name="Password" /> <input type="submit" name="Submit" value="form2" /> then you have a case structure on the process.php page, which would take the value of the submit button as its argument. for example process.php switch($_POST['Submit']){//use the value of the submit button to decide what to do case "form1": //form1 code break; case "form2": //form2 code break; default //error code break; }//end switch I would suggest that you put the different form processing code in different functions so that the case structure doesn't get super cluttered. Then you could just add new functions, and your case structure will look clean switch($_POST['Submit']){//use the value of the submit button to decide what to do case "form1": process_form1($_POST); break; case "form2": process_form2($_POST); break; default echo "OH GOD THINGS ARE TERRIBLE"; break; }
  21. this line $email_message.= "Multimedia: $Multimedia \t\t\t\t "Network Card: $Network_card \t\t\t\t Printer: $Printer\n"; should be $email_message.= "Multimedia: $Multimedia \t\t\t\t Network Card: $Network_card \t\t\t\t Printer: $Printer\n";
  22. this is your problem $header = $_FILES['header']; $_FILES['header'] is an array. It has the file's information. What part of the files info do you want in header? it should be like $header = $_FILES['header']['name']; if you wanted the files name
  23. http://php.net/manual/en/function.mail.php you need to set the email type to text/html for html to work via the headers $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
  24. yes, and the bleachers would be the farthest electron cloud, and the front row would be the closest electron cloud. But I remember many a times Where I fell through the wall/floor in halo. One time I fell through the sky... that was weird
  25. lol. I suppose an obligatory "thats what she said" is in order
×
×
  • 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.