Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Im making an update page. To me it looks strange, because the query function in php is in-built and in my case it should work properly. But it doesn't.


My code
<pre>class update
{
    function GetQuestion($question)
    {
        // Question
        $sql12query =$question->query("SELECT DISTINCT question FROM questions WHERE uniq_name='" . $question . "'");
        while ($row12 = $sql12query->fetch_array()) {
            $question = $row12[0];
        }
    }
}


What I have tried:

I tried to make the function public
Posted
Updated 3-Nov-22 3:25am
Comments
Richard Deeming 3-Nov-22 9:26am    
Your code is vulnerable to SQL Injection[^]. NEVER use string concatenation/interpolation to build a SQL query. ALWAYS use a parameterized query.

PHP: SQL Injection - Manual[^]

1 solution

Look at your code. You are using the variable $question in three different places for three different purposes ...
PHP
$sql12query =$question->query("SELECT DISTINCT question FROM questions WHERE uniq_name='" . $question . "'");
while ($row12 = $sql12query->fetch_array()) {
    $question = $row12[0];

... which will lead to all sorts of problems.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900