Jump to content

premiso

Members
  • Posts

    6,951
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by premiso

  1. The reasoning is because the browser holds all output until the end of processing to display a complete document, or the content is flushed. However, flushing only works on some browsers. Take a look at flush and ob_flush to learn more about flushing. If this was ran in CLI (command line interface), you would see the output as expected.
  2. My bet is going to be that they have fopen url wrappers turned off for security reasons. They will most likely offer curl, so I would use curl to fetch the page, and then use the load_string for simplexml to pull in the data and process it.
  3. I would suggest reading through a few tutorials, here is one to get you started: http://www.tuxradar.com/practicalphp/15/5/2
  4. Please post the relevant code inline instead of attaching. Since I do not know where the relevant part is / cba to look here is the code: <HTML> <?php // This defines the name of the file to be saved with the user information and grades $Savedfile = "FinalGrades.txt"; // This opens the text document named FinalGrades.txt and adds the new data. If it cannot open it, it then displays an error message to the user. $file = fopen($Savedfile,'a') or die("Cannot open file, check permissions"); //This clears the form fields if it is reset $clear = $_POST['reset']; if ($clear == "reset") { } else { //Defines the form variables $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $coursenumber = $_POST['coursenumber']; $finalgrade = $_POST['finalgrade']; // Uses an if statement to determine the grade as long as the fields are not empty } if (!empty($firstname) and !empty($lastname) and !empty($coursenumber) and !empty($finalgrade) and ($finalgrade >-1 and $finalgrade <101) and is_numeric($finalgrade)) { if (($finalgrade >=0) && ($finalgrade <=59) && is_numeric($finalgrade)){ $finalgrade="F"; } if (($finalgrade >=60) && ($finalgrade <=69) && is_numeric($finalgrade)){ $finalgrade="D"; } if (($finalgrade >=70) && ($finalgrade <=79) && is_numeric($finalgrade)) { $finalgrade="C"; } if (($finalgrade >=80) && ($finalgrade <=85) && is_numeric($finalgrade)) { $finalgrade="B"; } if (($finalgrade >=86) && ($finalgrade <=90) && is_numeric($finalgrade)) { $finalgrade="Aminus"; } if (($finalgrade >=91) && ($finalgrade <=95) && is_numeric($finalgrade)) { $finalgrade="A"; } if (($finalgrade >=96) && ($finalgrade <=100) && is_numeric($finalgrade)){ $finalgrade="Aplus"; } } // If a field is left empty it echos back the main page with extra information that advises the user to fill in information for all fields. if (empty($firstname) or empty($lastname) or empty($coursenumber) or empty($finalgrade) or (!ctype_alpha($finalgrade))){ echo " <html> <!-- This Allows the use of css files for the background and font format --> <STYLE TYPE='text/css' title='styleid' media='all'></STYLE> <head> <!-- This Sets the title of the page --> <title> Enter Course Grades </title> <!-- This imports the css file created to use as the background- defines the styles such as bg image and colors --> <link rel='stylesheet' type='text/css' href='background.css' /> </head> <body> <!-- Centers the company logo image as well as sets the size of 450x150 --> <center><img src='Logo.jpg' alt='Company Logo' width='450' height=150'></center> <!-- Creates the first heading for the page --> <center><h1> Enter Course Grades </h1></center> <center><h2> Please fill out all fields </h2></center> <br> <!-- Creates the form for the grade entries, and when the submit button is pressed, the form created will execute the php file process_EnterGrades.php , which will process the grades appropriately. --> <center> <Form action ='process_EnterGrades.php' METHOD = 'post'> <!-- Specifies the input types for the form created --> First Name: <input type='text' name='firstname' size='20'> Last Name: <input type='text' name='lastname' size='20'> <br> <br> <br> Course Number: <input type='text' name='coursenumber' size='20'> Final grade in percent (%): <input type='text' name='finalgrade' size='20'> </center> <br> <!-- This creates the submit buttons --> <center> <table border='3' bordercolor='red'> <tr> <td> <input type='submit' value='Submit Your Entries'> <td> </FORM> <!-- Below creates a second form that is used to clear the entries --> <FORM NAME = 'gradesclear' ACTION = 'gradesclear.php' METHOD = 'post'> <td> <input type='submit' value='Clear Your Entries'> </td> </tr> </center> </FORM> </body> </html> "; } // Displays results entered in the form in a table that is easily interpreted by the user else { echo "<link rel='stylesheet' type='text/css' href='background.css' />"; echo "<center><img src='Logo.jpg' alt='Company Logo' width='450' height='150'></center>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<center><TABLE BORDER='1' WIDTH='50%'> <TR> <TD WIDTH='50%'> First Name: $firstname </TD> <TD WIDTH='50%'>Last Name: $lastname </TD></TR> </TABLE></center>"; echo "<center><TABLE BORDER='1' WIDTH='50%'> <TR> <TD WIDTH='50%'> Course Number: $coursenumber </TD> <TD WIDTH='50%'>Final Grade: $finalgrade </TD></TR> </TABLE></center>"; //Below will define the format which the fields will be saved to the text document specified at the beginning of this document. $StringData = "First Name: $firstname Last Name: $lastname Course Number: $coursenumber Final Grade: $finalgrade \n "; fwrite($file, $StringData); fclose($file); } ?> </HTML>
  5. From his post, I am taking it he is working in the view section. Which is proper, in my opinion. So they are not really "unnecessary" that is just how views usually look. If, however, he only needs to change or add a class to it, it is really much simpler than what was posted, just need a little more clarification from the OP on that.
  6. You are using an assignment operator in your if ( = ) and not the conditional one ( == ). Change that and it should work properly. $council=0; if(isset($_POST['council'])){ $council=1; } if($council == 1){ $charge='10'; } else{ $charge='2.50'; }
  7. <?php $cnt = count($products); $i=0; foreach ($products as $row): if ($i == 0): ?> <?php elseif (($i+1) == $cnt): ?> <?php else: ?> <li><a href="product_details.php?product_id=<?php echo $row['product_id']; ?>"><?php echo $row['product_name']; ?></a></li> <?php endif; $i++; endforeach; ?> Something like that would work, probably a better way to do it, but without an example of what you want the first and last match to display / how it is changed, that is the best I have right now.
  8. Make it easier on yourself and use aliases. $Count_sql = "SELECT Event, COUNT(Sub_Type) as Sub_Type_Count FROM Verses WHERE Event='".$_POST["Event_Type"]."' GROUP BY Event"; $Count_res = mysqli_query($mysqli, $Count_sql) or die(mysqli_error($mysqli)); $Count_Event = mysqli_fetch_array($Count_res); //create the display string $display_block = " <p> The Event Type is: <b> ".$Event_Name."</b> </p> [color=#ff0000]<p> Number of Verses for this event Type:<b> </p> ".$Count_Event['Sub_Type_Count']."</b> [/color] <table width=\"70%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"#87CEEB\" > <tr> <th>ID</th> <th>VERSE</th> <th>MOOD/SUB TYPE</th> </tr>"; Does not answer your question, but yea, it is possible just makes for extra work and randomness at times. Go for the alias. EDIT: I made some changes to your code, you seem to only be pulling one event, so added the group by which should only return 1 line, and removed the while loop as 1 row should only ever be returned.
  9. Try using the postfields outside the array. curl_setopt_array($ch, array( CURLOPT_URL => $url, CURLOPT_USERAGENT => 'Mozilla/curl', CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 10, CURLOPT_POST => true, CURLOPT_COOKIEFILE => 'cookie.txt', CURLOPT_COOKIEJAR => 'cookie.txt', CURLOPT_FOLLOWLOCATION => true )); curl_setopt($ch, CURLOPT_POSTFIELDS, $login_data); And see where that gets ya.
  10. Look closer at the code I posted. Remove the single quotes ( ' ) around the $x part, as I did and it should display the numbers. When variables are used inside of single quotes, it takes it literally and displays $x, if you remove them or change them to Double Quotes (which double quotes would parse the variable) it would / will display the number.
  11. <?php for($x = 0; $x < 10; $x++) { echo 'Iteration: ' . $x . '<br />'; if ($x & 1) { echo ("odd"); }else { echo ("even"); } } ?> The browser just displayed that as you forgot the ? in the <?php, I fixed the code above, if you have questions about it let me know and I or someone else will be glad to assist.
  12. You need to move the if statement inside of the for loop.
  13. You would specify . instead of www. setcookie('user', 'badie', time()+3600*60, '/', '.mydomain.com'); Which would make it valid for all subdomains. Just remember, when you destroy / unset a cookie you need to supply the same path / domain.
  14. I was expecting to see... Hello, I'm Johnny Cash... I am disappointed.
  15. search is busted...or missing..

  16. Welcome to the forums! Let me greet you by saying, posting your code and then requesting us to add functionality to it rarely goes over well. What is better if posting the relevant sections of your code, and your attempts. If you need help with the logic of it, request that and we can point you in the right direction. If you want this done for you, I would suggest the freelance forums and offering some monetary value for the code. Thanks!
  17. If it is sending it as option_name1, use that for the post. If you are confused, do a print_r($_POST) and see what the variable name the data you want is attached to and use that in place of 'custom'
  18. The onX is for multiple items, but it will also display on the "order page" for that user. Custom will not display on the order page it is essentially hidden. For custom just do: <input type="hidden" name="custom" value="<?php echo $on0; ?>"> Simple as that, for the onX: <input type="hidden" name="on1_1" value="Username" /> <input type="hidden" name="os1_1" value="<?php echo $on0;?>" /> For custom, you should be able to access it on the IPN page as $_POST['custom'] if the os1, should be $_POST['os1'] It really depends on the problem, since your paypal script does work, that stuff is not necessary, the problem in this case lies with the form data It can also detract from your original problem as people like to go off on tangents.
  19. Not really, sure, that is a "better" method as it does not rely on PHP Version 5.4> and or short_open tags to be on in < 5.4, but as long as he has the open tags enabled or is running 5.4, that code he posted is just fine.
  20. Well the question is, do you want it to be on or do you want it to just be "custom". The onX stuff is nice if you need multiple items you want to show up on the invoice. However, if you want it to be more or less hidden the custom field is the way to go. Let me know which you want and I can fix you up. And also, next time post relevant code for your OP, posting ALL your code is just messy and sort of annoying
  21. I don't see anywhere in your paypal form where you have the <input name="custom"... being set. How do you expect it to be passed through without setting it?
  22. This is just funny, but sad at the same time. How are we expected to help not knowing your application and it is to be used. You need to post relevant sections of the code and we can help. Alternatively, you can just use javascript for a back button.
  23. Did you even read what I pasted? If your query matches 50% or more of the rows it will return nothing. Simply adding the same row 10 times, will give you nothing. You have to change the data that is being searched by to be different in order to get results.
×
×
  • 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.