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

problems with search form numerical "between" sending by php
I am trying to display the results of a search, on a sql database, on a web page. I set up html &quo

Please Help my PHP Dating Function.
Hi everyone!

Well here is my code that displays this:

It works wonderful.


problem with php mysql query
Hi guy's...

I'm totally lost here..because don't have any idea how to make a query for grab r

Querying info from one table based on info in another
Hi, I am currently trying to make a part for my user driven website where one user can subscribe to

foreach loop, assistance request
I would like some guidance on the usage of foreach as I try to parse through a large database and wh

What am I missing here? Help!
Hello all!. I can't seem to get this working right. Well - it renders right, but something is goin

Working with Dates, help.
Sooo to make a long story short, here's what im trying to accomplish.

I need to create a drop

Using Windows message as a Handle
Hi,

I am writing one of my first multithreaded programs.

In one of the thread,

add 20 000 to the rowcnt
Hi ...
I need to add 20 000 to the row count but just cant find a way to do this i am new to php

setcookie and isset($_COOKIE(name)) seem very finnicky.
I'm currently playing around with a user system with login and registration. I'm trying to use cooki

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