1539
votes
25answers
212k views

How to prevent SQL injection in PHP?

If user input is inserted into an SQL query directly, the application becomes vulnerable to SQL injection, like in the following example: $unsafe_variable = $_POST['user_input']; mysql_query("INSERT ...
67
votes
16answers
85k views

mysql_fetch_array() expects parameter 1 to be resource, boolean given in select

I am trying to select data from a table but get this error message: mysql_fetch_array() expects parameter 1 to be resource, boolean given.. This is my code: $username = $_POST['username']; ...
9
votes
1answer
592 views

How to insert binary data into MSSQL using PDO

I am currently experiencing a weird error. The setup: MSSQL Server 2012 Express with a localdb The target table collation is: SQL_Latin1_General_CP1_CI_AS PHP 5.3.9 on a Zend Server 5.6 MCrypt ...
7
votes
10answers
12k views

Display an array in a readable format

Here is the code for pulling the data for my array <?php $link = mysqli_connect('localhost', 'root', '', 'mutli_page_form'); $query = "SELECT * FROM wills_children WHERE will=73"; ...
6
votes
1answer
165 views
+50

connect to sql “server group” with php to run query over mutiple databases

I am trying to connect to an MSSQL Server group with PHP and action a select query over a view . I can connect & pull results from the server . I can connect & pull results from a DB With ...
5
votes
9answers
8k views

How to get the next auto-increment id in mysql

How to get the next id in mysql to insert it in the table INSERT INTO payments (date, item, method, payment_code) VALUES (NOW(), '1 Month', 'paypal', CONCAT("sahf4d2fdd45", id))
4
votes
4answers
2k views

MySQL Delete Records Older Than X Minutes?

I've searched quite a bit and found a few solutions that did not end up working for me and can't understand why. I have a table with a timestamp column. The MySQL type for this column is 'datetime'. ...
2
votes
3answers
89 views

Get number of fields in mysql table

How can I get number of fields(сolumns) in mysql table with PHP or just some kind of mysql query? Is there a way to do this without SELECT * FROM table_name and mysql_num_fields()? Maybe there is a ...
2
votes
2answers
44 views

MySQL: Check If Table's Data Has modified Without trigger and UDF?

Is there a way to know if a MySQL table's data has been modified?
2
votes
1answer
33 views

Killing off Global Session Variable as a logout button

Hey Stackoverflow users, Since I was able to get some amazing help before with a problem I was stuck on for longer than I could remember I thought I would come at you with this. Working with a login ...
2
votes
1answer
49 views

Why does my long integer change a tiny bit?

In my Java servlet, I generate a 64 bit integer every time a certain request is made. I then send this long in two directions: 1) as a JSON-encoded reply to the HTTP Get caller 2) into a MySQL ...
1
vote
1answer
42 views

PHP C or store sql query in array

I have a query that gets a number of cols off my database $searchResults = mysql_query("SELECT customerRefId, seekingAddressSuburb, seekingAddressPostcode, seekingAddressState FROM ...
1
vote
1answer
40 views

Use CASE to build SQL WHERE clause

note: Updated, as I think I need to use something similar to CASE I have a form which has 3 address inputs: Suburb Postcode State I want to use these 3 form fields to populate the where clause of ...
0
votes
3answers
1k views

MySQL SELECT * WHERE timestamp = TODAY

I am trying to select only todays records from a database table. Currently i use SELECT * FROM `table` WHERE (`timestamp` > DATE_SUB(now(), INTERVAL 1 DAY)); But this takes for the last 24 ...
0
votes
2answers
32 views

Change time zone of gmdate PHP function

I am using the gmdate PHP function to insert the current date to the database but it shows GMT time , can I change it to my time zone +3 ? this is the code $sql = "INSERT INTO Students VALUES ...

1 2 3 4 5 801
15 30 50 per page