Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Go Back   Code Forums > Application and Web Development > Everything SQL ( MySQL, MSSQL, DB2, Postgre, Oracle, etc...)
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 02-11-2008, 12:42 PM   #1 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 192
falsepride is on a distinguished road
is 99% of mysql mysql_query?

i've been reading some tutorials on mysql never using it before and it literally feels like mysql_query is the only function one needs to use to successfully program using mysql
__________________
falsepride is offline   Reply With Quote
Old 02-12-2008, 06:55 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,680
redhead is on a distinguished road
Well, if it's linked with PHP, then you need to know that function, aswell as what to query for.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 02-13-2008, 09:18 AM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,397
sde is on a distinguished road
you may need some other functions to get the results from a select like: mysql_fetch_array, mysql_fetch_assoc, or mysql_fetch_object, depending on the format you prefer.

another useful function may be mysql_num_rows() to get the number of results found in your query.

using it is the best way to just start understanding it.
__________________
testing 1 2 3
sde is online now   Reply With Quote
Old 02-13-2008, 01:36 PM   #4 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 635
DJMaze is on a distinguished road
it all will not work if you don't do mysqli_connect() first
__________________

UT: Ultra-kill... God like!
DJMaze is offline   Reply With Quote
Old 02-13-2008, 05:28 PM   #5 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,114
Belisarius is on a distinguished road
You might also want to look at a database abstraction class, like DB or MDB2. Especially if you're going to do any object-oriented programming.
__________________
GitS
Belisarius is offline   Reply With Quote
Old 02-13-2008, 07:40 PM   #6 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 192
falsepride is on a distinguished road
well in the past all of my codes have been rather sloppy. all flat file, all using functions involving md arrays. in small amounts it was easy to follow, but once scripts started getting longer, it was hard to detect errors, and fix them.

i read 3/4 of a c++ book(lost track because of school), but it did give me a good enough understanding of programing using oop.

i'm designing a site for the fish store i work at. we've hired 3 guys in the past to do it, but none actually did anything. we've recently just rehired someone, but i personally know, that how long its taking him and the temp page he put up, that i can do a better job. so i just started scripting it out, i'd like to get it done in a month, present it to my boss and tell him to just get rid of the other guy.

my objectives are rather simple on the php/mysql side. its a fish store. i need to make it so managers can post new fish orders so costumers can be alerted. a simple login system for managers to do so. have a sql table for people signed up for the mailing list, and have an email sent out to them of the order. and also have a 'full member' table. where people can build a fish 'wish list' so if we find a certain species is in high demand. order it. then post the order up. in this case the costumer would get 2 emails, one of the whole order. and one alerting them a fish on their wish list has arrived, then remove it off their list. and a few other things

i was planning on having sql tables for
manager info
order arivals
fish species
mailing list
full member

im guessing to do this, im not going to need to learn all of mysql, only a rather small portion. any suggestions would be great on how youd go about things differently.

and a quick sql question, when i try to make a field in a table a primary i got a length error or something. i was using phpmyadmin on awardspace. the free subdomain im setting my demo up on. anyone shed any light on my error?
__________________
falsepride is offline   Reply With Quote
Old 02-13-2008, 10:29 PM   #7 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,114
Belisarius is on a distinguished road
You can setup Apache/MySQL/PHP on your home Windows box - it'll give you more direct control for development. I'd suggest it - it's a lot easier to play around when everything is local and you can see the effects of changes right away.

I'd do that, then attempt to create your database. You can use the command line for direct feedback. If it fails, let us know what it says and the command you used.
__________________
GitS
Belisarius is offline   Reply With Quote
Old 02-14-2008, 07:17 AM   #8 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,397
sde is on a distinguished road
Quote:
Originally Posted by falsepride View Post
when i try to make a field in a table a primary i got a length error or something.
be more specific.
__________________
testing 1 2 3
sde is online now   Reply With Quote
Old 02-14-2008, 07:37 PM   #9 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 192
falsepride is on a distinguished road
Code:
CREATE TABLE `managers` ( `name` TEXT NOT NULL , `password` TEXT NOT NULL , `webmaster` BOOL NOT NULL , PRIMARY KEY ( `name` ) ) TYPE = MYISAM
#1170 - BLOB/TEXT column 'name' used in key specification without a key length
__________________
falsepride is offline   Reply With Quote
Old 02-16-2008, 04:29 AM   #10 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 635
DJMaze is on a distinguished road
Wow you definably need to learn it.

Code:
CREATE TABLE managers ( id INT NOT NULL AUTO_INCREMENT, name VARCHAR(50) NOT NULL , password VARCHAR(32) NOT NULL , webmaster TINYINT NOT NULL DEFAULT 0, PRIMARY KEY (id) ) TYPE = MYISAM; CREATE UNIQUE INDEX i_m_name ON managers (name);
Never use backticks, it is only supported by MySQL and allows you to create bad field names.
With bad fieldnames you can create fields with reserved words like: delete, create, default, key, etc.
__________________

UT: Ultra-kill... God like!
DJMaze is offline   Reply With Quote
Old 02-17-2008, 11:32 AM   #11 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 192
falsepride is on a distinguished road
that query was generated using phpMyAdmin. no idea what backticks are. anyway i made my table using

Code:
CREATE TABLE `managers` ( `name` VARCHAR( 50 ) NOT NULL , `password` VARCHAR( 50 ) NOT NULL , `webmaster` ENUM( 'false', 'true' ) NOT NULL , PRIMARY KEY ( `name` ) ) TYPE = MYISAM ;
now i am having trouble querying my table,

Code:
$result = mysql_query("SELECT * FROM managers WHERE name=$username");
where $username is provided end user from a form. i tried replacing $username with an a constant value, and still got no results
__________________
falsepride is offline   Reply With Quote
Old 02-17-2008, 01:30 PM   #12 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 192
falsepride is on a distinguished road
wooo! fixed my problems, now im querying and creating tables and inserting rows like a champ.
__________________
falsepride is offline   Reply With Quote
Old 02-17-2008, 07:49 PM   #13 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,114
Belisarius is on a distinguished road
FYI, a backtick ( ` ) looks a lot like a single quote, ( ' ), and usually has a special meaning, depending on the language you're using.
__________________
GitS
Belisarius is offline   Reply With Quote
Old 02-19-2008, 09:54 AM   #14 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,397
sde is on a distinguished road
Quote:
Originally Posted by falsepride View Post
wooo! fixed my problems, now im querying and creating tables and inserting rows like a champ.
see, now that you're using it, aren't flat files more painful to work with?
__________________
testing 1 2 3
sde is online now   Reply With Quote
Old 02-23-2008, 07:56 PM   #15 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 192
falsepride is on a distinguished road
true story man, mysql definitely makes life easier. so did going about things in an object oriented mindset. much easier to change as my ideas change
__________________
falsepride is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL Replication / Failover idx Everything SQL ( MySQL, MSSQL, DB2, Postgre, Oracle, etc...) 2 02-23-2005 07:22 PM
Converting MySQL Timestamp to a Unix Timestamp sde PHP 0 02-16-2003 11:59 PM
and on to mysql .. sde Linux / BSD / OS X 2 01-18-2003 07:39 PM


All times are GMT -8. The time now is 07:53 AM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle