|
 |
|
 |
 |
02-11-2008, 12:42 PM
|
#1 (permalink)
|
|
Regular Contributor
Join Date: Oct 2004
Posts: 192
|
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
__________________
|
|
|
02-12-2008, 06:55 AM
|
#2 (permalink)
|
|
Newbie
Join Date: Jun 2002
Location: Denmark
Posts: 1,680
|
Well, if it's linked with PHP, then you need to know that function, aswell as what to query for.
|
|
|
02-13-2008, 09:18 AM
|
#3 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,397
|
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
|
|
|
02-13-2008, 01:36 PM
|
#4 (permalink)
|
|
Senior Contributor
Join Date: Mar 2005
Posts: 635
|
it all will not work if you don't do mysqli_connect() first
__________________

UT: Ultra-kill... God like!
|
|
|
02-13-2008, 05:28 PM
|
#5 (permalink)
|
|
Java fanboy
Join Date: Aug 2003
Posts: 1,114
|
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.
|
|
|
02-13-2008, 07:40 PM
|
#6 (permalink)
|
|
Regular Contributor
Join Date: Oct 2004
Posts: 192
|
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?
__________________
|
|
|
02-13-2008, 10:29 PM
|
#7 (permalink)
|
|
Java fanboy
Join Date: Aug 2003
Posts: 1,114
|
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.
|
|
|
02-14-2008, 07:17 AM
|
#8 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,397
|
Quote:
Originally Posted by falsepride
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
|
|
|
02-14-2008, 07:37 PM
|
#9 (permalink)
|
|
Regular Contributor
Join Date: Oct 2004
Posts: 192
|
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
__________________
|
|
|
02-16-2008, 04:29 AM
|
#10 (permalink)
|
|
Senior Contributor
Join Date: Mar 2005
Posts: 635
|
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!
|
|
|
02-17-2008, 11:32 AM
|
#11 (permalink)
|
|
Regular Contributor
Join Date: Oct 2004
Posts: 192
|
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
__________________
|
|
|
02-17-2008, 01:30 PM
|
#12 (permalink)
|
|
Regular Contributor
Join Date: Oct 2004
Posts: 192
|
wooo! fixed my problems, now im querying and creating tables and inserting rows like a champ.
__________________
|
|
|
02-17-2008, 07:49 PM
|
#13 (permalink)
|
|
Java fanboy
Join Date: Aug 2003
Posts: 1,114
|
FYI, a backtick ( ` ) looks a lot like a single quote, ( ' ), and usually has a special meaning, depending on the language you're using.
|
|
|
02-19-2008, 09:54 AM
|
#14 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,397
|
Quote:
Originally Posted by falsepride
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
|
|
|
02-23-2008, 07:56 PM
|
#15 (permalink)
|
|
Regular Contributor
Join Date: Oct 2004
Posts: 192
|
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
__________________
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -8. The time now is 07:53 AM.
|
Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle
|
 |
|