Questions tagged as 'php'

2
answers

Why do I have to assign the value of the prepare method to a variable to only after instantiating the execute? I can not

Ex: $stmt = $db->prepare("SELECT * FROM BD"); $stmt->execute(); Why does not it work if I instantiate the execute method of the same instance? since the value has already been passed to the prepare method? ex: $db->prepare("SELEC...
asked by 03.05.2014 / 16:00
2
answers

When to use cache system in PHP?

I've been reading a bit about using the cache in PHP, its advantages and disadvantages. Some doubts have arisen and so on. If I have a system that only shows texts with update (re-editing) of the same, very small, is it advisable to use CACHE...
asked by 09.06.2014 / 23:13
1
answer

MySQL Commands out of sync; you can not run this command now

I have a class Import (PHP) that serves to read XML files and to insert into the DB. First of all I have the constructor of class Import that creates a new connection mysqli : ... $this->mysqli = new mysqli( HOST, USE...
asked by 19.05.2014 / 15:26
2
answers

PHP value rounding error

I have a problem, after assigning a variable a float value as below, 4.85, after multiplying by 100, 48500 and when I will print out the value of 00000000484. $variavel = 4.85; $valor = $variavel * 100; echo sprintf("%011d",$valor);     
asked by 30.06.2014 / 14:02
3
answers

PHP Execution via Ajax jQuery

I'm putting some instructions inside a same PHP file that are executed according to the value of the send variable received, at least that's what I thought. In this code you have two of these instructions, one that receives send == 'bu...
asked by 02.08.2014 / 15:54
1
answer

Find the key of an array by the given value?

I would like that through a given value I could return the array key. Example: $array = array("primeiro" => 1, "segundo" => 2, "terceiro" => 3); To find out if the value exists in the array there is the in_array(); function,...
asked by 11.08.2014 / 02:45
3
answers

How to compare MySQL with an array?

I have to make a MySQL comparison with an array of numbers. For example: I have array of integers asm: $inteiros = array(); And I have to return the ids of my class table with this array , like this: SELECT *...
asked by 10.10.2016 / 14:47
4
answers

Equivalent to PHP sprintf in JavaScript

Instead of doing: var html = '<a href="' + data.href + '" title="' + data.title + '">' + data.desc + '</a>'; I'm doing: var html = '<a href="{href}" title="{title}">{desc}</a>'; html = html .replace( '{href...
asked by 15.10.2014 / 18:50
5
answers

Can I make a JavaScript call through PHP?

I'm in a doubt ... I have a PHP code, and when it gets to the "end of it" I would call a JavaScript! Ex: <? .... sucesso('$a','$b'); ?> <script language="javascript"> function sucesso(a,b){ ... } </script>     
asked by 10.09.2014 / 16:18
3
answers

Integration with the SIGEP of the Post Office

I need to integrate with the SIGEP Post API only to generate the tags. I'm using the ready-made GitHub module ( link ). It makes the connection normally, but the return that the Post gives is "Could not get the requested tags." I asked the...
asked by 07.10.2014 / 18:34