insert/update functions for mysql, what do you think?


Posted on 16th Feb 2014 07:03 pm by admin

I am working on two really simple functions that automatically generate (and execute) insert and update mysql queries and I have some questions:

Can there be any problems later on if functions treat numeric and string values the same? The function reports error if some value is neither numeric nor string (checked by using is_numeric and is_string functions), otherwise it just uses mysql_real_escape_string on all values in array and adds '' everywhere. Unlike microsoft access, mysql doesn't seem to care if you put '' on numeric value.

The simplest usage of insert function (for form data entry) would be:

db_insert('users', 'name,e_mail,bio', $_REQUEST);

First argument is table, another is the list of fields (separated by comma) , and third is the associative array of data that you want to insert.

Can you notice any problems?

No comments posted yet

Your Answer:

Login to answer
329 Like 10 Dislike
Previous forums Next forums
Other forums

1,000 select boxes with 100 options?!
I have 1 drop down select box with 1,000 options.


In some case, there will be 100+ of the

get multiple rows
Hi I want to get multiple rows from a db

I am using this for the db query
Code: public

Form help: Syntax & Logic
Hello again all,

I'm working on a form and ran into a wall (again) and can't seem to think th

Record count of entire database
Does anyone know if there is a way to obtain the number of records in each table of the database usi

simple php table loop
Hi all,

I've the following code

<?php // Create category options

session variables not working anymore
hello,
i use sessions to handle authentication within my site. my host has been changing a lot of

problem with query error
First Thanks to those who helped me on my previous posts, and the following code i'm using is not mi

how do I show what a user have selected from a checkbox?
From my code below, how would i show which check boxes have been checked and which radio buttons sel

Intrastat Report Config in ECC 6.0 - goods Movement in EU countries
Colleagues, need ur help to understand the changes require in ECC 6 standard Report configuration se

Generate multilayered array from string.
ok so i have a string that looks like this:
Code: blog:edit_all,delete_all|users:edit_all,delete_

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash