Jump to content

trq

Staff Alumni
  • Posts

    30,999
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by trq

  1. Why use php? mysql has a perfectly good DATE_FORMAT() function.
  2. Oh, and I just noticed. Within the php, on the line after echo, you need die. @header("Content-type: application/json"); echo json_encode($arr); die();
  3. You need to remove all the whitespace from around the <?php and ?> tags. This might be playing up with the returned json. Do you have firebug? If not, install it and post the output from the console.
  4. Post the exact code you are using.
  5. What exactly do you need that part for? There may very well be something simpler.
  6. It should work as is. I haven't tested it though.
  7. This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=307298.0
  8. This exe doesn't happen to execute a desktop application does it? Apache doesn't have permission to do that.
  9. Why are so many people misusing jQuery these days? Are you aware that jQuery provides Ajax functionality that will be allot more reliable than what you have written.
  10. I'm not sure you understand what Ajax is. In this example, data is sent via Javascript back to the server to php, php then does some calculations and sends the data back to Javascript, Javascript then displays the results. No. Have you looked at the last example I have posted? Its does what your after.
  11. Sorry but, you might want to start actually thinking about what's going on for yourself. So far you haven't done anything that actually requires php, are you going to save this data to a database or something? Anyway, you need to have the data echo'd from php back to the javascript. <?php if (isset($_POST['slider'])) { $ptz = $_POST['slider']; /// Grabs user input. $prce = 500; $points = 2000; // Sets discount. $price = $prce; $dis = '0.01'; $price2 = $price * $dis; // gets discount from price // sets percentage per x amount of ptz. $pts = $ptz; $perc1 = '100'; // above 1% = 100 ptz $total = $pts / $perc1; // users ptz divided by 100 ptz $mtotal = $price2 * $total; // discount multiplied by result above. // Subtracts discount from price. $ftotal = $price - $mtotal; $arr = array( "Points" => $points, "Price" => $prce, "Discount" => $ftotal ); @header("Content-type: application/json"); echo json_encode($arr); ?> } ?> <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.3/themes/base/jquery-ui.css" type="text/css" /> </head> <body> <div id="foo">Data returned from php will show here.</div> <div id="scrollbar"></div> </body> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#scrollbar').slider({ value: 0, slide: function(event, ui) { $('#scrollbar').slider('value', ui.value); $.ajax({ type: 'post', url: '#', datatype: 'json', data: {'slider': ui.value}, success: function(fromphp) { $('#foo').html("Points = " + fromphp.Points + "<br />Price = " + fromphp.Price + "<br />Discount Price = " + fromphp.Discount + "<br />"); } }); } }); }); </script> </html> Actually study this example and try and figure out whats going on. It would probably be easier to see whats going on if the php was in a separate file.
  12. pg_escape_string.
  13. Not likely. Some thing will work, some won't.
  14. The reason is that the variable doesn't actually exist until you use the slider. Just move all your php into the first if statement. if (isset($_POST['slider'])) { $ptz = $_POST['slider']; // rest of your code }
  15. This topic has been moved to Other. http://www.phpfreaks.com/forums/index.php?topic=307175.0
  16. i have read it in php manual before i asked this question here,but i still don't know .how to use ob_start? shoud we use this function? If you don't know what it does you don't need it. It has its uses. Im not sure I could explain it any better than the official documentation could.
  17. That is still invalid syntax. Methods cannot have spaces in there names.
  18. Here is the manual. http://php.net/manual, look them up.
  19. the cldbid part isn't valid syntax.
  20. Post your code.
  21. What exactly it the point of it?
  22. Of course, as always, you need permissions to execute the queries. If its a remote server, you'll need permissions just to connect to it.
  23. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=307157.0
  24. Your saving both connections within the one variable called $link. Hence, the second connection overrides the first. You then fail to pass any specific connection to mysql_query.
  25. sudo apt-get update && sudo apt-get install php
×
×
  • 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.