Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

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:
  #1  
Old March 22nd, 2004, 08:19 PM
The Squirrel The Squirrel is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Mid-Indiana, USA
Posts: 153 The Squirrel 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 The Squirrel
help me please

I have a database I'm working on (different then what I have been working with. ) that I cannot get to display the results to.
here is my code for it
php Code:
Original - php Code
  1. //connect to database server
  2. $dbcnx = @mysql_connect('*', '*', '*');
  3. if (!$dbcnx) {
  4.     echo ('<p>Unable to connect to the database server at this time. Please try again later.</p>');
  5.     exit();
  6. }
  7.  
  8. //connect to registry database
  9. mysql_select_db('registry', $dbcnx);
  10. if (!@mysql_select_db('registry')) {
  11.     die ('<p>Unable to locate the registry database at this time.</p>');
  12. }
  13.  
  14. //select all items in database
  15. $result = @mysql_query('SELECT item, description FROM `registryitems`');
  16. if (!$result) {
  17.     die ('<p>Error performing query: ' . mysql_error() . '</p>');
  18. }
  19.  
  20. //display items in database
  21. while ($row = mysql_fetch_array($result) ) {
  22.     echo('<p>' . $row['registryitems'] . '</p>');
  23. }


it connects fine as far as I can tell but it will not display the information that I have in the database. I know the information is there cause I put it there and can run my queries fine in phpmyadmin. The above is the entire script. Any suggestions?

I'm guessing the problem is in my while loop but I do not see any errors.

Thanks,
The Squirrel

Reply With Quote
  #2  
Old March 22nd, 2004, 08:47 PM
treelo treelo is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 121 treelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 28 m 39 sec
Reputation Power: 2
RE: help me please

php Code:
Original - php Code
  1. //select all items in database
  2. $result = @mysql_query('SELECT * FROM registryitems');
  3. if (!$result) {
  4.     die ('<p>Error performing query: ' . mysql_error() . '</p>');
  5. }
  6.  
  7. //display items in database
  8. while ($row = mysql_fetch_array($result) ) {
  9.     echo('<p>' . $row['THE ROW YOU WANT TO ECHO'] . '</p>');
  10. }


try that mate, works for me

Reply With Quote
  #3  
Old March 22nd, 2004, 08:54 PM
The Squirrel The Squirrel is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Mid-Indiana, USA
Posts: 153 The Squirrel 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 The Squirrel
RE: help me please

Ok, I finally got it working. I don't know what I did but it worked.

Thanks for taking the time to read this though.

Treelo: I just fixed it before I came back to see if a reply had been posted. I will compare what my code looks like now and what you did to see if it would've worked. Thanks for the help though!

Reply With Quote
  #4  
Old March 23rd, 2004, 02:41 PM
The Squirrel The Squirrel is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Mid-Indiana, USA
Posts: 153 The Squirrel 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 The Squirrel
RE: RE: help me please

Ok, I'm running into another problem now. Perhaps you all could help me?

My script:
php Code:
Original - php Code
  1. //connect to database server
  2. $dbcnx = @mysql_connect('*', '*', '*');
  3. if (!$dbcnx) {
  4.     echo ('<p>Unable to connect to the database server at this time. Please try again later.</p>');
  5.     exit();
  6. }
  7.  
  8. //connect to registry database
  9. mysql_select_db('registry', $dbcnx);
  10. if (!@mysql_select_db('registry')) {
  11.     die ('<p>Unable to locate the registry database at this time.</p>');
  12. }
  13.  
  14. // If a item has been deleted, remove it from database.
  15. if (isset($_GET['deleteitem'])) {
  16.     $itemid = $_GET['deleteitem'];
  17.     $sql = "DELETE FROM items WHERE ID=$itemid";
  18.     if (@mysql_query($sql)) {
  19.         echo ('<P>The item has been deleted.</p>');
  20.     } else {
  21.         echo('<p>Error deleting item: ' . mysql_error() . '</p>');
  22.     }
  23. }
  24.  
  25. echo('<p>For your reference here are all the items listed in your registry and this time: <HR></p>');
  26.  
  27. //request all the items
  28. $result = @mysql_query('SELECT * from items');
  29. if (!$result) {
  30.     die('<p>Error performing query: ' . mysql_error() . '</p>');
  31. }
  32.  
  33. //Display the text of the items with a "delete" button next to each.
  34. while ($row = mysql_fetch_array($result) ) {
  35.     $itemid = $row['ID'];
  36.     $items = $row['items'];
  37.     echo('<p>' . $items . ' - <a href="' . $_SERVER['PHP_SELF'] . '?deleteitem=' . $itemid . '">' .
  38.         'Remove item</a></p>');
  39. }



Problem: Items will not delete.
Message: "Error deleting item: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1"

I have checked my query and it is valid. But for some reason it isn't working from the web. Any help is as always most appreciated.

Thanks,
The Squirrel

Reply With Quote
  #5  
Old March 23rd, 2004, 06:38 PM
The Squirrel The Squirrel is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Mid-Indiana, USA
Posts: 153 The Squirrel 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 The Squirrel
RE: help me please

I got this problem fixed. Thanks for reading though.

Now I gots another problem. Well, not really problem but a question. How would I go about having an item in a database with a link beside (already of this accomplished) and when you click on the link beside it, instead of removing it from the database just put a marker besides it of some sort saying that it has been selected already?

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > help me please


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway