Jump to content

earl_dc10

Members
  • Posts

    71
  • Joined

  • Last visited

    Never

Everything posted by earl_dc10

  1. hey, I stumbled upon MySQLi at php.net when I misspelled a function name. I was wondering what the difference was, the functions look identical and the only difference I noticed was that MySQLi is MySQL Improved Extension. but I was wondering if anyone knew what the actual difference was or "improvement" is. thanks!
  2. I believe you want to change [code] $num=mysql_numrows($result); [/code] to [code] $num=mysql_num_rows($result); [/code]
  3. while being a Guru may signify knowledge it also displays the amount of quesions one asks, which is just as important, if not more than being able to answer questions
  4. sorry, Im still thinkin about this one, ummm..... just for clarification, if we are calculating the price and vat of each item in a loop, what does this do? [code] $price_wovat1=($product['UK_Price']/100)*17.5; $price_wovat=round($product['UK_Price']-$price_wovat1, 2); [/code]
  5. looks like you might have the quotations switched around in your INSERT query try changing [code] $insert = "INSERT INTO `2006` (`date`, `event`, `player`, `place`, `entries`, `points`)     VALUES ($date, $event, $player, $place, $entries, $points)"; [/code] to [code] $insert = "INSERT INTO `2006` (date, event, player, place, entries, points)     VALUES ('$date', '$event', '$player', '$place', '$entries', '$points')"; [/code]
  6. [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]From this URL, a request comes in for the Sample.jpg to be displayed. But before this image be displayed, some process should be done first at the back-end, then the right size of the image should will be displayed.[/quote] so Im assuming you want an image resize script, well here's one that works well [code] <?php $img = $_REQUEST['<image name>']; header('Content-type: image/jpeg'); $source = imagecreatefromjpeg($img); $width = imagesx($source); $height = imagesy($source); $max = <maximum size> // ie 250, if max size is 250x250 if(($width > $max) || ($height > $max))     {if($width > $height)         {$new = ($width/$max);}     else         {$new = ($height/$max);}     $new_width = ($width/$new);     $new_height = ($height/$new);          $new_image = imagecreatetruecolor($new_width, $new_height);          imagecopyresized($new_image, $source, 0, 0, 0, 0, $new_width, $new_height, $width, $height);          imagejpeg($new_image);     }     else     {imagejpeg($source);} ?> [/code]
  7. remove your <html> <head> and <body> tags, only have your php script in the web page, trust me I had the same problem and this cleared it up
  8. can I see how you are adding these values together? it may be in there I just can't see where $amoutTotal = anything. if this is what you have, sorry, I'll suggest it anyway since Im crashin try this for adding the total [code] $amountTotal += ($Price-$vat); // since if VAT doesn't apply $vat equals 0, shouldn't be a problem    // after loop is done and you want to display the total $total = round($amountTotal, 2); echo $total; [/code] and I THINK that this line becomes irrelevent since we calculate VAT individually [code] $vat = $amountTotal-$price_wovat1; [/code] Im sorry if this is entirely irrelevent to your question, Im a bit tired, hope it helps though! -J
  9. is $amountTotal calculated before this query? try changing $amountTotal to the amount of the individual item for inside the loop so that the VAT calculation only applies to the individual price, not the whole.
  10. I would recommend having [code] if ($VatInfo > 0) {       //echo $amountTotal; $vat = (0);      // $price_wovat=round($amountTotal+$price_wovat1, 2);       //$vat = $amountTotal-$price_wovat1; } else { $vat = ($amountTotal/100) * 17.5; } [/code] inside your for() loop but add something like [code] $total += <price of item>; [/code] so everytime it runs and calculates whether it'a VAT or not, it adds that value to $total
  11. does the table display where it should, only the submit button is messed up?? is the hidden value underneath the table, or is it above with the submit button?
  12. Im not sure if textarea's can have "values", try this as a test [code] <textarea rows="10" cols="20" name="S1" value="It Works"></textarea> [/code] just another thing I noticed, you had your "cols" value inside of the "value" tag quotes, but try that.
  13. try this as a backup plan if nothing else works [code] <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST"> //reloads page when submitted <input type="text" name="USD"> <input type="submit" name="sub" value="submit"> </form> <?php $sub = $_POST['sub']; // makes a variable from the Posted Data $USD = $_POST['USD']; $rate = 46; if(isset($sub)) // when submit is pressed, this runs {    $INR = $rate*$USD    echo "The converted dollar is ".$INR;    // if you really wanted to be fancy you could do this:    echo $USD." in Rupee is ".$INR; } [/code]
  14. or you could use nl2br [code] echo nl2br($comment); [/code] this converts all \n's to <br>'s
  15. I did incorporate elements of your code into mine, and it works great now, thank you. and I humbly accept your correction, the above script apparently doesn't work on its own, but somehow it works incorporated in my site (seriously), but however, it will be the last time I attempt something like that, so thank you
  16. I thought about using the modulus, but wasn't sure how to account for the odd number that would go in the last page (the second 2 in your 22 would be lost) but Im pretty sure I got it, I'll try it in the morning. thanks for your patience! and, just so I don't feel entirely stupid, put this in a script and run it [code] $page = 7/(5*$x); echo $page; // this gives an error   if($x = 1)    {echo $page;} // this gives result // you were correct about the loop however, Im confused why but oh well // this yields nothing $page = 7/(5*$x);    for($x = 1; $page == 1.4; $x++)      {echo $page;} [/code] because it is not called outside the loop, it doesn't get a divide by 0 error, it is simply an alias for a clumsy equation, which, when you insert $page into the loop, the server reads it as 22/(5*$x) because they are one and the same
  17. I apologize, when copying the code (my editor doesn't like to paste to mozilla), I left out the break statement at the end of the if(), my fault, anyways, here's what it actually is [code] <?php $page = $id_main/(5*$x); // divide # of rows by 5*$x    for($x = 1; $page >= 0.2; $x++) // so it still runs if there's only 1 page left    {echo "<a href=\"".$self."?pid=".$x"\" class=\"page\">".$x." </a>"; // makes all the pages except the final      if(($page < 1) && ($page > 0))      {echo "<a href=\"".$self."?pid=".$x."\" class=\"page\">".$x."</a>"; // make last page         break; // end script           }    } ?> [/code] $x is stated in the loop, $page is just a shorter name than $id_main/(5*$x) and so there should be no problem there. and as for it never ending, it would end after $page became less than 1, $x is being modified which in turn changes $page (example below) and how this should output is links to pages of 5 entries each (1 link = 5 entries), should look like this: 1 2 3 4.... all being links, with 1 being the most recent 5 entries and the last having the odd number that are last. example [code] for($x = 1; $page >= 0.2; $x++) // expected results if $num_main = 7 // $num_main = 7, $x = 1; => 7/(5*1) = 1.4 which is >= 0.2, script runs // $num_main = 7, $x = 2; => 7/(5*2) = .7 which is >= 0.2, script runs, but runs the if statement // since it is less than 1, signifying there are less than 5 entries left for the final page and script ends with break                                                                             [/code]
  18. hey, I have a loop to make the links for the different pages for my site, I want them in groups of 5 (except for the last one if it doesn't divide equally) [code] <?php $page = $id_main/(5*$x); // divide # of rows by 5*$x    for($x = 1; $page >= 0.2; $x++) // so it still runs if there's only 1 page left    {echo "<a href=\"".$self."?pid=".$x"\" class=\"page\">".$x." </a>"; // makes all the pages except the final      if(($page < 1) && ($page > 0))      {echo "<a href=\"".$self."?pid=".$x."\" class=\"page\">".$x."</a>";} // make last page    } ?> [/code] Nothing displays from the loop, even if I just put in echo $x; inside the loop, it does nothing (and I do have more than 5 pages, so it's not that). I get no errors, so if you see something, please tell me Thanks -J
  19. you could set a cookie or session at the verification page and then request it at the 3rd page
  20. [!--quoteo(post=356615:date=Mar 20 2006, 06:30 AM:name=lessthanthree)--][div class=\'quotetop\']QUOTE(lessthanthree @ Mar 20 2006, 06:30 AM) [snapback]356615[/snapback][/div][div class=\'quotemain\'][!--quotec--] Yup, Another thing to check, although obvious, often escapes some people. If the code that inserts data into the database appears in your code AFTER you have printed out the comments / posts then it will obviously need the second refresh as the process is like below: Submit the form Refresh page due to POST Display the current posts Insert the data. You can clearly see that it can't display a post that has not been inserted despite the fact that you have refreshed the page and submitted the form. Obviously then, when the page is refreshed a second time, you can see the data that was inserted on the first refresh. Therefore make sure your process is: Submit the form Refresh due to POST Insert the data Display the current posts. Hope that makes sense. [/quote] haha, yeah, I guess that puts me in my place ;) I guess I should've noted where in the script I was placing it! Thanks for your inputs!
  21. I have a comments system on my site, it displays the 10 most recent comments and you can add a comment via a form underneath it. When I go to insert a comment, the page refreshes with nothing, then if you refresh the page a second time, it appears, there is nothing WRONG with that, it's actually exactly how it should execute, Im just wondering if there's an alternative without having a referring page, here's my code [code] <form name="comment_form" class="comment_form" action="<?php echo $self;?>" method="POST"> Name <input type="text" name="name_comment_form" size="7"><br> <textarea name="entry_comment_form" rows="2" cols="18" wrap="virtual">    </textarea><br> <input type="submit" name="comment_form_sub" value="Input> <?php $name_comment_form = $_POST['name_comment_form']; $entry_comment_form = $_POST['entry_comment_form']; $insert = "INSERT INTO $table VALUES ('$name_comment_form', '$entry_comment_form', '$num_comment')"; $insert_query = mysql_query($insert, $link)    or die("Couldn't insert comment ".mysql_error() ); [/code] I have tried this, I may be in the right direction, but not sure.... [code] <form name="comment_form" class="comment_form" action="<?php echo $self;?>" method="POST"> Name <input type="text" name="name_comment_form" size="7"><br> <textarea name="entry_comment_form" rows="2" cols="18" wrap="virtual">    </textarea><br> <input type="submit" name="comment_form_sub" value="Input OnClick="<?php    $name_comment_form = "window.document.main_table.comment_form.name_comment_form.value";    $entry_comment_form = "window.document.main_table.comment_form.name_comment_form.value";    // same insert query [/code] whenever I push submit on that code, only the "-" is entered that goes after the name, but once I refresh the page, it is then entered, on a new post, and if I load the page without submitting anything, the "window.document......" javascript stuff is entered into the values and a little off-topic, but can "this, " replace "window.document.main_table.comment_form"? Thanks!
  22. a quick google search "how to upload on a form" yielded a number of results, the first one looked like a winner [a href=\"http://cgi-lib.berkeley.edu/ex/fup.html\" target=\"_blank\"]here[/a]
  23. check any nearby loops (ie, perhaps a loop to fill the array) I normally time out on neverending loops if I forget something, but the actual line that it displays as timing out is sometimes only related to the loop, not actually in it
  24. I figured it out, apparently there's an html tag called valign, it conveniently does things like this
  25. one thing you could do is use CSS max-height in conjunction with overflow
×
×
  • 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.