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

Redirecting Admin
In my members table, I have a field called "perm" and it's set to zero for all members. Ho

Using loop to count number of entries
I'm writing a program that must ask user to type in numbers. After each entry, the program has to re

function to return url
Hi,

Can you guys help me giving a function that takes all the contents in a particular field

Search in the PHP Files
have to search asterisk(*) in the php code of the php files .
In the html page one text box

php web service error
hey guys,
I'm working on a project requires the use of web services. I've been trying a few tutor

PHP time (deadline within one week)
I have a column ['projdue'], which stores the deadline for a project.
I have PHP code and <

Sending an SMS Message with ASP.NET
Often times it may be a requirement for your web application to send an SMS message. Such examples w

Problem with HTML form
Hello,

I made a HTML form with some fields and check box.
Everything works fine except whe

How to know if online site made with PHP
Hello,
I see some sites that does not display extensions at all , for example:

www.site.co

INSERT data problem!
After having an string with apostrophes ', double quotes " or any other special characters, suc

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