Click here to Skip to main content
14,922,433 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
My project is about e municipality where online permission system for the users
I am performing a demo
The queries are executed for the one week and now No query is executing
What will be the problem
Please help me


PHP
php
    include('functions.php');
    $id = $_GET['id'];

$query = "SELECT * FROM `listtap` WHERE `id` = '$id'; ";
    if(count(fetchAll($query)) > 0)
    {
        foreach(fetchAll($query) as $row)
        {
            $id=$row['id'];
            $name=$row['name'];
            $taxno=$row['taxno'];
            $noc=$row['noc'];
            $c=$row['c'];
            $date=$row['date'];    
            $query = "INSERT INTO `approvedtap` (`id`, `name`, `taxno`, `noc`,`c`,`date`) VALUES ('$id','$name','$taxno','$noc','$c','$date') ;";
        }
        $query .= "DELETE FROM `listtap` WHERE `listtap`.`id` = '$id';";       
        if(performQuery($query)){
            echo "Account has been rejected.";header("location:homeelectricity.php");
        }else{
            echo "Unknown error occured. Please try again.";
        }
}


What I have tried:

Execution problem
For the above program i have unknown error
Posted
Updated 30-Oct-19 11:03am
v6
Comments
Richard Deeming 30-Oct-19 14:16pm
   
Your database has probably been obliterated because your code is vulnerable to SQL Injection[^]. NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.

PHP: SQL Injection - Manual[^]
Richard Deeming 30-Oct-19 14:17pm
   
And if you want someone to help you fix an error, you need to tell us what the error is.

Click the green "Improve question" link and add the full details of the error to your question. Remember to indicate which line of code it's thrown from.
Dave Kreskowiak 30-Oct-19 14:42pm
   
It could be any one or more of about a couple dozen things. But since you give no information about the errors you're getting, nor supplied the "performQuery" code, it's impossible for anyone to tell you what's going on.
Richard MacCutchan 30-Oct-19 15:50pm
   
You never execute the INSERT queries.

Good thing that is erroring now, as this script has several SQL Injection Vulnerabilities
PHP
$query = "SELECT * FROM `listtap` WHERE `id` = '$id'; ";
$query = "INSERT INTO `approvedtap` (`id`, `name`, `taxno`, `noc`,`c`,`date`) VALUES ('$id','$name','$taxno','$noc','$c','$date') ";
$query = "DELETE FROM `listtap` WHERE `listtap`.`id` = '$id';";
NEVER EVER create queries by piecing together the commands and variables; you should always use Parameters, and this can be done with prepared statements

References:
PHP: Prepared statements and stored procedures - Manual[^]
PHP Prepared Statements[^]
   
Quote:
My querys are not executing

Your code do not behave the way you expect, or you don't understand why !

There is an almost universal solution: Run your code on debugger step by step, inspect variables.
The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't know what your code is supposed to do, it don't find bugs, it just help you to by showing you what is going on. When the code don't do what is expected, you are close to a bug.
To see what your code is doing: Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute.

Debugger - Wikipedia, the free encyclopedia[^]

Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
Basic Debugging with Visual Studio 2010 - YouTube[^]

phpdbg | php debugger[^]
Debugging techniques for PHP programmers[^]

The debugger is here to only show you what your code is doing and your task is to compare with what it should do.
   

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