Welcome Guest ( Log In | Register )



2 Pages V  < 1 2  
Reply to this topicStart new topic
> Need Help With A PHP - MySQL Registration Script, Wont INSERT into the database
Houdini
post May 21 2006, 05:28 PM
Post #11


Super Member
Group Icon

Group: Members
Posts: 572
Joined: 25-April 05
From: Nashville Tennessee
Member No.: 4,340



QUOTE
Your SQL Insert statement is wrong, you confused it with the UPDATE SQL Statement, the correct way to write it is:
This is not necessarily true you can include the SET in an insert statement see MySQL:INSERT syntax for more and you will notice the second method of using the INSERT statement allows the use of the SET statement, you just don't see it used that much and instead see the UPDATE being used.
Go to the top of the page
 
+Quote Post
iGuest
post May 6 2008, 05:02 AM
Post #12


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 0
Joined: 1-November 07
Member No.: 25,869



business logic validation
Need Help With A PHP - MySQL Registration Script

How to do business logic validation to check whether duplicate username is already existing in database using php

-question by kalai
Go to the top of the page
 
+Quote Post
hotsam
post Jul 20 2008, 02:47 AM
Post #13


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 3
Joined: 11-June 08
Member No.: 30,912



Hi,

Below is a picture of my database tables, and their relationships. I was hoping someone might have a quick look and tell me if I'm on the right track, or if I need to:

Change PRIMARY keys
Change INDEX / FOREIGN keys
Change Table Structures

Also, I'd like to add a table that stores the various CALIBERS that firearms are available in. I'm thinking the relationship would be many-to-many, as a firearm can have many calibres, and a calibre is available for many firearms...?

How would I make the CALIBRE table? What fields should the table contain, and how should it relate to the FIREARMS table? I'd like to be able to output a list of firearms, and show available calibres for each of those firearms.

Just to help out, the database will be used to:
- search for firearms and their available calibres
- show retailers that sell a particular make of firearm
- show reviews that owners (users) submit. These will be shown alongside each firearm searched for


http://home.exetel.com.au/jazzy/relationships.png

Thanks for any help!
Jarrad




Go to the top of the page
 
+Quote Post
Arbitrary
post Jul 20 2008, 03:17 AM
Post #14


Premium Member
Group Icon

Group: [HOSTED]
Posts: 377
Joined: 17-June 06
From: Adblock life
Member No.: 13,992



QUOTE
After thinking about it I can see the advantage of writing a script that does what you're talking about vujsa. Have a function like build_db_query or something that builds the actually query and returns it as a string perhaps. You pass a table name, and an array of values in an assoc array indexing the related tables in the fields. You could make it even more flexible and add flag to determine whether it's a select, insert, update, or delete statement. Just have a switch on the flag, then build the appropriate sql statement.

This has been done before in the CakePHP framework (see http://api.cakephp.org/class_model.html#eb...b5a35dd428f5c81 and I'm sure numerous other PHP frameworks that I don't work extensively with as well), except that Cake didn't take advantage of PHP's OOP because it also wanted to be PHP 4 compatible. It just requires that you pass in the variables in a certain format (in Cake's case it's an array) and then parse based on the fields and values in that format. It is really quite flexible and makes saving data a lot faster than writing the same old INSERT functions. Especially in this case where the insert function is exceptionally huge, having a function like that would be a huge advantage.

Hey hotsam!

I'd say for your firearms and reviews, you don't need a many-to-many relationship. After all, each review only has one firearm; each review wouldn't have multiple firearms, would they? Then each firearm would have many reviews, which would make sense. As for the business to firearm relationship, I'm not sure if a firearm can have many businesses--that would depend on the license, right? Aren't many firearms licensed so that they're only made by one business? (Then again, I'm not familiar with their creation...)

Everything else makes sense to me. :-) Good luck!
Go to the top of the page
 
+Quote Post

2 Pages V  < 1 2
Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Php Script To Download File From Another Site(9)
  2. [PHP + MySQL] Encrypting Data(11)
  3. Important: Basics Of Using PHP And MySQL(10)
  4. What Would Make A Good Registration Script?(4)
  5. PHP & MySQL: Displaying Content From A Given ID(6)
  6. Extracting Mysql Maths Using Php(2)
  7. Something Wrong With This Script?(9)
  8. Five Common Php Database Problems(0)
  9. Anyone Know Of A Really Good Mysql Class?(4)
  10. Automated Product Suggestion Script(2)
  11. Run A Script When Expires A Session(6)
  12. Php Script Help(1)
  13. SQL Doesn't Connect In PHP Script(19)
  14. Warning: Mysql_num_rows()(1)
  15. Warning: Mysql_result(): Supplied Argument Is Not A Valid Mysql Result Resource In ...(4)
  1. Password Recovery Script(6)
  2. How To Make A Value In The Database Raise Every Minute.(50)
  3. Login Script(8)
  4. Free Forum Hosting Type Script Help!(2)
  5. Script Request(2)
  6. Making A Link = Mysql_query(8)
  7. Making Something In Mysql Happen Only Once(10)
  8. Mysql Question(inserting Number From A Textfield)(3)
  9. Writing And Testing My Own Login Script [solved](20)
  10. Letting Users Add Mysql Data With Php(1)
  11. Make A Script Run Even If No User Is Online(6)
  12. Php Login Script(0)
  13. Myspacetv Download Php Script Help(6)


 



- Lo-Fi Version Time is now: 22nd November 2008 - 09:59 PM