Jump to content

Ansego

Members
  • Posts

    151
  • Joined

  • Last visited

Everything posted by Ansego

  1. Changed Having -> Where still have this error of the double. 03:12:29 SELECT *,(((acos(sin(( tbl_aupc.Latitude *pi()/180)) * sin((`lat`*pi()/180))+cos(( tbl_aupc.Longitude *pi()/180)) * cos((`lat`*pi()/180)) * cos(((tbl_aupc.Longitude - `long`)*pi()/180))))*180/pi())*60*­ 1.1515*1.609344) as `distance` FROM `tbl_aupc` WHERE `distance` <= 50 ORDER BY `distance` ASC Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1.1515*1.609344) as `distance` FROM `tbl_aupc` WHERE `distance` <= 50 ORDER ' at line 1 0.000 sec
  2. Hi All, Having trouble getting this to work, in scope of the project stated above and could do with some assistance to get it to work please. SQL STATEMENT: Does not seem to enjoy a double: *180/pi())*60*­ 1.1515*1.609344) as `distance` FULL SQL STATEMENT: SELECT *,(((acos(sin(( tbl_aupc.Latitude *pi()/180)) * sin((`lat`*pi()/180))+cos(( tbl_aupc.Longitude *pi()/180)) * cos((`lat`*pi()/180)) * cos(((tbl_aupc.Longitude - `long`)*pi()/180))))*180/pi())*60*­ 1.1515*1.609344) as `distance` FROM `tbl_aupc` HAVING `distance` <= 50 ORDER BY `distance` ASC; ERROR: 02:24:12 SELECT *,(((acos(sin(( tbl_aupc.Latitude *pi()/180)) * sin((`lat`*pi()/180))+cos(( tbl_aupc.Longitude *pi()/180)) * cos((`lat`*pi()/180)) * cos(((tbl_aupc.Longitude - `long`)*pi()/180))))*180/pi())*60*­ 1.1515*1.609344) as `distance` FROM `tbl_aupc` HAVING `distance` <= 50 ORDER BY `distance` ASC Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1.1515*1.609344) as `distance` FROM `tbl_aupc` HAVING `distance` <= 50 ORDER ' at line 1 0.000 sec Table Columns: pcode Latitude Longitude Kind regards;
  3. Um, might be late and I am tired, but I must of missed the question. Are you trying to make a form for potential customers? Why the file system? Possible security risk posting in public all the file names in the directory...
  4. Hello, I can't see what I am doing wrong, not getting any errors and the data is not storing the database, can you see what I've missed? (SQL Statement correct?) Objective: Pull data from *.CSV and dump it into MySQL Database; $fin = fopen('db/pc.csv','r') or die('cant open file'); $mysqli = new mysqli('localhost', 'user', 'password', 'aupostcode'); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $mysqli->select_db("dbleads"); If (!$mysqli) { die ('Could not connect: ' . mysqli_error()); } echo "Connection succeeded <br />\n"; while (($data=fgetcsv($fin,1000,","))!==FALSE) { $sqlstring = "INSERT INTO `aupostcode`.`tbl_aupc` (`PCode`, `Locality`, `State`, `Comments`, `Deliveryoffice`, `Presortindicator`, `ParcelZone`, `BSPnumber`, `BSPname`, `Category`, `Lat`, `Long`) VALUES ('" . $data[0] . "', '" . $data[1] . "', '" . $data[2] . "', '" . $data[3] . "', '" . $data[4] . "', '" . $data[5] . "', '" . $data[6] . "', '" . $data[7] . "', '" . $data[8] . "', '" . $data[9] . "', '" . $data[10] . "', '" . $data[11] . "'); "; $mysqli->query($sqlstring); } echo "Insert Complete </br>"; fclose($fin); $mysqli->close(); Kind regards and advance thanks.
  5. Hi all and thanks for reading; I need to get a scope together before I start building and having a little trouble with logic and the maths and could do with some input from you all the best way to attack this. Basically I need to use Latitude and Longitude and a radius of (X) km and get all the postcodes (ZIP, Area code) within that (X) km radius. There is 8000+ postcodes and some Lat & Long share the same postcode area. Tools: Html/CSS Php SQL/MySqli Example: Data: Postcode's | Name of area | Lat | Long | (X) Area Radius km User Input: '4001' Output: 4002, 4005, 4010 3090, 3097 etc Maths: Circumference ( C ) Diameter ( D ) Radius ( R ) Area ( A ) Pi ( P ) A = P R Square 50 km = A≈7853.98
  6. Hi, I also agree with @Jacques1; Has the explanation in more detail on the php manual: bin2hex Reference: http://www.php.net/manual/en/function.bin2hex.php Mhash Reference: http://www.php.net/manual/en/ref.mhash.php md5 Reference: http://au2.php.net/md5
  7. Hi, phpinfo.php file can be placed any where in your web folder and should give you a print out of all the settings from php. If that does not give a print out then your php install is incorrect. Html/css is more decorative / design then you add scripts like php, asp, perl etc. Html runs without a server and can be run locally without the help of http server. If your php code is printing to screen then it would seem php is not installed or your not running the file through the server or format of the code blocks, or extensions etc, so test the phpinfo.php file and if it gets a return like below then your in business and we need to look at other problems. Are you running the web server from your private server? This is what phpinfo looks like when it is run: (Do you get this?)
  8. Yeah mate I know the feeling, we have been cranking this for a couple of days lol. Need to look at the logic and follow it through, think it is almost there, check your sums and see if they are out putting correct and echo them in different places in your code to see if changes occured. See how you go, give it a good crack and post again if you have not got a resolve.
  9. My bad 'number_format' I thought it was your own method. It is from PHP manual.
  10. Are you sure you have php installed? lol. If php.ini is no where to be found that does not sound good... lol. It seems you might have a php install problem not running through your http server correctly. These are my current thoughts. Create a file called: phpinfo.php and add the following code to it: <?php phpinfo(); ?>
  11. Can you show me what's going on in 'number_format()' - Also the chuck of code we are working on from the $price down to the $counter ++; paste in here please. Seems pointless but test this just the same, cleared the variables before the switch: $price = $price + (calcVAT (htmlspecialchars($row['Price_ExVat']))) * htmlspecialchars($row['quantity']); $i = $row["Prod_Make"]; $percentage = '0'; $discount = '0'; $totaldiscount = '0'; switch ($i) { case "SONY": ($percentage = 15/100); $discount = ($percentage * $price / 1.200); $totaldiscount = $price / 1.200 - $discount; break; default: $percentage = '0'; $discount = '0'; $totaldiscount = '0'; }
  12. Just a heads up the scope of your code has a downfall with having the code like this is that it is NOT fully dynamic; for example: If you added items to your database ie 'Microsoft', 'Panasonic', 'Nec' etc you would then require updating the discounts manually every time. Or even IF you wanted to change the discount on 'Sony' you would have to do it manually.
  13. switch ($i) { case "SONY": ($percentage = 15/100); $discount = ($percentage * $price / 1.200); $totaldiscount = $price / 1.200 - $discount; break; default: $percentage = '0'; $discount = '0'; $totaldiscount = '0'; }
  14. When you added those three lines do we get the same output? You have the three lines before the default and remove the "APPLE" so it defaults default: $percentage = '0'; $discount = '0'; $totaldiscount = '0';
  15. Get this to work first, it is wanting a numeric, should of been a easy fix for you, put this also above the switch before it starts so it is fresh, might fix the other problem; The other screen shot shows incorrect data too. Paste your full code in again so I can take another look... $percentage = ''; $discount = ''; $totaldiscount = '';
  16. Place in the apple section of the switch: $percentage = ""; $discount = ""; $totaldiscount = ""; OR You can remove apple so it goes to the default section. Out of curiosity; is sony going to always have a discount?
  17. Hi, Changing the approach: // Allows Session to run for min of 2 hours ini_set('session.gc_maxlifetime', 7200); // Client will have session id for EXACTLY 2 hour session_set_cookie_params(7200); Few things come to mind; Normally the server will Garbage collect after I believe default 20 minutes. If this is NOT working, then in the php.ini possibly these have been edited? So check the following: session.gc_probability integer session.gc_divisor integer session.gc_maxlifetime integer Reference: http://au1.php.net/manual/en/session.configuration.php#ini.session.gc-maxlifetime General structure for session: At the top of your page before the <html>: <?php session_start(); ?> After the <body>: Setting Session <?php session_start(); // store session data $_SESSION['views']=1; //retrieve session data echo "Pageviews=". $_SESSION['views']; if(isset($_SESSION['views'])) $_SESSION['views']=$_SESSION['views']+1; else $_SESSION['views']=1; echo "Views=". $_SESSION['views']; ?> To destroying a session ie Logout page: <?php session_start(); if(isset($_SESSION['views'])) unset($_SESSION['views']); ?> OR <?php session_destroy(); ?> Reference: http://www.w3schools.com/Php/php_sessions.asp Hope this helps. Please don't forget to press the solved button if we happen to solve it for you.
  18. Making me work for this solved tick lol,... Can you print screen, don't understand what you mean: Would this fix it? Change: default: // Nothing TO: default: $percentage = ""; $discount = ""; $totaldiscount = ""; Don't forget to press solve when we come to a solution... Need my brownie points ;-)
  19. Make sure this is set allow_url_include in you php.ini file. Reference: http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-include
  20. Id do something like below; Code NOT TESTED you will need to debug it and tweak to get to work. Hope it helps. PS: Keep you code clean, tight and indented, will help you read it better. <?php } else { //*************display contents of basket////////////////////////////////////////////////////// // echo each header from array //foreach ($dbFields as $headIndex) // echo an extra blank header for the delete item column // fetch each row as an associative array $counter = 1; $price = 0; //set default postage value outside loop $postagerate = 15.00; while ($row = mysql_fetch_assoc($result)) { //decide which postage value is the highest and use that to calculate overall price //get the postage values for each product $sqlpostquery = "SELECT * FROM postage WHERE Post_ID = '" . htmlspecialchars($row['Post_ID']) . "'"; //get the postage values from the database $postresult = mysql_query($sqlpostquery); $rowpost = mysql_fetch_assoc($postresult); // check if postage value was available if ($postresult || !(mysql_num_rows($postresult) == 0)){ $rawpostage = htmlspecialchars($rowpost['Post_Cost']) ? htmlspecialchars($rowpost['Post_Cost']) : 0.00; //get the lowest postage rate. if ($postagerate > $rawpostage){ $postagerate = $rawpostage; } } else { $postagerage = 0.00; } //round postage rate of 2 decimal places $postagerate = $postagerate; //release the postage resultset array mysql_free_result($postresult); // Pecentage discount code - Needs testing: $price = $price + (calcVAT (htmlspecialchars($row['Price_ExVat']))) * htmlspecialchars($row['quantity']); $i = $row["Prod_Make"]; switch ($i) { case "Sony": ($percentage = 15/100); $discount = ($percentage * $price); $totaldiscount = $price - $discount; break; case "Etc": ($percentage = 15/100); $discount = ($percentage * $price); break; default: // Nothing } echo "<form action=basket.php method=get name=form".$counter."> <input name=update type=hidden value=yes> <input name=productID type=hidden value=". $row['productID'] ."><tr class=stdtable> <td align=center> " . htmlspecialchars($row['Prod_Make']) . "</td> <td align=center> " . htmlspecialchars($row['Prod_REF']) . "</td> <td align=left>" . htmlspecialchars($row['Product_Desc']) . "</td> <td align=center><input name=updateQuantity onchange=submit(); type=text size=2 value=". htmlspecialchars($row['quantity'])."></td> <td align=center>". $currency . number_format(htmlspecialchars($row['Price_ExVat']), 2) ."</td> <td align=center>". $currency . number_format(calcVAT($row["Price_ExVat"]), 2) ."</td> <td align=center>". $currency . number_format((calcVAT (htmlspecialchars($row['Price_ExVat'] * $row['quantity']))), 2) . "</td> <td align=center>" . $totaldiscount . "</td> "; //REMOVE ITEM echo "<td align=center><a href=\"basket.php?delete=yes&productID=" . $row['productID'] . "\"><img src=2003/remove.gif border=0></a></td>"; echo "</tr></form>"; $counter ++; // Loop that will apply the TRADE DISCOUNT // LEAVE THIS HERE INCASE I BREAK THINGS $price = $price + (calcVAT (htmlspecialchars($row['Price_ExVat']))) * htmlspecialchars($row['quantity']); $price = $price + (calcVAT (htmlspecialchars($row['Price_ExVat']))) * htmlspecialchars($row['quantity']); $i = $row["Prod_Make"]; switch ($i) { case "Sony": ($percentage = 15/100); $discount = ($percentage * $price); $totaldiscount = $price - $discount; break; case "Etc": ($percentage = 15/100); $discount = ($percentage * $price); break; default: // Nothing } } // END the TRADE DISCOUNT LOOP $subtotal = $price - $discount; $total = $subtotal + $postagerate ; //pick overall postage type if ($postagerate == 5) $postage = 3; else if ($postagerate == 9) $postage = 2; else if ($postagerate == 10) $postage = 1; } //update shopper table with new/changed info $sqlshopper = "SELECT * FROM shopper WHERE User_ID = '" . $userID . "'"; //echo "query: " . $sqlshopper; $result = mysql_query($sqlshopper); $rowCount2 = mysql_num_rows($result); //add shopper if ($rowCount2 == 0) // Nothing { $sqladd = "INSERT INTO shopper" . $shopperFields . "VALUES ('" . $userID . "', '" . $total . "', '" . $postage . "')"; $shopadd = mysql_query($sqladd); if (!$shopadd) echo "<font class=error><p>Your basket has not been processed</p></font>"; } else // Nothing { //update details $sqlupdate = "UPDATE shopper SET Basket_total = '" . $total . "', Postage = '" . $postage . "' WHERE user_ID = '" . $userID . "'"; $shopupdate = mysql_query($sqlupdate); if (!$shopupdate) echo "<font class=error><p>Your basket has not been updated</p></font>"; } // finish table echo "</td></tr>"; ?>
  21. The example above I was giving above is an example of the percentage data that you can sort out within your switch statement. Is this code inside a SWITCH STATEMENT and within the loop? echo "<td align=center><input name=updateQuantity onchange=submit(); type=text size=2 value=". htmlspecialchars($row['quantity'])."></td> <td align=center>". $currency . number_format(htmlspecialchars($row['Price_ExVat']), 2) ."</td> <td align=center>". $currency . number_format(calcVAT($row["Price_ExVat"]), 2) ."</td> <td align=center>" THIS IS WHERE I NEED THE DISCOUNT TO SHOW! "</td> <td align=center>". $currency . number_format((calcVAT (htmlspecialchars($row['Price_ExVat'] * $row['quantity']))), 2) . "</td>"; echo "<td align=center><a href=\"basket.php?delete=yes&productID=" . $row['productID'] . "\"><img src=2003/remove.gif border=0></a></td>"; echo "</tr></form>"; If it is all you need to do is replace 'THIS IS WHERE I NEED THE DISCOUNT TO SHOW!' with $$discount"; OR $percentage% Depending what you want. Hope this helps. If it doesn't I'll have another look tomorrow, very late here, not enough coffee and have blurry eyes.
  22. Show us the form code + Javascript for the onchange function and where you are compiling the drop box and what ever is needed from ch_div_content.php that handles method=getPriceSets&countryId='+this.value. Don't show any passwords / usernames or any secure data.
×
×
  • 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.