Skip to content

Tag: php

Can I parameterize the table name in a prepared statement?

I’ve used the mysqli_stmt_bind_param function several times. However, if I separate variables that I’m trying to protect against SQL injection I run into errors. Here’s some code sample: Is it possible to somehow replace the .$new_table. concatenation with another question mark statement, ma…

PDO Exception Questions – How to Catch Them

I’m using PDO to re-write a website interface for a database. I used to use the mysql extension, but I had never bothered with error handling, and the few error handlers I had were basically copy-paste. Now I’d like to do this right. However, I’m having issues catching the errors how I&#8217…

Undefined index uid calling GET fetch

I have a function that calls a SQL query, the function is type fetch_user Now i get an Undefined Index error when I call my query, The error message is Undefined index: uid in profile.php on line 3 But the thing is that i cant find the error, This is my user.inc.php that have the function And this is my

SQL writing format

I would like to inner join to tables with sql like this: $check_unscored = “select * from [user] INNER JOIN [tenderrc] on [user].[id] = [tenderrc].[userid]”; $…

How can I prevent 2nd order SQL attacks?

I’m using PHP PDO for my queries, everywhere, but I read that in very rare cases there could still be “second order injections” where an unsafe variable is stored then executed when used in another statement. Will prepared statements still protect against this? As long as I make sure I alway…

Doctrine 2 Query Builder abs Function

This Work: This Don’t Work: The Error: Syntax Error] line 0, col 118: Error: Expected end of string, got ‘(‘ The native doctrine function abs work only on a select part of statment and don’t work on order by part. Obs: 1-) Im avoiding to use NativeQuery. 2-) u.code is a varchar fild on…

How to print SQL statement in codeigniter model

I have a sql statement in my model, I then say My query always fails, how do I get php to print the exact sql statement being sent to my database? And display that on my php view, page Answer To display the query string: To display the query result: The Profiler Class will display benchmark results, queries y…