Questions tagged as 'mysqli'

3
answers

Use a variable for the LIMIT in a SELECT of MYSQL with PHP

I need to do a SELECT in PHP where X records are randomly selected. So I'm using the ORDER BY RAND() method, but I need the LIMIT to be one or the other depending on a variable, that is, something like this: $sql = "SELECT...
asked by 16.11.2018 / 19:20
1
answer

Problem with date in mysql query

I have a problem with a rebellious date. It turns out that I have to make a query between two dates, which would be this: SELECT id FROM 'Pedidos' WHERE ('fecha_cobro' BETWEEN '$fechini' AND '$fechafin') AND borrado = 0 I come from a form t...
asked by 01.12.2017 / 10:25
2
answers

Error Mysqli mysqli_query () expects parameter 1 to be mysqli, even if I am already giving you the two parameters that you request [duplicated]

I have this code: <?php require ("../clases/Conexion.php"); session_start(); $host = "localhost:3307"; $user = "root"; $pass = ""; $bd = "nutricion"; $con = mysqli_connect($host,$user,...
asked by 18.04.2018 / 17:52
1
answer

Query to database

I'm working with someone else's code, it's a mix of structured programming, POO, MVC. Inside a file task_model.php I have two methods, the first getTareasPendientes applies filters and makes the query with the database to throw the...
asked by 01.08.2017 / 16:23
1
answer

can session_start () be used in constructors of various classes?

I have a big doubt about security, I'm using session_start() as follows: public function validar() { session_start(); if(@$_POST) { foreach($_POST as $campo => $valor) { $asig = "$" . $campo . "='" . html...
asked by 11.08.2016 / 13:42
1
answer

Error with SQL statement prepared using PHP

So far I have never used the prepared statements but from what I have read they are necessary when avoiding SQL injection as it could happen, for example, from a web form. To test them I wrote the following code: A function to connect to the...
asked by 20.05.2016 / 08:22
2
answers

How to change a price string in php

I'm having problems printing the price of my products so I want to change it, I mean I do my sql query SELECT * FROM sinventario,as_precios WHERE sinventario.FI_CODIGO = as_precios.FI_CODIGO I save my data in an array and print it whil...
asked by 31.05.2016 / 18:37
1
answer

convert query result Mysql to INT

If I have the following function: function obtener_id(){ $conn = db_connect(); $query = "SELECT max(idproblema) FROM problemas"; $result = @$conn->query($query); return $result; } What I want to do is that...
asked by 21.02.2018 / 21:48
1
answer

How to avoid loading the data of the user logged on the user.php page?

I have two pages, perfil.php and user.php , profile.php opens when I log in with my user and I enter my profile and user.php is when I search by user name and it takes me to the profile of the searched user. How do I prevent the...
asked by 09.11.2016 / 15:24
3
answers

Error 1242 Mysql subquery

I have a problem with this subquery. I have in a table two id, cveLider and cveOperador that are related to cveEmpleado , I have to get the name of both, I did it through a subquery but I get the error    ERROR 1242 Sub...
asked by 02.01.2017 / 15:36