Jump to content

ChemicalBliss

Members
  • Posts

    719
  • Joined

  • Last visited

    Never

Everything posted by ChemicalBliss

  1. No you cannot redeclare functions (so the while loop would fail anyway). But, there is a slightly complicated work-around: you can do this: <?php $function_prefix = "func_"; $i = 0; $funcname1 = create_function('$arg1,$arg2','return $arg1." - ".$arg2;'); echo($funcname1("hello","world")."<br />"); $funcname2 = create_function('$arg1,$arg2','return $arg1." - ".$arg2;'); echo($funcname2("hello","world")); ?> Good Luck -CB-
  2. I'm glad you found your solution . Just a note on security; Never do this: <?php include($_POST['filename']); ?> Instead do this: <?php Switch($_POST['filename']){ default: include('index.php'); break; case 'file1': Include('path/to/file1.php'); break; } ?> I'm sure you will understand why -CB-
  3. Looks like your using a Google API to populate the divs, So the actual data your using is off-site, if google supports it, maybe you can get the data directly instead of getting google to populate your divs, if you can store the data into an Array, you can do whatever you want with it. Otherwise you will need your own mysql database that holds all the zip codes and locations. (Will be extremely difficult to add routes to this system like google maps though, so i doubt it wil be anywhere near as accurate). Check the Google API you are using . Good Luck, -CB-
  4. Also, you need to state what "conditions" you require beofre including the file, give us some info on what you are trying to do . -CB-
  5. Hmm, the query looks sound. You would just store the query in a variable, before using it in executequery. Then you can do whatever you want with the query before using it . Hmm, what method of sanitization are you using? i would reccommend using mysql_real_escape_string($variable_here); on all the values, eg: $varItem = mysql_real_escape_string($varItem); -CB-
  6. No, i don't have two accounts, i don't have my old one anymore.
  7. I'd agree, but he wanted a seperate validation file in which case GET/POST data would be lost upon returning to the form. SESSIONS also help him to understand what they can be used for, it's not perfect, but it will work. Two different methods achieve the same result, just that my method is more specific to his original question. -CB- Though if you can do it, merge validation into form1.php - it is more efficient to have the form and validation in one place, executed at once.
  8. Hmm, just to let you know - there is a specifric REGEX help sub-forum in this forum, i would suggest moving this topic there as they are the REGEX gurus . -CB-
  9. Save the $file variable as another variable, and use either Explode() or substr() (see the php manual for more info on how to use these functions). Then for the Title and Alt parts use the new variable instead. -CB-
  10. Do it in 3's, dont have 7, have 9, but have the last two the same as the first two. Other than that, i believe you will need to change the javascript/css that handles the display. -CB-
  11. The answer to that is in my post - use sessions to store the data so it doesnt get lost between pages. You will need to use these functions: session_start(); // starts the session. isset(); // checks wether a variable has been set/exists. header(); // Sends specific headers to the browser telling it what to expect or do. You will also need to use these super globals: $_SESSION; // Contains every variable stored in the current session. $_POST; // Contains the post values from the form. Ofcourse you will need to use a few if statements, else if's and else. Good Luck -CB-
  12. Ok, you are obviously new to php so my advice is take it one step at a time. First, get the structure ready:Create form1.php with the ability to return the values that were previously entered. Then you can add validation. So the easiest method is to use sessions (if your going from page to page); eg: form1.php <?php // First start the session // Set some default values for the fields. can be blank, but needed if you dont want E_NOTICE errors. eg: $form['name'] = 'Please enter your name'; // Check if certain session variables are set, if they are then save them to some variables eg: if(isset($_SESSION['name'])){ $form['name'] = $_SESSION['name']; // So instead of the default value, you have the value that is saved in the session. } // Display the form with the default values (or modified session values); eg: ?> <input type="text" value="<?php echo($form['name']); ?>" name="name" id="name" /> <?php // That's it ?> Then with validate.php: <?php // Start the session like in form1.php // Check all the $_POST values (values submitted by the form) // If there is an error, save all the $_POST values into $_SESSION values, eg; $_SESSION['name'] = $_POST['name']; // NOTE: Saving any $_POST/$_GET or $_REQUEST variable directly can result in security vulnerabilities. Make sure you don't use code like this for a production (public) website. // Then you can use a header() redirect back to form1.php, and the form will automatically preserve the values. // Once you get this far, the specific validation you need will be very simple. Obviously if there is no problem validating, then you can continue with whatever comes after form1.php (whatever your doing with the data). ?> This should get you started, dont forget to read tutorials, and check out the php manual (http://www.php.net/manual/en/getting-started.php). Good Luck! -CB-
  13. Frankly - this is a Javascript question. Since you will need to use some sort of javascript to modify the default behaviour of the drop-down box. Try asking in the javascript forum - You should get better results. -CB-
  14. All you need is an if clause in ur script to tell wether its ajax calling it, and you can handle the queries easy . Would take a little time if it's your first go but really is more simple than it sounds . And since u obviously know javascript (having porting your code from it), you should take it on easy . Just follow a quick tutorial and you'l get the hang of it in like 1 day (thats how long it took me - without knowing java). -CB- Good Luck
  15. Read through all the answers and try each one. If you don't, i highly doubt anyone is going to repeat themselves - in which case you may nerver solve the problem. -CB-
  16. Lol ok - well i think we've thoroughly discuessed this enough . It's just 0 reply topics - they all can be answered, if helpers just do a quick google search (ive done it plently of times, with a previous phpfreaks account , and a couple with this one), just to get an idea of the subject matter, it helps the helper to learn as well. If they dont know the answer they can give references to people/ places that do . Some people honestly don't know how to ask simple questions because they don't know the code well enough or have enough experience to structure an informative question. Unless they spam, or dont listen to the answers - that's different . O lol - not nit-picking (well..maybe ) but; 0 reply threads dont mean its 100% not solved . And 0 reply threads could make it into the boundless pages therein, once it reaches the 2nd page, it's answering potential is probably (guess) halved, then halved again every subsequent page, unless poeple *bump* (which i wouldnt condone), people with specific questions as cags has mentioned wont get an answer unless someone with that particular knowledge reads the message . Anyway, maybe some ideas there . -CB-
  17. PHP is a pre-processor. That means output doesnt get forwarded to apache until the process has finished (script closure). Unfortunately you cannot change this without elaborate tcp calls etc. (that i know of). To do what your asking, you will need to setup an ajax script, so that when the user clicks submit, the first query gets sent to the special script by javascript (without loading another page), then it would wait for a response (that you can display to the user), and then it can do it again, and again, until the last query. This is relatively simple if you have any experience with javascript. Just check out some ajax tutorials - you'll get it . -CB-
  18. To be blunt, Not really, if we did you probably wouldnt understand it. I would suggest reading tutorials on using IMAP with attachments, if it's too advanced then you need to start on some smaller tutorials that focus on the components. Like writing functions, using Classes and Objects, and the various functions in there like base64_decode() can be understood by reading through the php manual. -CB-
  19. First, i would learn a little about php, find a few beginner tutorials etc (some on this site). Then, learn how to use the mail() function. Good Luck . -CB-
  20. I use unix timestamps to do this. Save the current time() in a variable called $cTime; Get 7 days ahead by adding 7 days of seconds to $cTime and store in $dTime; then get the current project Due time $pTime; (all of these should be unix timestamps). Then it's easy: if($pTime < $dTime){ echo("Less than 7 days remaining"); }else{ continue; } so if the Project due timestamp, is less (sooner) than the current time+7 days, then it should be flagged. Hope this Helps, -CB-
  21. If you want real-time reporting of each query you would need to use some pretty complicated AJAX. And call a script with each query one after the other, and get ajax to update the page each time. AJAX is actually pretty simple once u know how to use it. -CB-
  22. lol waited to use that emoticon . The manual says (And the error), that paramter 1 needs to be of type: resource (this would be returned by a successfull fopen call). $handle doesnt exist anywhere in the code so obviously its wrong, where is your resource? what variable are you using to save the resource to (from fopen()). Hope this helps, -CB- PS: http://uk3.php.net/manual/en/function.fgetcsv.php The manual is your best friend.
  23. Looks like you have a double-quote beofre the query. When mysql gives a syntax error, it shows from the beginning of the error. so the error lies _just_ before the INSERT clause. Try echoing the query into the browser and seeing if it is what you expected. There is ofc a problem with your query, and probably not the class your using. Its the data your passing to the class (your query). -CB-
×
×
  • 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.