home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 3157
Discussions: 188,374, Posts: 2,243,437, Members: 232,603
Old May 6th, 2002, 03:58 PM   Digg it!   #1 (permalink)
Ultimate Member
 
ChoaticWhisper's Avatar
 
Join Date: Oct 2001
Location: Alabama
Posts: 1,309
Send a message via AIM to ChoaticWhisper
Song Request Software- Followup Thread

First I hope everyone doesnt mind me posting a followup thread.
Now in this thread I posted I wanted something to send a song request to a server.
Well I found nothing so I started learning what I could of PHP and MySQL, Worked on it about 2 days.
If you can improve on it please do also if you do would you let me know what you did.
This Link is a Direct Download of what I came up with.

ChoaticWhisper is offline   Reply With Quote
Old May 6th, 2002, 07:12 PM     #2 (permalink)
Ultimate Member
 
ChoaticWhisper's Avatar
 
Join Date: Oct 2001
Location: Alabama
Posts: 1,309
Send a message via AIM to ChoaticWhisper
Oh yeah If someone could help me with the search part.

I need it to search a word and print out the data in the same way that it is shown like the index.php file that is relavent(sp?)

ChoaticWhisper is offline   Reply With Quote
Old May 6th, 2002, 10:14 PM     #3 (permalink)
Banned
 
qball's Avatar
 
Join Date: Oct 2001
Posts: 447
We'll work on this thread:

I just dloaded your stuff and will see if I can get it working and get back to you.

Good work??? Hope your enjoying the development.

[edit]
Hey it actually works, kinda sorta...

Took me 15 minutes to figure out why send.php doesn't work. Change:

"mysql_select_db("Form_Data");"

To:

"mysql_select_db("Song_Data");"

Also:

"mysql_query("INSERT INTO form SET
Name='$name',
Song='$song'");"

Doesn't work, try:

$query = "INSERT INTO form (name,song)
VALUES ('".$name."','".$song."')";
mysql_query($query)
or die("Could not execute query");

//Pay attention to "'" and '""

More later young jedi...
[/edit]


Last edited by qball : May 6th, 2002 at 11:11 PM.
qball is offline   Reply With Quote
Old May 7th, 2002, 12:02 AM     #4 (permalink)
Ultimate Member
 
ChoaticWhisper's Avatar
 
Join Date: Oct 2001
Location: Alabama
Posts: 1,309
Send a message via AIM to ChoaticWhisper
Quote:
Originally posted by qball
"mysql_select_db("Form_Data");"

To:

"mysql_select_db("Song_Data");"
Hmm... Well Everything I had worked fine for me, Could you explain the reason, I have the name and song-title-ID going to a different database(I guess I could just add a new table).
When I changed it it died "Could not execute query"
Quote:
Also:

"mysql_query("INSERT INTO form SET
Name='$name',
Song='$song'");"

Doesn't work, try:

$query = "INSERT INTO form (name,song)
VALUES ('".$name."','".$song."')";
mysql_query($query)
or die("Could not execute query");

//Pay attention to "'" and '""

More later young jedi...
[/edit]
ok I changed that and it still works fine, is your way more compatable or something? Is there some reason it works on mine and not what your using?

Also for some reason on my windows-apache-mysql-php box I cant get any or the variables($name) to go to the next page. What I mean is the $name and the $song doesnt get transfered to the send.php, or any other form data like that. What could be wrong?
ChoaticWhisper is offline   Reply With Quote
Old May 7th, 2002, 04:50 PM     #5 (permalink)
Banned
 
qball's Avatar
 
Join Date: Oct 2001
Posts: 447
Quote:
Hmm... Well Everything I had worked fine for me, Could you explain the reason, I have the name and song-title-ID going to a different database(I guess I could just add a new table).
That would explain why yours works, I have just one DB named song_database, which I created and then used your scripts to create two tables, form and song_database. You can use multiple DBs iffin you like, but there is no logical reason. One DB will work just fine and running queries and relating data in tables to each other is much easier using one DB. In fact you already have an implied relationship in the form table. The song column should be a songtitle column in the song database. More on this later...

Quote:
ok I changed that and it still works fine, is your way more compatable or something?
Great question, glad you picked up on this. I've seen the following syntax a few times:

INSERT INTO form
SET Name='$name',
Song='$song';

I've gotten it to work, but it's problematic (for me at least). As far as compatibility:

INSERT INTO table (col1,col2)
VALUES (val1,val2);

Explicitly states what is happening and more universal, I believe (maybe, I'm old school). See:

http://www.mysql.com/doc/I/N/INSERT.html

Quote:
Also for some reason on my windows-apache-mysql-php box I cant get any or the variables($name) to go to the next page. What I mean is the $name and the $song doesnt get transfered to the send.php, or any other form data like that. What could be wrong?
Really? I mean, huh?

Try this. Using your send.php, don't worry about inserting row, simply place:

print $name;
print $song;

At the top of the PHP tag, meaning first lines following "<?". This should merely echo back the form data from index.php.

Quote:
Is there some reason it works on mine and not what your using?
There may be, I set up mySQL so long ago, I don't recall some of the config parameters. Also, version could be different and I'm using IIS. Regardless, I often wondered why:

"('".$name."','".$song."')"; "

Needed the periods (.), but I get parse errors without???

Lastly, you asked about searching, pretty easy, try:

SELECT *
FROM song_database
WHERE songtitle LIKE '%the%';
qball is offline   Reply With Quote
Old May 7th, 2002, 05:16 PM     #6 (permalink)
Ultimate Member
 
ChoaticWhisper's Avatar
 
Join Date: Oct 2001
Location: Alabama
Posts: 1,309
Send a message via AIM to ChoaticWhisper
Quote:

That would explain why yours works, I have just one DB named song_database, which I created and then used your scripts to create two tables, form and song_database. You can use multiple DBs iffin you like, but there is no logical reason. One DB will work just fine and running queries and relating data in tables to each other is much easier using one DB. In fact you already have an implied relationship in the form table. The song column should be a songtitle column in the song database. More on this later...
Ok I will convert mine to just one DB, OK Im not sure what you mean by that last part but I will wait untill you explain.

Quote:
Great question, glad you picked up on this. I've seen the following syntax a few times:

INSERT INTO form
SET Name='$name',
Song='$song';

I've gotten it to work, but it's problematic (for me at least). As far as compatibility:

INSERT INTO table (col1,col2)
VALUES (val1,val2);

Explicitly states what is happening and more universal, I believe (maybe, I'm old school). See:

http://www.mysql.com/doc/I/N/INSERT.html
Ok After looking at it your way looks to be more understandable too, I just see a tutioral that insert data into a db that way so I used it.
Your way kinda even lets me understand where the data is going to go.

Dont worry about my stuff now working now, I downloaded foxserv and now it all works. Now I wont have to upload it to my other computer to test stuff, Plus I bought the "PHP4 Bible", So maybe that will help with some stuff.

Quote:
Lastly, you asked about searching, pretty easy, try:

SELECT *
FROM song_database
WHERE songtitle LIKE '%the%';
I will try that, I didnt think it would be that easy.
ChoaticWhisper is offline   Reply With Quote
Old May 7th, 2002, 11:16 PM     #7 (permalink)
Banned
 
qball's Avatar
 
Join Date: Oct 2001
Posts: 447
Quote:
OK Im not sure what you mean by that last part but I will wait untill you explain.
I hope I can, basically mySQL much like Oracle, DB2, Sybase, etc. are RDBMS, see:

http://searchdatabase.techtarget.com...214260,00.html

What this means (usually, I use a customer ordering a product), let's use Artist, Song, and Album, therefore more relevant. Now you intuitively already know the relationships:
Albums contain Songs
Songs are written by Artist

Simple, but what about:
Albums containing songs from various Artists (compilation)
Songs performed by various Artists (duet)
Album that has 2/more CDs.

Try doing the last three in your existing tables, uh-oh. A good schema (db tbls and relationships) will support the above and even more wacky relationships. At the very least one should be able to see that the Album table needs to relate to the Song table, else my explanation stinks...

Now, I don't want to design this schema, any more than you and I doubt we have to. Someone has already done this. As inferred earlier www.cdnow.com already is using one and even home users have done this stuff for album and mp3 collections. We just need to find one that will share (perhaps post in Database section?). Think of this a WIP, unless you want to explore the dark depth of DB design.
qball is offline   Reply With Quote
Old May 7th, 2002, 11:25 PM     #8 (permalink)
Ultimate Member
 
ChoaticWhisper's Avatar
 
Join Date: Oct 2001
Location: Alabama
Posts: 1,309
Send a message via AIM to ChoaticWhisper
Well I uploaded a updated version Here of what I have done.
I made a config.inc file that has the host and dbname and username and password in it, Just so I wouldnt mess that up having to configure so many different pages.

I thought about it and the index page I have isnt going to work for the real db because its pretty big, So the search page is really what I need to work on, If I just listed the real db like I am doing with this one it would be huge. I think the real db is going to be close to 1000 songs or more.
I only need a simple form to search for title or artist. I dont quiet understand how I use the %the%, How would I change that to search for something when I click submit on a form?
ChoaticWhisper is offline   Reply With Quote
Old May 8th, 2002, 02:44 AM     #9 (permalink)
Ultimate Member
 
ChoaticWhisper's Avatar
 
Join Date: Oct 2001
Location: Alabama
Posts: 1,309
Send a message via AIM to ChoaticWhisper
UPDATE!!!!
Please download the zip file again and test it out, Ive been working on it for awhile and I included a search.php(Im going to use it for index).
I had some problems with it showing the entire database onload, I think I fixed it with the if and esle but tell me if it has any problems.
Also could you tell me about anything that might be there that I dont need or something that doesnt work.

Thanks for the help
~ChoaticWhisper
ChoaticWhisper is offline   Reply With Quote
Old May 8th, 2002, 11:55 PM     #10 (permalink)
Banned
 
qball's Avatar
 
Join Date: Oct 2001
Posts: 447
Ok, the 'LIKE %the%' in the WHERE clause will return any rows in which the string column contains the word 'the'.

I strongly suggest you dload some sort of SQL interpreter. I use:

http://phpmyadmin.sourceforge.net/

[edit]
wow, they have a version 2.2.6, I'm running 2.2.4
[/edit]

That will allow you to admin your DB(s) and execute SQL statements, directly, rather than embedding in HTML/PHP pages. Thus you can cut-n-paste the SQL statement and see results.

I dloaded your newest stuff and will get back to you...
qball is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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

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

Most Active Discussions
Is It Just Me? (2881)
The United States Debt (20)
Looks like Burris will get his Sena.. (7)
Upgrading RAM (5)
I think I just killed my computer w.. (24)
Folderchat Weekday thread (436)
Antec 300 bulk purchase? (11)
Worth the upgrade?? (14)
Titan quest and Immortal Throne, an.. (17)
Recent Discussions
CPU wont boot (3)
Best digital camera for under 2.. (13)
Building first computer, will t.. (2)
Folderchat Weekday thread (436)
Help with an Ati Radeon HD 4850.. (22)
get this error, "res://C:\.. (73)
Problem with boot and motherboa.. (0)
MS to offer free Windows 7 upgr.. (1)
System Security Virus (20)
Blackberry Storm, Gears of War .. (1)
Core 2 Quad Q9550 system (3)
COWBOOM Ripoff! Used Laptop w/$.. (4)


All times are GMT -4. The time now is 07:31 PM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28