Good Morning,

This may seem like a very basic and simple question from someone that has been doing programming as long as I have, but it is something that has always eluded me, and I've never taken the time to ask, so here it is...

When I am doing queries, I am constantly questioning the structure regarding using variables in the query..

Is there a simple rule to follow that would make sense to tell me 'In this instance you do this' and 'In that instance you do that'...?

An example of the variations I'm referring to...

INSERT INTO adm_period_trans(adm_trans_id, admin_id, period_id, cur_rate, trans_id) 
VALUES('', '$adm[0]', '$period_id', '$adm[2]', '$sent_id')

OR

INSERT INTO adm_period_trans(adm_trans_id, admin_id, period_id, cur_rate, trans_id)
VALUES('', '".$adm[0]."', '".$period_id."', '".$adm[2]."', '".$sent_id".')

DOES it Matter?

And does it matter based on the operation? i.e. INSERT / UPDATE / SELECT

Clarification on this would be a wonderful thing...

Thanks in advance.

Douglas

Recommended Answers

Quoting in MySQL:
http://dev.mysql.com/doc/refman/5.6/en/string-literals.html

Quoting in PHP:
http://php.net/manual/en/language.types.string.php

I don't think your request has anything to …

Jump to Post

All 2 Replies

Thanks for the reply pritaeas...

I'm trying to get to the end of this project that I'm wrapped up in so I can disconnect from production and go into training mode for awhile and figure out what I need to know about using mysqli going forward. And also OOP... Trying to play catch up on the education.

Been too busy to learn for quite awhile.. although the process has been an education in itself.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.