Skip to content
Advertisement

Tag: php

How to prevent SQL injection in Question2Answer?

I want to prevent SQL injection in Question2Answer. This is how I store data in MySQL via HTML form. I know it’s a security risk. Examples – OR and SQL query is – How should I post data in the latest PHP 7 and above version? I think escaping strings is deprecated or outdated. Answer Based on what little information

Sort MySQL query in PHP

I’m trying to sort different users ‘points’ by descending order (highest first). But at the moment the query is being returned in order of the user’s ID (order they appear in the database). I’m not sure what is wrong with my code? The user can be in multiple leagues, so it first queries to see what leagues that the particular

How to update multiple records in Codeigniter

In above code snippet first function is declared in controller and second function is declared in model. I want to update owner for multiple rows having ids in $astrep. Can anyone please help me? Answer You can use whereIn() or orWhereIn() methods from query builder class. Refer https://codeigniter4.github.io/userguide/database/query_builder.html#looking-for-specific-data

How to get Table field names at top of result array

Here is my Sample table: Here is My Query: Result for above query is: I need to get the field names in the first element of the array. Expected result array is: How can I modify the Query to get this result? Thanks in advance… Answer Display issues should generally be dealt with in application code, not SQL queries. If

Update row if exists or insert

I’m working on a web based PHP form that’s currently connect to an Oracle database. I’m trying to get the functionality working so that after a user submits the form it’ll check if a row exists based on the Job Number, if it does then update, otherwise insert the values. It’s bring back an internal server error at the moment

Showing two different values depending on SESSION value in INNER JOIN

I have two different tables, one named users, and another named transactions. Transactions contains wallet1, wallet2, amount. Users contains user details such as firstname, lastname, and wallet. I am trying to display the corresponding first name and last name, depending on whether or not the SESSION_wallet is equal to wallet1 or wallet2 within transactions. I tried searching for a while,

Advertisement