SunQuest
           PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old July 1st, 2002, 01:27 AM
russ russ is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: London, UK
Posts: 129 russ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to russ Send a message via Yahoo to russ
Selecting database

okay, I'm trying to make my site easy for my to update and stuff, I also want it to have less pages, so I had the great idea of haveing a drop down menu to select a database, but for some reason its not working, basicly, the select variable doesn't seem to be passing though.

php Code:
Original - php Code
  1.  
  2. <?php
  3. $db = @mysql_connect("$dbhost", "$dbuname", "$dbpage");
  4. if (!$db) {
  5.   echo( "<p>Unable to connect to the " .
  6.         "database server at this time.</p>" );
  7.   exit();
  8. }
  9. mysql_select_db("$dbname", $db);
  10. if (! @mysql_select_db("$dbname") ) {
  11.   echo( "<p>Unable to locate the $select " .
  12.         "database at this time.</p>" );
  13.   exit();
  14. }
  15. if($submit)
  16. {
  17. $sql = "INSERT INTO ".$_GET['select']."db (band, song, tab) VALUES ('$band', '$song', '$tab')";
  18. $result = mysql_query($sql);
  19. echo( "Thank you! Information entered. Click <a href=/".$_GET['select'].".php>here</a> to view your tab" );
  20. }
  21. else
  22. {
  23. ?>
  24. <form method="post" action="<?=$PHP_SELF?>">
  25. Band Name:
  26. <br><input type="Text" name="band">
  27. <br>Song Title:
  28. <br><input type="Text" name="song">
  29. <br>Guitar/Bass/Drum:
  30. <br><select name="select">
  31. <option value="guitar">Guitar</option>
  32. <option value="bass">Bass</option>
  33. <option value="drum">Drum</option>
  34. </select>
  35. <br>Tab:
  36. <br><textarea name="tab" cols=40 rows=8></textarea>
  37. <br>
  38. <input type="Submit" name="submit" value="Submit"></form>
  39. <?
  40. }
  41. ?>

Reply With Quote
  #2  
Old July 1st, 2002, 01:50 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Selecting database

your form is using the post method and you are trying to access the select via the get superglobal. Try $_POST instead.....

Reply With Quote
  #3  
Old July 1st, 2002, 07:54 PM
russ russ is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: London, UK
Posts: 129 russ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to russ Send a message via Yahoo to russ
RE: Selecting database

cheers thank you

Reply With Quote
  #4  
Old July 1st, 2002, 09:27 PM
russ russ is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: London, UK
Posts: 129 russ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to russ Send a message via Yahoo to russ
RE: Selecting database

Okay, so the first one worked, but I don't get why this one doesn't, its pretty much exactly the same, I seriously can't see whats wrong

php Code:
Original - php Code
  1.  
  2. <?php
  3. $db = @mysql_connect("$dbhost", "$dbuname", "$dbpage");
  4. if (!$db) {
  5.   echo( "<p>Unable to connect to the " .
  6.         "database server at this time.</p>" );
  7.   exit();
  8. }
  9. mysql_select_db("$dbname", $db);
  10. if (! @mysql_select_db("$dbname") ) {
  11.   echo( "<p>Unable to locate the $select " .
  12.         "database at this time.</p>" );
  13.   exit();
  14. }
  15. if($submit)
  16. {
  17. $sql = "INSERT INTO ".$_POST['select']."db (add, link) VALUES ('$add', '$link')";
  18. $result = mysql_query($sql);
  19. echo( "Thank you! Information entered. Click <a href=/links.php?action=view&type=".$_POST['select'].">here</a> to view your link" );
  20. }
  21. else
  22. {
  23. ?>
  24. <form method="post" action="<?=$PHP_SELF?>">
  25. Type:
  26. <br><select name="select">
  27. <option value="label">Labels</option>
  28. <option value="band">Bands</option>
  29. <option value="zine">Zines</option>
  30. <option value="tab">Tabs</option>
  31. <option value="other">Other</option>
  32. </select>
  33.  
  34.  
  35. <br>Link Address
  36. <br>http://<input type="Text" name="add">
  37.  
  38. <br>Link Address
  39. <br><input type="Text" name="link">
  40. <br>
  41. <input type="Submit" name="submit" value="Submit"></form>
  42. <?
  43. }
  44. ?>

Reply With Quote
  #5  
Old July 2nd, 2002, 09:02 PM
russ russ is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: London, UK
Posts: 129 russ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to russ Send a message via Yahoo to russ
RE: Selecting database

Okay, now I have changed the code to this

php Code:
Original - php Code
  1.  
  2. <?php
  3. $db = @mysql_connect("$dbhost", "$dbuname", "$dbpage");
  4. if (!$db) {
  5.   echo( "<p>Unable to connect to the " .
  6.         "database server at this time.</p>" );
  7.   exit();
  8. }
  9. mysql_select_db("$dbname", $db);
  10. if (! @mysql_select_db("$dbname") ) {
  11.   echo( "<p>Unable to locate the $select " .
  12.         "database at this time.</p>" );
  13.   exit();
  14. }
  15. if($submit)
  16. {
  17. $sql = "INSERT INTO labeldb (add, link) VALUES ('$add', '$link')";
  18. $result = mysql_query($sql);
  19. echo( "Thank you! Information entered." );
  20. }
  21. else
  22. {
  23. ?>
  24. <form method="post" action="<?=$PHP_SELF?>">
  25. <br>Link Address
  26. <br>http://<input type="Text" name="add">
  27.  
  28. <br>Link Address
  29. <br><input type="Text" name="link">
  30. <br>
  31. <input type="Submit" name="submit" value="Submit"></form>
  32. <?
  33. }
  34. ?>


and its still not adding the information

Reply With Quote
  #6  
Old July 2nd, 2002, 09:38 PM
CmdrDats CmdrDats is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: <br><img src='http://www.dats.co.za/icon.gif'>
Posts: 269 CmdrDats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to CmdrDats Send a message via AIM to CmdrDats Send a message via Yahoo to CmdrDats
RE: Selecting database

Is it giving you an error? if not, add this into your code :
php Code:
Original - php Code
  1.  
  2. <?
  3.   ...
  4.   $result = mysql_query($sql);
  5.  
  6.   // Add this line
  7.  
  8.   echo( "Thank you! Information entered." );
  9.   ...
  10. ?>


Test that and give us the results..

Reply With Quote
  #7  
Old July 2nd, 2002, 10:04 PM
russ russ is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: London, UK
Posts: 129 russ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to russ Send a message via Yahoo to russ
RE: Selecting database

ah thank u, now I get this error, which is wierd because the code is pretty much exactly the same as my other codes

You have an error in your SQL syntax near 'add, link) VALUES ('www.epitaph.com', 'Epitaph')' at line 1Thank you! Information entered. Click here to view your link

Reply With Quote
  #8  
Old July 3rd, 2002, 08:04 AM
CmdrDats CmdrDats is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: <br><img src='http://www.dats.co.za/icon.gif'>
Posts: 269 CmdrDats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to CmdrDats Send a message via AIM to CmdrDats Send a message via Yahoo to CmdrDats
RE: Selecting database

I have a feeling that the column name "add" is reserved. try changing it to something like "address" or "addy" and see if that works.

I think "link" isn't a reserved word in mysql, so it shouldn't be a problem, but if it still gives headaches, try changing that too..

Reply With Quote
  #9  
Old July 3rd, 2002, 07:39 PM