Jump to content
xisto Community
Sign in to follow this  
O2xygen

Different Styles Of Mysql Coding.

Recommended Posts

I look around the place, and at my own MYSQl scripts, and most look the same except with a few differing factors.

Now Im relativly new to MYSQL, and not so new to PHP. The problem is though, I havent been able to test my scripts/site out so Im not sure if my scripts are right.

For example, heres a script to create my user table.

<?php$DBhost = "localhost"; $DBuser = "********"; $DBpass = "*********";  $DBName = "*********"; $connection = @mysql_connect($DBhost,$DBuser,$DBpass); echo "SQL Connection"; mysql_select_db("$DBName") or die("Unable to select database $DBName" . mysql_error() );?><?php$sql = "create table users(' 'ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, ' . 'dob_day TINYINTUNSIGNED,'. 'dob_month TINYINTUNSIGNED,'. 'dob_year TINYINTUNSIGNED,'. 'quote text,'. 'namefirst char(20),'. 'namelast char(20),'. 'email char(255),'. 'username char(255),'. 'minitar char(255),'. 'password char(255),'.)";mysql_query($sql)$result = mysql_query($sql) or die("Login Query Failed." . mysql_error() . " ". $sql);?><html><head><title>Table created</title></head><body><p>DONE!</p></body></html>

and when I compare this to others, some things differ, like the 'ID INT UNSIGNED' bit has underscores instead of spaces and is in lower case.

So my question is, does these differing factors matter?

Oh, by the way, Im new so Hi everyone :)

Share this post


Link to post
Share on other sites

You missed the ; here:

 

...

'username char(255),'.

'minitar char(255),'.

'password char(255),'.)";

 

mysql_query($sql)

 

$result = mysql_query($sql) or die("Login Query Failed." . mysql_error() . " ". $sql);

...

 

Share this post


Link to post
Share on other sites

I look around the place, and at my own MYSQl scripts, and most look the same except with a few differing factors.

<snip>

 

and when I compare this to others, some things differ, like the 'ID INT UNSIGNED' bit has underscores instead of spaces and is in lower case.

 

So my question is, does these differing factors matter?

 

Oh, by the way, Im new so Hi everyone :D

71164[/snapback]


I know that in some database systems upper/lowercase is important (like Oracle), but I don't think uppercase/lowercase is important in MySQL. However, I would think that there is a big difference between "ID INT UNSIGNED" and "ID_INT_UNSIGNED", the second one would just be one huge field name, and probably give off a syntax error because you didn't specify a type.

 

So, upper/lowercase probably doesn't matter (in MySQL), but don't exchange underscores for spaces.

 

And Hi. Welcome to Xisto. :o

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.