Jump to content

garyed

Members
  • Posts

    198
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

garyed's Achievements

Advanced Member

Advanced Member (4/5)

1

Reputation

1

Community Answers

  1. Thanks, that's good info .
  2. What I would like to do is have most of the numbers go to 2 decimals & just a few go to 4 decimals. The problem with that is if I set decimals to (10,4) so it will read a number like 32.0756 then 27.55 goes to 27.5500 & it looks kind of cumbersome. That's why I originally thought float was best for my database but I didn't know how floats were treated.
  3. Can I assume if I wanted to have the capability of a number as large as 125000.50 that I would need to set something like " cost decimal(10,2)" for that.
  4. As usuall you guys are right on the money. I spent all day working on this & even spent about an hour google searching to no avail. Why i never thought that float could be a problem was because the number sits right in the database as is & prints out as it is also. It's only the the = sign that doesn't recognize it.
  5. I have a query that only works using like but not with = on decimal values even if the values are exact: $sql_amount=mysqli_query($con,"update $table set item='$item1' where cost= 27.55" ); $sql_amount=mysqli_query($con,"update $table set item='$item1' where cost like 27.55 " ); The second way works but I can't figure out why the first way doesn't. I can reverse the first query using set cost = 27.55 where item='$item1' & it works fine. Is there something I'm missing in the first command that will not let me use the "where" with an = sign on a decimal?
  6. Unless I'm missing something that link only descibes how to edit the mysql database which I arleady have no problem with. My only prblem is eidting the databse without having to reload the webpage. I'm not sure what API you're referring to but I didn't see it on the link you posted but I'm not even sure what API really is. What I'm looking for is a some way whether it's javascript, ajaxj,jquery or something else that will tell a php function to run on the server without reloding the page.
  7. I thought I could just change the php function in my example to a mysql call to edit a database & it would work from plain javascipt but I was obvuiously wrong. Thanks for setting me straight before I wasted any more time. It looks like I'm going to have to learn some ajax to do what I want. As for the page reloading time issue, I'm sure I can solve the time issue using just php code but I wanted to learn a way to execute a php function without reloading the page.
  8. I get what you're saying about the server side protecting against a malicious query & I understand I need to work on that. My real question is whether there any more danger in using my javascript example to call the php function than if I was to use ajax instead. As for the time issue, when the page loads it pulls data from other sources that are not from my server & that is what takes so long. Editing my database is virtually instantaneous so there is quite a bit of down time saved if I can do it without reloading the page every time the database is edited.
  9. To go a little further into what I'm planning to do with my php function is to edit a mysql database. That's why I was concerned when I read about my javascreipt method of calling the php function being insecure. I was trying to figure out how calling a php function with javascript would be any more insecure than any php code that is executed when a page loads.
  10. I have a php file that pulls information from another source & takes about 5 to 10 seconds to load. After it loads I want to be able to run a php function from the page without waiting for it to reload. I found a simple way to do it wit Javascript but my research is telling me it's very dangerous & would open the server to malicious attacks. I'm trying to understand why & also to see if there is another simple option to do it. Here's an example of the code I'm using: <?php function tester() { $x= "Get or do anything you want from the server"; echo $x; } ?> <script> function test1() { var test = "<?php echo tester(); ?>"; document.getElementById("tx1").innerHTML=test; } </script> <div id="tx1">This shows on page load </div> <button onclick="test1();"> call php function</button>
  11. Thanks for the reply, That makes a lot of sense.
  12. In trying to get the text off a particular website, I've used two different ways, both of which seem to work fine & give the exact same results.. I was wondering if anyone could give me any insight or recommendations why one way might be any better or worse than the other . I've used these two ways: $ch1=curl_init(); curl_setopt($ch1,CURLOPT_URL,$link1); curl_setopt($ch1,CURLOPT_RETURNTRANSFER, true); $text1=curl_exec($ch1); // or $text1 = shell_exec('curl '.$link1 ); The second way seems easier & speedwise they both are about the same I've also tried "file_get_contents" which also gives the same results but is obviously slower.
  13. Thanks, that's exactly what I needed. I thought I had posted in the wrong forum because I had no idea what REGEX was or meant. In all the years I've been playing around with PHP, I hardly ever used regular expressions & I didn't even know that is what they were called either.
  14. I've been trying to find some sort of tutorial on how to come up with search patterns for a function like preg_match. I was hoping someone here could point me to a site with a tutorial so I don't have to do a search every time I need to find a particular pattern. I don't need any specific search pattern right now but it's frustrating not having a clue on how to come up with one.
×
×
  • 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.