PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, March 5, 2022

[FIXED] Im trying to retrieve data from mysql with MAMP

 March 05, 2022     android, mamp, mysql, php     No comments   

Issue

hi guys I'm trying to retrieve data from mysql server with php, but the variable with YYYY-MM-DD it not working without date variable it works, anyone know what happened ?

If I try do in MAMP command line work but sending data from url no, please help thanks

pd: sorry for my english and on my local server date value its a date type thanks

http://localhost/arriendo/Hora.php?centroid=111&cancha=1&date=2015-11-22

$cod=$_GET["centroid"]; $cancha=$_GET["cancha"]; $date=$_GET["date"];

$result = mysqli_query($con,"SELECT Hora FROM reserva3 WHERE Cod_centro='$cod' AND Cancha='$cancha' AND Fecha='$date'");


Solution

To see what is wrong with your query try debugging it Here's how I debug query's

  1. echo the query to the screen

    $query= "SELECT Hora FROM reserva3 WHERE Cod_centro='$cod'  AND Cancha='$cancha' AND Fecha='$date'";
    echo $query;
    
  2. copy the printed query from the screen

  3. execute the query in you db manager (phpmyadmin)

  4. Read the sql error and

  5. change your query accordingly

Assumming you have a timestamp (not only date) I think you can change your query from

SELECT Hora FROM reserva3 WHERE Cod_centro='$cod'  AND Cancha='$cancha' AND Fecha='$date'

to

SELECT Hora FROM reserva3 WHERE Cod_centro='$cod'  AND date(Cancha)='$cancha' AND Fecha='$date'

If this works it's because of formatting why the first query didn't work. otherwise you have to add your sql error here, so we can fix.



Answered By - davejal
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing