HomeFAQSearchRegisterLog in

Share | 
 

 Understanding SQL commands and codes.

View previous topic View next topic Go down 
AuthorMessage
Spellarella
Lifer
Lifer
avatar

Posts : 3905
Join date : 2009-08-16
Location : Peeking out of a drain.

PostSubject: Understanding SQL commands and codes.   Sat Feb 12, 2011 7:47 am

SQL is a vast area with many many many commands and codes. I've put up a few, to gather whether you understand it, its relevance etc.

Databases are complex on one hand, simple the next but above anything they can go wrong with the wrong syntax used or a simple spelling mistake. Staring at lines of code looking for a speeling mistake or an , in the worng place is not for the faint hearted. Don't try this unless you understand and are able to revert back to a working database, or you can use this safely away from a database that doesn't need you interfering with it.


Quote :
Although SQL is an ANSI (American National Standards Institute) standard, there are many different versions of the SQL language.

However, to be compliant with the ANSI standard, they all support at least the major commands (such as SELECT, UPDATE, DELETE, INSERT, WHERE) in a similar manner.

Note: Most of the SQL database programs also have their own proprietary extensions in addition to the SQL standard!


Using SQL in Your Web Site
To build a web site that shows some data from a database, you will need the following:
Code:
[quote][quote]
•An RDBMS database program (i.e. MS Access, SQL Server, MySQL)
•A server-side scripting language, like PHP or ASP
•SQL
•HTML / CSS[/quote][/quote]
--------------------------------------------------------------------------------

RDBMS
Code:
RDBMS stands for Relational Database Management System.
RDBMS is the basis for SQL, and for all modern database systems like MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access.

The data in RDBMS is stored in database objects called tables.

A table is a collections of related data entries and it consists of columns and rows.


Database Tables
A database most often contains one or more tables. Each table is identified by a name (e.g. "Customers" or "Orders"). Tables contain records (rows) with data.

Below is an example of a table called "Persons":

P_Id LastName FirstName Address City
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger

The table above contains three records (one for each person) and five columns (P_Id, LastName, FirstName, Address, and City).


--------------------------------------------------------------------------------

SQL Statements
Most of the actions you need to perform on a database are done with SQL statements.

The following SQL statement will select all the records in the "Persons" table:

Code:
SELECT * FROM Persons
In this is all about the different SQL statements.


--------------------------------------------------------------------------------

Keep in Mind That...
•SQL is not case sensitive

--------------------------------------------------------------------------------

Semicolon after SQL Statements?
Some database systems require a semicolon at the end of each SQL statement.

Semicolon is the standard way to separate each SQL statement in database systems that allow more than one SQL statement to be executed in the same call to the server.

BAse on MS Access and SQL Server 2000 and we do not have to put a semicolon after each SQL statement, but remember some other database programs you have to use it.


--------------------------------------------------------------------------------

SQL DML and DDL
SQL can be divided into two parts: The Data Manipulation Language (DML) and the Data Definition Language (DDL).

The query and update commands form the DML part of SQL:

Code:
•SELECT - extracts data from a database
•UPDATE - updates data in a database
•DELETE - deletes data from a database
•INSERT INTO - inserts new data into a database
The DDL part of SQL permits database tables to be created or deleted. It also define indexes (keys), specify links between tables, and impose constraints between tables. The most important DDL statements in SQL are:

•CREATE DATABASE - creates a new database
•ALTER DATABASE - modifies a database
•CREATE TABLE - creates a new table
•ALTER TABLE - modifies a table
•DROP TABLE - deletes a table
•CREATE INDEX - creates an index (search key)
•DROP INDEX - deletes an index

The SQL SELECT Statement
The SELECT statement is used to select data from a database.
The result is stored in a result table, called the result-set.

Code:
SQL SELECT Syntax
SELECT column_name(s)
FROM table_name
and

Code:
SELECT * FROM table_name
Note: SQL is not case sensitive. SELECT is the same as select.

--------------------------------------------------------------------------------

An SQL SELECT Example
The "Persons" table:

P_Id LastName FirstName Address City
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger

Now we want to select the content of the columns named "LastName" and "FirstName" from the table above.

We use the following SELECT statement:

Code:
SELECT LastName,FirstName FROM Persons
The result-set will look like this:

LastName FirstName
Hansen Ola
Svendson Tove
Pettersen Kari


--------------------------------------------------------------------------------

SELECT * Example
Now we want to select all the columns from the "Persons" table.

We use the following SELECT statement:
Code:

SELECT * FROM Persons
Tip: The asterisk (*) is a quick way of selecting all columns!

The result-set will look like this:

P_Id LastName FirstName Address City
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger


The SQL SELECT DISTINCT Statement
In a table, some of the columns may contain duplicate values. This is not a problem, however, sometimes you will want to list only the different (distinct) values in a table.

The DISTINCT keyword can be used to return only distinct (different) values.

Code:
SQL SELECT DISTINCT Syntax
SELECT DISTINCT column_name(s)
FROM table_name

--------------------------------------------------------------------------------

SELECT DISTINCT Example
The "Persons" table:

P_Id LastName FirstName Address City
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger

Now we want to select only the distinct values from the column named "City" from the table above.

We use the following SELECT statement:

Code:
SELECT DISTINCT City FROM Persons
The result-set will look like this:

City
Sandnes
Stavanger


The WHERE Clause
The WHERE clause is used to extract only those records that fulfill a specified criterion.

Code:
SQL WHERE Syntax
SELECT column_name(s)
FROM table_name
WHERE column_name operator value

--------------------------------------------------------------------------------

WHERE Clause Example
The "Persons" table:

P_Id LastName FirstName Address City
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger

Now we want to select only the persons living in the city "Sandnes" from the table above.

We use the following SELECT statement:

Code:
SELECT * FROM Persons
WHERE City='Sandnes'
The result-set will look like this:

P_Id LastName FirstName Address City
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes


--------------------------------------------------------------------------------

Quotes Around Text Fields
SQL uses single quotes around text values (most database systems will also accept double quotes).

Although, numeric values should not be enclosed in quotes.

For text values:

This is correct:

Code:
SELECT * FROM Persons WHERE FirstName='Tove'
This is wrong:

SELECT * FROM Persons WHERE FirstName=Tove

For numeric values:

This is correct:

Code:
SELECT * FROM Persons WHERE Year=1965
This is wrong:

SELECT * FROM Persons WHERE Year='1965'


--------------------------------------------------------------------------------

Operators Allowed in the WHERE Clause
With the WHERE clause, the following operators can be used:

Operator Description
Code:
= Equal
<> Not equal
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
BETWEEN Between an inclusive range
LIKE Search for a pattern
IN If you know the exact value you want to return for at least one of the columns
Note: In some versions of SQL the <> operator may be written as !=


The AND & OR Operators
The AND operator displays a record if both the first condition and the second condition is true.

The OR operator displays a record if either the first condition or the second condition is true.


--------------------------------------------------------------------------------

AND Operator Example
The "Persons" table:

P_Id LastName FirstName Address City
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger

Now we want to select only the persons with the first name equal to "Tove" AND the last name equal to "Svendson":

We use the following SELECT statement:

Quote :
SELECT * FROM Persons
WHERE FirstName='Tove'
AND LastName='Svendson'
The result-set will look like this:

P_Id LastName FirstName Address City
2 Svendson Tove Borgvn 23 Sandnes


--------------------------------------------------------------------------------

OR Operator Example
Now we want to select only the persons with the first name equal to "Tove" OR the first name equal to "Ola":

We use the following SELECT statement:

Quote :
SELECT * FROM Persons
WHERE FirstName='Tove'
OR FirstName='Ola'
The result-set will look like this:

P_Id LastName FirstName Address City
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes


--------------------------------------------------------------------------------

Combining AND & OR
You can also combine AND and OR (use parenthesis to form complex expressions).

Now we want to select only the persons with the last name equal to "Svendson" AND the first name equal to "Tove" OR to "Ola":

We use the following SELECT statement:

Quote :
SELECT * FROM Persons WHERE
LastName='Svendson'
AND (FirstName='Tove' OR FirstName='Ola')
The result-set will look like this:

P_Id LastName FirstName Address City
2 Svendson Tove Borgvn 23 Sandnes

The ORDER BY Keyword
The ORDER BY keyword is used to sort the result-set by a specified column.

The ORDER BY keyword sort the records in ascending order by default.

If you want to sort the records in a descending order, you can use the DESC keyword.

SQL ORDER BY Syntax
SELECT column_name(s)
FROM table_name
ORDER BY column_name(s) ASC|DESC


--------------------------------------------------------------------------------

ORDER BY Example
The "Persons" table:

P_Id LastName FirstName Address City
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger
4 Nilsen Tom Vingvn 23 Stavanger

Now we want to select all the persons from the table above, however, we want to sort the persons by their last name.

We use the following SELECT statement:

Quote :
SELECT * FROM Persons
ORDER BY LastName
The result-set will look like this:

P_Id LastName FirstName Address City
1 Hansen Ola Timoteivn 10 Sandnes
4 Nilsen Tom Vingvn 23 Stavanger
3 Pettersen Kari Storgt 20 Stavanger
2 Svendson Tove Borgvn 23 Sandnes


--------------------------------------------------------------------------------

ORDER BY DESC Example
Now we want to select all the persons from the table above, however, we want to sort the persons descending by their last name.

We use the following SELECT statement:

Quote :
SELECT * FROM Persons
ORDER BY LastName DESC
The result-set will look like this:

P_Id LastName FirstName Address City
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger
4 Nilsen Tom Vingvn 23 Stavanger
1 Hansen Ola Timoteivn 10 Sandnes

The INSERT INTO Statement
The INSERT INTO statement is used to insert a new row in a table.

SQL INSERT INTO Syntax
It is possible to write the INSERT INTO statement in two forms.

The first form doesn't specify the column names where the data will be inserted, only their values:

Code:
INSERT INTO table_name
VALUES (value1, value2, value3,...)
The second form specifies both the column names and the values to be inserted:

INSERT INTO table_name (column1, column2, column3,...)
VALUES (value1, value2, value3,...)


--------------------------------------------------------------------------------

SQL INSERT INTO Example
We have the following "Persons" table:

P_Id LastName FirstName Address City
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger

Now we want to insert a new row in the "Persons" table.

We use the following SQL statement:

Quote :
INSERT INTO Persons
VALUES (4,'Nilsen', 'Johan', 'Bakken 2', 'Stavanger')
The "Persons" table will now look like this:

P_Id LastName FirstName Address City
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger
4 Nilsen Johan Bakken 2 Stavanger


--------------------------------------------------------------------------------

Insert Data Only in Specified Columns
It is also possible to only add data in specific columns.

The following SQL statement will add a new row, but only add data in the "P_Id", "LastName" and the "FirstName" columns:

Code:
INSERT INTO Persons (P_Id, LastName, FirstName)
VALUES (5, 'Tjessem', 'Jakob')
The "Persons" table will now look like this:

P_Id LastName FirstName Address City
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger
4 Nilsen Johan Bakken 2 Stavanger
5 Tjessem Jakob

Back to top Go down
.tUrniP
Lifer
Lifer
avatar

Posts : 910
Join date : 2009-08-13

PostSubject: Re: Understanding SQL commands and codes.   Sat Feb 12, 2011 8:04 am

I must thank you for taking the time... I for one am ready to move on.

By the way, did you write this?

Back to top Go down
Spellarella
Lifer
Lifer
avatar

Posts : 3905
Join date : 2009-08-16
Location : Peeking out of a drain.

PostSubject: Re: Understanding SQL commands and codes.   Sat Feb 12, 2011 8:42 am

.tUrniP wrote:
I must thank you for taking the time... I for one am ready to move on.

By the way, did you write this?

Nope it was my first introduction lesson on this and kept it inmy docs,as its a good reminder when I'm brain dead.
Back to top Go down
.tUrniP
Lifer
Lifer
avatar

Posts : 910
Join date : 2009-08-13

PostSubject: Re: Understanding SQL commands and codes.   Sat Feb 12, 2011 8:53 am

It's from W3Schools isn't it? Fantastic resource.
Back to top Go down
Spellarella
Lifer
Lifer
avatar

Posts : 3905
Join date : 2009-08-16
Location : Peeking out of a drain.

PostSubject: Re: Understanding SQL commands and codes.   Sat Feb 12, 2011 5:20 pm

tUrniP wrote:
It's from W3Schools isn't it? Fantastic resource.


Asking or showing me.

I've got it listed in my college folder: JVC Database Resource Papers, Practical lesson 1 -Constructing Install and configure SQL
:
Assessment 1: 1 activity requiring you to create simple table susing required elements. And it's a photocopy

Which I passed all the course assessments and gained my cute piece of paper showing the employers of the world my qualifications and certifications in completing the entire course set. Yay was me back then

Common enough used resource then, and a good one. Easily understandable. So I don't need to dust off my old assessment folders to show you SQL etc, you can follow the same resources I used at college back in the 90's , now up and running at W3schools.


Saves me typing up anymore codes and meanings.

Also, I have just noticed they've got the whole lot, aspi.net, sql,pho and mobile too there, defo saves me time digging out more of my dusty college folders of my not so youth and typing them into a shiny forum..

Back to top Go down
.tUrniP
Lifer
Lifer
avatar

Posts : 910
Join date : 2009-08-13

PostSubject: Re: Understanding SQL commands and codes.   Sat Feb 12, 2011 7:06 pm

To be honest it seemed familiar and I couldn't think where I'd read it; I have no idea why I felt the need to post it when I remembered ... I guess I was surprised that it's exactly the same.

Anyway, I didn't mean to suggest anything.

As I said when I asked, there most definitely are thousands of resources but there isn't really a better way to learn than doing, hence suggesting the forum project. Since nobody else seems at all interested though maybe it wasn't a good idea.

Sorry it seems to have come to nothing, I think it's a shame.
Back to top Go down
Spellarella
Lifer
Lifer
avatar

Posts : 3905
Join date : 2009-08-16
Location : Peeking out of a drain.

PostSubject: Re: Understanding SQL commands and codes.   Sun Feb 13, 2011 3:16 pm

.tUrniP wrote:
To be honest it seemed familiar and I couldn't think where I'd read it; I have no idea why I felt the need to post it when I remembered ... I guess I was surprised that it's exactly the same.

Anyway, I didn't mean to suggest anything.

As I said when I asked, there most definitely are thousands of resources but there isn't really a better way to learn than doing, hence suggesting the forum project. Since nobody else seems at all interested though maybe it wasn't a good idea.

Sorry it seems to have come to nothing, I think it's a shame.
You just want me with worn out fingers, from frantically typing all my old course papers up, don't you. lol! No offense take. TBH I've seen other college course papers appear online after I've finished the course, or were online at the same time, many times.
Many resources seem shared these days its part of the norm.

I'll check out W3's tutuorials, see if my first course differs or runs the same way. If it does, i can't see the point in me writing up my course contents if W3's is the same.

I learnt when I was programming, under IBM in the begining. When computers were huge things with limited everything. shocked

What are you exactly wanting to do? Most hosts have the coding upand running. Then you only need base commands to manage the server. Some come complete with forums, normally PHPBB and security updates, modifications come with help attached to input them. Some other forums also come with help to setting them up at the server side.

Servers come with help guides to, most of it is WYSIWYG.


Not sure what you actually want?


Back to top Go down
.tUrniP
Lifer
Lifer
avatar

Posts : 910
Join date : 2009-08-13

PostSubject: Re: Understanding SQL commands and codes.   Sun Feb 13, 2011 5:17 pm

I don't particularly want a forum, I just want to write one from scratch; to learn from the process obviously, not because I enjoy pointless endeavours ... I think a forum is a good project because it consists ( or can consist ) of a relatively large variety of functions and efficiency, accessibility, format, security, etc are major considerations. It just seems to me to be the perfect assignment.

I wouldn't claim to be adept but I do know bits and pieces, I'm pretty sure that with a few peeks at a reference now and again I could write it myself but without a purpose or content it tends to get a bit boring; I guess I could set up a personal website but I have nothing worth saying here on a free forum, I'm definitely not wasting the hosting charge. Making it a team project ( even if it is just writing it ) would add an incentive for me ( yes, the idea was born out of pretty selfish reasoning ) but since nobody else is interested it's dead in the water.

Since I am the only one I suppose I'm allowed to ask ... An area where I could probably really use a friendly piggyback up mt. Everest is Assembly. You can teach me that instead if you like?

Back to top Go down
Spellarella
Lifer
Lifer
avatar

Posts : 3905
Join date : 2009-08-16
Location : Peeking out of a drain.

PostSubject: Re: Understanding SQL commands and codes.   Mon Feb 14, 2011 7:59 am

.tUrniP wrote:
I don't particularly want a forum, I just want to write one from scratch; to learn from the process obviously, not because I enjoy pointless endeavours ... I think a forum is a good project because it consists ( or can consist ) of a relatively large variety of functions and efficiency, accessibility, format, security, etc are major considerations. It just seems to me to be the perfect assignment.

I wouldn't claim to be adept but I do know bits and pieces, I'm pretty sure that with a few peeks at a reference now and again I could write it myself but without a purpose or content it tends to get a bit boring; I guess I could set up a personal website but I have nothing worth saying here on a free forum, I'm definitely not wasting the hosting charge. Making it a team project ( even if it is just writing it ) would add an incentive for me ( yes, the idea was born out of pretty selfish reasoning ) but since nobody else is interested it's dead in the water.

Since I am the only one I suppose I'm allowed to ask ... An area where I could probably really use a friendly piggyback up mt. Everest is Assembly. You can teach me that instead if you like?


The coding for creating a forum from scratch is vast and complicated. Just one syntax error can screw up the whole program. A forum can be created in the following languages, perl,php,asp,cgi and others which are right for writing such a large application which you will have to learn. Php being open source is most commonly used.

Personally, Unless you are planning on selling your own forum creation. I'd download a phpbb forum and customize the script. Don't hold me to it but I think simpleachines also have a forum script you can tinker with.

A free phpbb forum is basic, however you can mod it colour and style it etc. But, unless you have a host you can't tinker much if its provided by the free forum brigade. Some do let you to an extent tinker but he business end as in the database is off limits. Hosting can vary some pennies some expensive but it gives you the ability to tinker from the SQL end of things.

What you could focus on, and there is a need for it, is customising the style of the forums, as in colours, specific graphics etc. That is a good way to get the feel for how the coding works. I can give you CSS for php and invison and probably let you looses on a' free' invison forum so you can customise its style and give you some mod codes it. .

This tutorial below might help you. It's aimed at beginner levels, not that computer language is ever easy.

TutsToaster creating a forum from scratch .

Assembly? What are you wanting to assemble, flat packed wardobes or? lol!
Back to top Go down
.tUrniP
Lifer
Lifer
avatar

Posts : 910
Join date : 2009-08-13

PostSubject: Re: Understanding SQL commands and codes.   Mon Feb 14, 2011 2:18 pm

I use my home server for tinkering, that's not a problem, and I do have a PHPBB forum, among other things, on it that I play with. PHPBB specifically is well set out and well commented which makes it an ideal reference but just messing with someone else's script is only good up to a point.

I'm mostly interested in the backend mechanics; that's not to say that I'm totally disinterested in all things client side, after all the user interface is just as much a part of the package, but as a programmer I think you'll understand. Having said that, Html5 and CSS3 seem to promise some interesting developments.

Anyway, I'll just keep messing about on my server. Thanks for the link, it looks quite interesting. Also, I may post bits and pieces at some stage and ask you to audit it if I may.

As for Assembly, I guess MASM, FASM, TASM - IA32 type stuff. I was only half serious though.

Out of interest, which languages would you say you know?
Back to top Go down
Spellarella
Lifer
Lifer
avatar

Posts : 3905
Join date : 2009-08-16
Location : Peeking out of a drain.

PostSubject: Re: Understanding SQL commands and codes.   Mon Feb 14, 2011 2:32 pm

.tUrniP wrote:
I use my home server for tinkering, that's not a problem, and I do have a PHPBB forum, among other things, on it that I play with. PHPBB specifically is well set out and well commented which makes it an ideal reference but just messing with someone else's script is only good up to a point.

I'm mostly interested in the backend mechanics; that's not to say that I'm totally disinterested in all things client side, after all the user interface is just as much a part of the package, but as a programmer I think you'll understand. Having said that, Html5 and CSS3 seem to promise some interesting developments.

Anyway, I'll just keep messing about on my server. Thanks for the link, it looks quite interesting. Also, I may post bits and pieces at some stage and ask you to audit it if I may.

As for Assembly, I guess MASM, FASM, TASM - IA32 type stuff. I was only half serious though.

Out of interest, which languages would you say you know?

The older languages, and some new ones. I now stay the client side so my language knowledge has probably slipped I haven't had a need touse them and with most things use or lose it. I started in the 70's, by the 90's I'd turned away acutal programming and that side and switched to client end and the pretty's. I'll have to go dig up some sawdust and see what I'm still fluent with. Binery is probably the only one I might be fluent in, as I adored both it's simplicity and complexity. I also like triganomtry and hate maths so that sums me up. lol!

As for your assembly, it all depends on what you want it to translate for you, Windows, linux etc. If I recall, out of the bunch, and I really am seriously woolly here, Tasm is not used anymore not saying its defunct. That said some open sources make compliers to bring the relics back to usefulness. Off the top of my head and I could be completely wrong here, I'd say MASM or GOASM(?) is the best for use open sources like php.

IA32 no idea I am assuming its intel whether its pentium or celeron instruction I can't remember.

As you have your own server, and have a copy of pHPBB, set that up and then take it apart so you can see the main veins. From there once you worked out the main skeleton and how it functions, write your own code but aim to simplfy it. Problem with most forum coding is:

a) the space it needs, andthe client end space used up, bulky forums eat into HD space of hosting etc.
b) the resources it needs, some forums are power hungry etc
c) Security, how easy it is to interfere and insert coding to alter(as in hack/crack) it etc
d) The stablity, as in if you mod PHPBB it can cause the forum structure to weaken.
e) Customisation, the easier it can be done by the general public the greater the need for it is.


PHPBB for all its bonus's falls flat on many levels it's also the most prone to hacking. Invision is lovely, fairly stable but very bulky. Vbulletin is a nightmare for gltiching and a resource hog.


All I would advise is, start with one thing and learn it fully, be it a computer language, database, server or other. There are resources out there as well as dedicated forums. Base what you have around you to practise with, that is a must, and concentrate on those areas. Once you can comprehend those then branch out into other areas. The dead languages such as Colbalt, fortrans even basic still are useful to know so never discount an outdated or replaced language. The opensource area is alive with resources and those who are more hand on than me. I retired for programming so don't have a fully updated knowledge. Bits n bobs may come my way, when I have had to ue them to set up a forum or correct a mistake in odd bits of copied coding or when a coder has gone blind and can't see the syntax error. Programming can make you go codeblind to mistakes.

I'd recomend you use the active resources out there. As I have said,I like the pretty side as in CSS etc and that area I'm more active in.



Back to top Go down
.tUrniP
Lifer
Lifer
avatar

Posts : 910
Join date : 2009-08-13

PostSubject: Re: Understanding SQL commands and codes.   Tue Feb 15, 2011 6:18 am

01000010 01001001 01001110 01000001 01010010 01011001 00100000 01101001 01110011 00100000 01110001 01110101 01101001 01110100 01100101 00100000 01101001 01101110 01110100 01100101 01110010 01100101 01110011 01110100 01101001 01101110 01100111 00101110 00100000 01001001 01110100 00100111 01110011 00100000 01100110 01110101 01101110 00100000 00100110 00100000 01100101 01100001 01110011 01111001 00100000 01110100 01101111 00100000 write little messages but I can't imagine actually writing code in it.

lol! Maybe I'll edit this post when I can be bothered to translate the rest.

I'm not sure what you mean about MASM and GOASM but since I already have MASM and a c2d processor in this machine which runs on the IA32 - Intel's 32bit, x86 architecture - I think MASM may be the best to use.

Anyway, once again, thanks for the pointers.

Back to top Go down
.tUrniP
Lifer
Lifer
avatar

Posts : 910
Join date : 2009-08-13

PostSubject: Re: Understanding SQL commands and codes.   Tue Feb 15, 2011 3:21 pm

Okay, so I think I'll write a binary translator, might be fun and it'll be much quicker than translating manually. I'll edit this post with the source when I'm done so that you can make suggestions, if you would?

grin

EDIT:

Code:


<html>
   <head>
   
      <title>TEXT 2 BINARY</title>
      
         <style type="text/css">
     
                  #body {
               background-color:#161616;
               font-family:tahoma, arial, monospace;
               color:#ffffff;
                  }
               
                  #container {
               background-color:#000000;
               border-top-left-radius:50px;
               border-bottom-right-radius:50px;
               min-width:650px;
               min-height:500px;
               position:absolute;
               left:10%;
               top:10%;
               bottom:10%;
               right:10%;
                  }
               
                  #t2b {
               position:absolute;
               left:10%;
               top:10%;
                  }
               
                  #b2t {
               position:absolute;
               bottom:10%;
               right:10%;
                  }
               
                  #display {
               baackgroud-color:#ffffff;
               border:1px solid white;
               position:absolute;
               left:10%;
               top:30%;
               bottom:30%;
               right:10%;
                  }
                  
                                 
         </style>
         
      </head>
      
      <body id="body">
         
         <div id="container">   
         
         <div id="t2b">   
                           
            <h1>  Text2Binary ~ </h1>
            
               <form action="" method="post">
               <input type="text" name="text"/>
               <input type="submit"/>
               </form>
   
         </div>         
         
         <div id="display">
         
            
<?php

   if(isset($_POST['text']))
   {
   $text = $_POST["text"];
   $txt = str_split($text);
       
      foreach ($txt as $character) {
            $dec=ord($character);
            $bin=decbin($dec);
            $bin = substr("00000000",0,8 - strlen($bin)) . $bin;
            print($bin. " ");
         }
   }
   elseif(isset($_POST['binary']))
   {
   $binary = $_POST["binary"];
   $binary = str_replace(' ','',$binary);
   $binx = str_split($binary, 8);
      
      foreach ($binx as $binstring) {
            $decx=bindec($binstring);
            $char=chr($decx);
            print($char);
         }
   }

?>
            
            
         </div>
   
         <div id="b2t">   
                  
               <form action="" method="post">
               <input type="text" name="binary"/>
               <input type="submit" />
               </form>
         
            <h1> ~ Binary2Text  </h1>
         </div>
         
      </body>
</html>

Back to top Go down
Spellarella
Lifer
Lifer
avatar

Posts : 3905
Join date : 2009-08-16
Location : Peeking out of a drain.

PostSubject: Re: Understanding SQL commands and codes.   Tue Feb 15, 2011 3:37 pm

.tUrniP wrote:


write little messages but I can't imagine actually writing code in it.

lol! Maybe I'll edit this post when I can be bothered to translate the rest.

I'm not sure what you mean about MASM and GOASM but since I already have MASM and a c2d processor in this machine which runs on the IA32 - Intel's 32bit, x86 architecture - I think MASM may be the best to use.

Anyway, once again, thanks for the pointers.


GOASM is a compact version, and is for 32 bit . Stick wit h MASM as you have it. Saves getting overly complex.
MASM dedicated forum


lol! After a while you hear the devil swearing when you play a U2 song backwards devil lmao

And you made a mistake,
Quote :
BINARY is quite interesting. It's fun &amp easy to .
Amp = Error. wink lol!
2 ways to write, as shown below.


Code:
01010100 01101000 01100101 00100000 01110100 01110010 01101001 01100011 01101011 00100000 01110100 01101111 00100000 01110010 01100101 01101101 01100101 01101101 01100010 01100101 01110010 00100000 01101001 01110011 00100000 01110100 01101000 01100001 01110100 00100000 01100010 01101001 01101110 01100101 01110010 01111001 00100000 01100100 01101111 01100101 01110011 00100000 01101110 01101111 01110100 00100000 01110010 01100101 01100011 01101111 01100111 01101110 01101001 01110011 01100101 00100000 01100001 01101100 01101100 00100000 01100111 01110010 01100001 01101101 01101101 01100001 01110010 00100000 01111001 01101111 01110101 00100000 01110011 01101001 01101101 01110000 01101100 01111001 00100000 01110111 01110010 01101001 01110100 01100101 00100000 01110111 01101000 01100001 01110100 00100000 01111001 01101111 01110101 00100000 01110111 01100001 01101110 01110100 00100000 01100001 01101110 01100100 00100000 01101001 01110100 00100000 01110111 01110010 01101001 01110100 01100101 01110011 00100000 01110100 01101000 01100101 00100000 01100011 01101111 01100100 01100101 00001101 00001010 00001101 00001010 00001101 00001010 01010011 01110000 01100101 01101100 01101100 01101001 01101110 01100111 00100000 01101101 01101001 01110011 01110100 01100001 01101011 01100101 01110011 00100000 01101001 01110011 00100000 01100001 01101110 01101111 01110100 01101000 01100101 01110010 00100000 01100010 01100001 01100100 00100000 01100001 01110010 01100101 01100001 00100000 01110100 01101111 00100000 01100110 01101001 01101110 01100100 00100000 01111001 01101111 01110101 01110010 01110011 01100101 01101100 01100110 00100000 01101011 01101110 01100101 01100101 00100000 01100100 01100101 01100101 01110000 00100000 01101001 01101110 00100000 01100001 01101110 01100100 00100000 01110111 01100001 01100100 01101001 01101110 01100111 00100000 01110100 01101000 01110010 01101111 01110101 01100111 01101000 00100000 01110100 01101111 00100000 01100110 01101001 01101110 01100100 00100000 01110100 01101000 01100101 00100000 01100101 01110010 01110010 01101111 01110010 00100000 01010011 01101111 00100000 01100001 01101100 01110100 01101000 01101111 01110101 01100111 01101000 00100000 01100010 01101001 01101110 01100101 01110010 01111001 00100000 01101001 01110011 00100000 01100011 01101111 01101110 01110011 01101001 01100100 01100101 01110010 01100101 01100100 00100000 01100001 00100000 01110011 01101001 01101101 01110000 01101100 01100101 00100000 01100011 01101111 01100100 01100101 00100000 01101001 01110100 00100000 01101001 01110011 00100000 01101001 01101110 00100000 01100110 01100001 01100011 01110100 00100000 01100001 00100000 01110110 01100101 01110010 01111001 00100000 01100011 01101111 01101101 01110000 01101100 01101001 01100011 01100001 01110100 01100101 01100100 00100000 01101100 01100001 01101110 01100111 01110101 01100001 01100111 01100101 00100000 01100001 01101110 01100100 00100000 01110100 01101001 01101101 01100101 00100000 01100011 01101111 01101110 01110011 01110101 01101101 01101001 01101110 01100111 00100000 00001101 00001010 00001101 00001010 01000101 01110011 01110000 01100101 01100011 01101001 01100001 01101100 01101100 01111001 00100000 01101001 01100110 00100000 01111001 01101111 01110101 00100000 01101000 01100001 01110110 01100101 00100000 01101111 01110110 01100101 01110010 00100000 01100001 00100000 01110000 01100001 01100111 01100101 00100000 01101111 01100110 00100000 01101001 01101110 01110011 01110100 01110010 01110101 01100011 01110100 01101001 01101111 01101110 01110011 00100000 01100001 01101110 01100100 00100000 01111001 01101111 01110101 00100000 01101000 01100001 01110110 01100101 00100000 01101101 01100001 01100100 01100101 00100000 01101111 01101110 01100101 00100000 01101101 01101001 01110011 01110100 01100001 01101011 01100101 00001101 00001010 00001101 00001010 01000010 01100001 01101110 01100111 00100000 01100111 01101111 01100101 01110011 00100000 01111001 01101111 01110101 01110010 00100000 01110000 01110010 01101111 01100111 01110010 01100001 01101101 00100000 01100001 01101110 01100100 00100000 01100111 01110010 01100101 01111001 00100000 01100111 01101111 01100101 01110011 00100000 01111001 01101111 01110101 01110010 00100000 01101000 01100001 01101001 01110010


or
Code:
0110001101101111011011100111010001101001011011100110111101110101011100110010000001101100011010010110111001100101

The latter is mind blowing and hair pulling when you make one mistake, let alone hundreds
Back to top Go down
Spellarella
Lifer
Lifer
avatar

Posts : 3905
Join date : 2009-08-16
Location : Peeking out of a drain.

PostSubject: Re: Understanding SQL commands and codes.   Tue Feb 15, 2011 4:04 pm

.tUrniP wrote:
Okay, so I think I'll write a binary translator, might be fun and it'll be much quicker than translating manually. I'll edit this post with the source when I'm done so that you can make suggestions, if you would?

grin

EDIT:

Code:


<html>
   <head>
   
      <title>TEXT 2 BINARY</title>
      
         <style type="text/css">
     
                  #body {
               background-color:#161616;
               font-family:tahoma, arial, monospace;
               color:#ffffff;
                  }
               
                  #container {
               background-color:#000000;
               border-top-left-radius:50px;
               border-bottom-right-radius:50px;
               min-width:650px;
               min-height:500px;
               position:absolute;
               left:10%;
               top:10%;
               bottom:10%;
               right:10%;
                  }
               
                  #t2b {
               position:absolute;
               left:10%;
               top:10%;
                  }
               
                  #b2t {
               position:absolute;
               bottom:10%;
               right:10%;
                  }
               
                  #display {
               baackgroud-color:#ffffff;
               border:1px solid white;
               position:absolute;
               left:10%;
               top:30%;
               bottom:30%;
               right:10%;
                  }
                  
                                 
         </style>
         
      </head>
      
      <body id="body">
         
         <div id="container">   
         
         <div id="t2b">   
                           
            <h1>  Text2Binary ~ </h1>
            
               <form action="" method="post">
               <input type="text" name="text"/>
               <input type="submit"/>
               </form>
   
         </div>         
         
         <div id="display">
         
            
<?php

   if(isset($_POST['text']))
   {
   $text = $_POST["text"];
   $txt = str_split($text);
       
      foreach ($txt as $character) {
            $dec=ord($character);
            $bin=decbin($dec);
            $bin = substr("00000000",0,8 - strlen($bin)) . $bin;
            print($bin. " ");
         }
   }
   elseif(isset($_POST['binary']))
   {
   $binary = $_POST["binary"];
   $binary = str_replace(' ','',$binary);
   $binx = str_split($binary, 8);
      
      foreach ($binx as $binstring) {
            $decx=bindec($binstring);
            $char=chr($decx);
            print($char);
         }
   }

?>
            
            
         </div>
   
         <div id="b2t">   
                  
               <form action="" method="post">
               <input type="text" name="binary"/>
               <input type="submit" />
               </form>
         
            <h1> ~ Binary2Text  </h1>
         </div>
         
      </body>
</html>


stop You have a rogue fullstop, and a couple of other minor errors. But its showing functionability. clap
Back to top Go down
.tUrniP
Lifer
Lifer
avatar

Posts : 910
Join date : 2009-08-13

PostSubject: Re: Understanding SQL commands and codes.   Tue Feb 15, 2011 4:50 pm

Could you show me where the errors are please?

Apart from the missing doctype ( which was just laziness ) I can't seem to find any; even using the find function I can't find the 'rogue full stop'.

The binary is only a translation of plain text, what's wrong with ampersand?

And why would you ever NOT divide it into byte size chunks, that's pretty masochistic...
Back to top Go down
Spellarella
Lifer
Lifer
avatar

Posts : 3905
Join date : 2009-08-16
Location : Peeking out of a drain.

PostSubject: Re: Understanding SQL commands and codes.   Wed Feb 16, 2011 4:17 pm

.tUrniP wrote:
Could you show me where the errors are please?

Apart from the missing doctype ( which was just laziness ) I can't seem to find any; even using the find function I can't find the 'rogue full stop'.

The binary is only a translation of plain text, what's wrong with ampersand?

And why would you ever NOT divide it into byte size chunks, that's pretty masochistic...

'amp', erros send the program into chaos. Its little things likethat that can render a whole program useless.

Its actually easier to write binary code without spacing, spacing is another command added inot the inery code. In some cases that extra space is all that can topple a program. But you are right, writing it is fun reading it for the error is sadistic.





Back to top Go down
.tUrniP
Lifer
Lifer
avatar

Posts : 910
Join date : 2009-08-13

PostSubject: Re: Understanding SQL commands and codes.   Wed Feb 16, 2011 5:13 pm

Wait, what...?

So you mean that you translated 00100110 to & amp instead of just &? If so then I can't imagine how, did you use a binary to text translator? ... I think you've made a mistake || Maybe I've just completely misunderstood. Could you possibly explain binary to me? Perhaps give the binary data of a .jpg and explain how that translates to pixels on a screen - the algorithm, etc, etc...

As for my translator page, I'm quite concerned with the errors ... ? As I said, I can't find them but now that you've said there are some it will bug me until I can fix them.

Back to top Go down
Spellarella
Lifer
Lifer
avatar

Posts : 3905
Join date : 2009-08-16
Location : Peeking out of a drain.

PostSubject: Re: Understanding SQL commands and codes.   Thu Feb 17, 2011 3:56 pm

.tUrniP wrote:
Wait, what...?

So you mean that you translated 00100110 to & amp instead of just &? If so then I can't imagine how, did you use a binary to text translator? ... I think you've made a mistake || Maybe I've just completely misunderstood. Could you possibly explain binary to me? Perhaps give the binary data of a .jpg and explain how that translates to pixels on a screen - the algorithm, etc, etc...

As for my translator page, I'm quite concerned with the errors ... ? As I said, I can't find them but now that you've said there are some it will bug me until I can fix them.


Unlocked it myself , do they even do translators for binery, I thought that was what you were doing? amp= a spacing error such as , ; and such. I know it because I've had a few amp errors myself. lol!


As for your bit, I'm searching another persons coding for errors as it won't run correctly. So far I've tallied 180 errors, mainly silly errors. But the coders gone blind so it needs new eyes to run red rings around them. When I've done theirs I'll do yours.
Back to top Go down
.tUrniP
Lifer
Lifer
avatar

Posts : 910
Join date : 2009-08-13

PostSubject: Re: Understanding SQL commands and codes.   Thu Feb 17, 2011 5:01 pm

Yeah, I wrote my binary to text translator because translating my message manually took too long ( truth be told I got distracted by V and went off to finish watching it ) but others exist. It wasn't a particularly original idea. For example, this one does binary, hex, base64, decimal and text ( ascii ).

I just can't seem to understand what you are talking about though; I have no idea what "spacing error" means and I have no idea what "amp" is or where it came from. I'm sorry but you really are going to have to explain it to me.

As for validating my PHP, and just in general really, thanks for your time ( already spent and to come ).

grin
Back to top Go down
.tUrniP
Lifer
Lifer
avatar

Posts : 910
Join date : 2009-08-13

PostSubject: Re: Understanding SQL commands and codes.   Wed Feb 23, 2011 4:33 am

Do you have any experience with the windows API and C++?

I started writing a little windows app ( to serve as a starting point for a MadDogz project ) soon after suggesting the web project but lost interest when nobody seemed at all interested in even that. I think that I will continue with it on my own anyway though ( along side the web stuff ) but if you do have any experience it would be nice to know that I can impose on you more so with further questions.
Back to top Go down
Spellarella
Lifer
Lifer
avatar

Posts : 3905
Join date : 2009-08-16
Location : Peeking out of a drain.

PostSubject: Re: Understanding SQL commands and codes.   Wed Feb 23, 2011 3:46 pm

Now that's thrown me, Can't say I remember using either, might be brief intro's only. I'll have a look, it might trigger some ark rusing program in my memeory banks.
Back to top Go down
.tUrniP
Lifer
Lifer
avatar

Posts : 910
Join date : 2009-08-13

PostSubject: Re: Understanding SQL commands and codes.   Thu Mar 17, 2011 11:53 am

I completely forgot about this and haven't really done much coding recently, particularly for either of the projects here ( which aren't really projects here because nobody cares but you know what I mean ).

I wish it didn't but it bugs me that even after looking over my PHP code again just now I still can't find the mistakes you mentioned and still don't understand the whole binary thing. Nevermind, I guess...

Anyway, the little Windows app I made doesn't actually do anything yet ( it's basically just a clone of notepad ) but it's this sort of stuff ( if you'd care for an example to jog your memory ) -
Code:


Took it out.




Last edited by .tUrniP on Sun May 08, 2011 9:24 am; edited 1 time in total
Back to top Go down
Spellarella
Lifer
Lifer
avatar

Posts : 3905
Join date : 2009-08-16
Location : Peeking out of a drain.

PostSubject: Re: Understanding SQL commands and codes.   Wed Mar 30, 2011 3:41 pm

.tUrniP wrote:
Could you show me where the errors are please?

Apart from the missing doctype ( which was just laziness ) I can't seem to find any; even using the find function I can't find the 'rogue full stop'.

The binary is only a translation of plain text, what's wrong with ampersand?

And why would you ever NOT divide it into byte size chunks, that's pretty masochistic...

I'm stunned. I know there is an error and the error shows up as a rogue . but where it is I am clueless. Only thing i can think of is what I used is showing an error up, so wil try another program and see if that show the rogue . or not.
Back to top Go down
.tUrniP
Lifer
Lifer
avatar

Posts : 910
Join date : 2009-08-13

PostSubject: Re: Understanding SQL commands and codes.   Thu Mar 31, 2011 6:35 pm

Once again my brain has clearly decided that understanding is just far too much effort; I can only apologise. I am myself rather annoyed at my brain's disobedience; A 'little chat' may be in order but I can only imagine it grunting unintelligibly and wandering off and so instead I think it may be best to take my brain and myself off to bed and try for the sleep it quite probably craves, and I most definitely do. The only trouble being that my brain is an arse, delighting in keeping me up for enough sequential days to see all the pretty colours and bring on the light and airy 'swooshy head' but whining endlessly when it gets a bit too much, like a child on a roller-coaster. FML.

All I can say is that my PHP script does contain fullstops as concatenation operators and will 'translate' fullstops ( and other punctuation ) to and from their binary value - both are quite intentional. Other than that I cannot find nor produce fullstops, erroneous or otherwise.

The Binary message I wrote also contains a fullstop ( and other punctuation ) but is literally just a conversion from decimal to binary ( base10 to base2 ) and is plain text. My PHP script translates it as I intended. I'm not sure which rules I'm breaking there.

My C++/WinAPI program is crap. A quick glance at the syntax should be enough to jog the memory whereas actual reading will probably result in a relatively quick but rather painful death for that memory; A death not dissimilar to being hit by a bus as it crosses the road towards the local park.

What on earth have you used?

Back to top Go down
Sponsored content




PostSubject: Re: Understanding SQL commands and codes.   

Back to top Go down
 
Understanding SQL commands and codes.
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Unknown Sten Manufacturer Codes...
» Breaking German Codes Real Reason for 1942 Dieppe Raid
» CSS codes for customizing phpBB3 forums
» HTML Codes!
» CSS Codes

Permissions in this forum:You cannot reply to topics in this forum
 :: Bits For PC's :: PC Problems and solutions.-
Jump to: