Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\xampp\htdocs\DCT\2\devices\move_device.php on line 108
and am having a heck of s time diagnosing it, if I comment out some php
Is there a problem with $row2?
I get Fatal error : Uncaught TypeError: ini_set() expects parameter 2 to be string, int given in C:\xampp\htdocs\DCT\2\devices\move_device.php:2 Stack trace: #0 C:\xampp\htdocs\DCT\2\devices\move_device.php(2): ini_set(‘display_errors’, 1) #1 {main} thrown in C:\xampp\htdocs\DCT\2\devices\move_device.php on line 2
when I
Sql injection would allow you to close the existing query and tack on a UNION SELECT … query to grab the complete contents of any table, such as a user table, with usernames, email addresses, and (hopefully hashed) passwords and get the code to output it onto the web page. Don’t try to pick and choose when to make a query safe, make them all safe all the time.
John, I think you already know about never trusting user supplied data. Neverthless, try this…
<?php
//Url: localhost/yourfile.php?Search=<script>alert('Hacked')</script>
$sql = 'SELECT rack_id,room_id,row,bay,title,width,height,depth,slots FROM racks WHERE title LIKE "%'.$_GET['Search'].'%"';
echo $sql;
I have been using user input to search MySql tables for about ten years and may have been fortunate in that nobody has corrupted of deleted any tables.
I did a quick search and found the following statement which I have never tried and from the write up apparently will delete the table:
database.execute(“INSERT INTO students (name) VALUES ('” + name + “');”);
The search string I use is similar to Post: #1 and I think that using LIKE %…% will not cause any harm.
If I am incorrect then I would be grateful for an example that I could try and if it does delete tables then I will revise my code and report back here with the revised script.
What is a security vulnerability if not the ability for the intent of code, logic to be changed. Measures should be taken to guard against any type of hack that change intent of logic. Leaving a SQL statement open to alteration is no different than leaving application code open to the same.
In order for injected sql to be able to append a completely different type of sql statement to what the base query is, requires multiple semi-colon ; separated queries to be supported. Most, but not all, of php’s non-multiple query methods specifically parse the sql statement and prevent this. However, there are some databases that ‘automatically’ convert a hex encoded string found in a non-string context, back to the original string, which can contain any type of injected sql, including the ; needed for executing multiple queries on the database server.
No. You do understand how sql injection is accomplished? It breaks/escapes out of the current sql context, appends its own sql syntax, then finally converts the remainder of your original sql syntax into a comment. All it has to do is supply some arbitrary value to satisfy the current syntax, supply a single-quote, to break/escape out of the string context, then it can do whatever it wants.
I didn’t state that it does. I did state that it separates multiple sql queries in those cases where they are permitted. Are you actually reading what has been written?
It breaks/escapes out of the current sql context, appends its own sql syntax, then finally converts the remainder of your original sql syntax into a comment.
I misunderstood.
When you said “it breaks/escapes out of the current sql context” I thought the current sql context was the LIKE %…% statement and the ; would break out of that statement.
It looks as though the search script is safe and I will continue to use it… unless somebody can supply a search string that breaks the search.