Musqli prepared statements

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
feinstimmer
Forum Newbie
Posts: 19
Joined: Thu Dec 07, 2006 8:36 am

Musqli prepared statements

Post by feinstimmer »

I have table with colom colled- ID, and it is int, not null, auto_increment and primary key.If i try to insert values in that table using msqli prepared statement, which specification character i use for bind_param for ID colom and which value has to be inserted to that colom?Thanks in advance!!
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

What have you coded so far? And can you use a stored procedure instead of a prepared statement?
User avatar
feinstimmer
Forum Newbie
Posts: 19
Joined: Thu Dec 07, 2006 8:36 am

Post by feinstimmer »

I am still learning, trying to make registration script using prepered statements to store data in DB.Everything is working till now or et least i can myself make it work except that problem i posted. Didn't read much about stored procedures, is that better solution?Even if it is, i would like to get answer on my question.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Musqli prepared statements

Post by RobertGonzalez »

feinstimmer wrote:I have table with colom colled- ID, and it is int
feinstimmer wrote:which specification character i use for bind_param for ID colom
User avatar
feinstimmer
Forum Newbie
Posts: 19
Joined: Thu Dec 07, 2006 8:36 am

Post by feinstimmer »

Ok, i solved it, missed one "?" in prepare and used "i' for specification character.Variable $id needed in bind_param but value is not needed.Thank you Everah.
Last edited by feinstimmer on Mon Nov 19, 2007 9:56 am, edited 1 time in total.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

You got it. Glad I could help.
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post by jmut »

Everah wrote:What have you coded so far? And can you use a stored procedure instead of a prepared statement?
No that question is answered, in same context...would you recommend stored procedure and why?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

I like stored procs because they live on the database server so you do not constantly have to build queries and send them to the database server. You just call a stored query that is in the DB server. They are safer, faster and centralized.
Post Reply