Jump to content

Search the Community

Showing results for tags 'int'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 3 results

  1. Newb here trying to build a form that works with ints to count how many red shirts die in a classic episode of star trek (exercise to get better with forms and ints). I have an error which reads as '7 Error message: Undefined index: rsTot'. I have tried a few things and read that setting it(casting it?) as a float was the safest way to work with the int, however each thing i've attempted results in some sort of error so after a day of reading and trying i'm very confused and hoping for an answer I can understand here. I have read through stackOverflow for an answer but not seen one which i can understand and apply that speaks to the problem i'm having of initially entering and process a number as an int which i can later do some math on. error can be seen here: http://zephir.seattlecentral.edu/~jstein11/itc250/z14/w03c0102_OOPform/w03c0102_OOPform.php <?php //w03c0102_OOPform require '../inc_0700/config_inc.php'; #provides configuration, pathing, error handling, db credentials //END CONFIG AREA ---------------------------------------------------------- $rsTot = (float)$_POST['rsTot'];// float more forgiving int $rsSurvived = (float)$_POST['rsSurvived']; $rsSum = $rsTot - $rsSurvived; $rsRatio = 0; # Read the value of 'action' whether it is passed via $_POST or $_GET with $_REQUEST if(isset($_REQUEST['act'])){$myAction = (trim($_REQUEST['act']));}else{$myAction = "";} switch ($myAction) {//check 'act' for type of process case "display": # 2)Display user's name! showName(); break; default: # 1)Ask user to enter their name showForm(); } function showForm() {# shows form so user can enter their name. Initial scenario get_header(); #defaults to header_inc.php ?> <script type="text/javascript" src="<?=VIRTUAL_PATH;?>include/util.js"></script> <script type="text/javascript"> function checkForm(thisForm) {//check form data for valid info if(empty(thisForm.YourName,"Field Empty, please fill out")){return false;} return true;//if all is passed, submit! } </script> <p align="center"><?=smartTitle();?></p> <h3 align="center">Star Trek Classic</h3> <h2 align="center">Death-Shirt Calculator</h2> <form action="<?=THIS_PAGE;?>" method="post" onsubmit="return checkForm(this);"> <p align="center">Classic Star Trek Episode Name<br /> <input type="text" name="epName" /><br /><br /> Esitmated number of officers with red shirts<br /> <input type="text" name="rsTot" /><br /><br /> Esitmated number of officers with red shirts<br /> to actually survive the episode<br /> <input type="int" name="rsSurvived" /><br /><br /> <input type="submit" value="Go!"> </p> <input type="hidden" name="act" value="display" /> </form> <?php get_footer(); #defaults to footer_inc.php } function showName() {#form submits here we show entered name get_header(); #defaults to footer_inc.php if(!isset($_POST['epName']) || $_POST['epName'] == '') {//data must be sent feedback("No form data submitted"); #will feedback to submitting page via session variable myRedirect(THIS_PAGE); } if(!ctype_alnum($_POST['epName'])) {//data must be alphanumeric only feedback("Only letters and numbers are allowed. Please re-enter your name."); #will feedback to submitting page via session variable myRedirect(THIS_PAGE); } $epSubmitted = strip_tags($_POST['epName']);# strip data entered echo '<h3 align="center">' . smartTitle() . '</h3>'; echo '<p align="center">Episode Name: <b>' . $epSubmitted . '</b><br />'; echo '<p align="center">Total Red Shirts Appearing: <b>' . $rsTot . '<br />'; echo 'Red Shirts Still Breathing at End of Episode: <b>' . $rsSurvived . '<br />'; echo 'Red Shirt Episode Survival Ratio: <b>' . $rsRatio . '</b>!</p>'; echo '<p align="center"><a href="' . THIS_PAGE . '">RESET</a></p>'; get_footer(); #defaults to footer_inc.php } ?>
  2. Hi I appreciate your help, the code is kinda simple actually but I'm having trouble The following code echo's the WRONG result a5611bcd::0::0::abccef01 I need this following result a5611bcd::fffafaff::fefffeef::abccef01 I suspect the issue is that those two middle values are too large for integer, I know about bcmath, but whats the best way to get correct results into INTEGER form.. must be integer form, basically I my variables below are closely named sorry about this... <?php $KEY = array(0xA5611BCD,0xFFFAFAFF,0xFEFFFEEF,0xABCCEF01); /*this is the model of how everything below should end up in $SKEY $KEY = array(0xA5611BCD,0xFFFAFAFF,0xFEFFFEEF,0xABCCEF01); */ //so I begin with this string $getSKEY and try to make it into the above model $getSKEY = "A5611BCDFFFAFAFFFEFFFEEFABCCEF01"; $SKEY = array( hexdec(substr($getSKEY,0,), hexdec(substr($getSKEY,8,16)), hexdec(substr($getSKEY,16,24)), hexdec(substr($getSKEY,24,32)) ); echo dechex($SKEY[0])."::". dechex($SKEY[1])."::". dechex($SKEY[2])."::". dechex($SKEY[3]) ; ?>
  3. I have a php script that looks at a supplier website and queries from a pricing calculator, the script displays the result in a table. The result is my actual cost from my supplier and the price is displayed as a string. I need to convert my wholesale cost from a string to a value and then add my retail markup cost then display the Retail Cost as a string in my table. Unfortunately, I am a complete newbie and have been searching various methods, but no matter what I try, it fails. Here is the script: <?php // Request parameters $materialid = $_GET['materialid']; $sizeid = $_GET['sizeid']; $quantity = $_GET['quantity']; $numcolors = $_GET['numcolors']; // form URL for request //$url = "http://www.suppliersite.com/pricing?materialid=104&sizeid=37&quantity=1&numcolors=1"; $url = "http://www.suppliersite.com/pricing?materialid=".$materialid."&sizeid=".$sizeid."&quantity=".$quantity."&numcolors=".$numcolors; // Create DOM from URL or file $html = file_get_html($url); // Echo page //echo $html->plaintext; $price_per_item = $html->find('#price-per-item'); $total_price = $html->find('#total-price'); $description = $html->find('.description'); $name = $html->find('h3'); //echo $price_per_item[0]."<br />"; //echo $total_price[0]."<br />"; //echo $description[0]."<br />"; //echo $name[1]."<br />"; // Iterate through all combinations: echo "<table id=\"products\">"; echo "<tr>"; //echo "<th>Price per item</th><th>Total Price</th><th>Product</th><th>Description</th><th>Size</th><th>Quantity</th>"; echo "<th width=\"25%\">Price per item</th><th width=\"15%\">Total Price</th><th width=\"30%\">Product</th><th width=\"10%\">Size</th><th width=\"10%\">Colors</th>"; echo "<tr>"; $price_per_item = $html->find('#price-per-item'); $total_price = $html->find('#total-price'); $description = $html->find('.description'); $size = $html->find('select[id='.'top-sizes-select'.'] option[value='.$sizeid.']'); echo"<tr>"; echo "<td>".$price_per_item[0]."</td>". "<td>".$total_price[0]."</td>". "<td>".$name[1]->innertext."</td>". // "<td>".$description[0]."</td>". "<td>".$size[0]->innertext."</td>". "<td>".$numcolors."</td>"; echo "</table>"; echo "<br />"; echo "<div style=\"width:40%\">"; echo $description[0]; echo "</div>"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB"> <head> <title>Extractor</title> <style media="screen" type="text/css"> #products { font-family:Arial, Helvetica, sans-serif; width:60%; border-collapse:collapse; font-size:12px; } #products td, #products th { font-size:1em; border:1px solid #777777; padding:3px 7px 2px 7px; } #products th { font-size:1.1em; text-align:left; padding-top:5px; padding-bottom:4px; background-color:#777777; color:#ffffff; } </style> </head> <body> </body> </html> Attached is a screenprint of the results, you will see the cost per item is $11.55 and I simply want to add 20% or as in the code: = price-per-item*1.2 -----so the price should show $13.86 per item I have tried to define a value such as: $RETAIL_price_per_item = $html->find(int('#price-per-item')*1.2); but that does not work I have tried many other versions and in different areas of the code but nothing works. Any help would be greatly appreciated. Thanks
×
×
  • 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.