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

Tuesday, October 11, 2022

[FIXED] Why is node js returning all tinyint data even though I select * where it is 0?

 October 11, 2022     express, mysql, node.js, phpmyadmin     No comments   

Issue

I tried the same sql command in phpmyadmin and it works fine but different in node js so I don't think it's a problem with the sql command.

  app.get('/tag/:id', (req, res) => {
    const id = req.params.id;
    
  
    console.log(id);
      connection.query("SELECT * from news   WHERE ? = 0",id, function (error, results, fields) {
        if (error) {
          console.log(error);
      }
      else {
            res.send(results) 
      };
  });
   
 })

When I use the

SELECT * from news WHERE ? = 0 

It will return all values.

But when I use

   SELECT * from news WHERE ? = 1

It doesn't return any values ​​at all.

This is my database structure. enter image description here enter image description here


Solution

Are you trying to select to use which boolean field to select on? This can't be done using query parameters.



Answered By - Vesa Karjalainen
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

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