User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,944 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,891 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 264 | Replies: 1
Reply
Join Date: Jan 2008
Location: USA East Cost
Posts: 386
Reputation: CoolGamer48 is on a distinguished road 
Rep Power: 1
Solved Threads: 37
CoolGamer48's Avatar
CoolGamer48 CoolGamer48 is offline Offline
Posting Whiz

No result from a PHP page

  #1  
Jun 14th, 2008
EDIT: Ahhh.. nvm, I found it: die("Error with database".); should be die("Error with database.");
Might anyone know why the following php script produces no results? I.e., when I ctrl+u in Firefox, a blank screen comes up.

  1. <html>
  2. <head>
  3. <title>Create Base</title>
  4. </head>
  5. <body>
  6. <h1>Create Base</h1>
  7. <form action="bases.php" method="post">
  8. <table>
  9. <tr><td>Name:</td><td><input type="text" name="name" /></td></tr>
  10. </table>
  11. <input type="submit" value="Create Base" />
  12. </form>
  13. <?php
  14. $con = mysql_connect("localhost","user","pass");
  15. if($con == NULL)
  16. {
  17. die("Error with database".);
  18. }
  19. mysql_select_db("alecbenz_rpgProj",$con);
  20. if(isset($_POST["name"]) && $_POST["name"] != "")
  21. {
  22. $sql = "SELECT money FROM users WHERE username = \"".$_COOKIE["user"]."\"";
  23. $result = mysql_query($sql,$con);
  24. $row = mysql_fetch_array($result);
  25. $current_money = $row["money"];
  26. if($current_money >= $cost)
  27. {
  28. $sql = "INSERT INTO bases (name,usr_name) VALUES (\"".$_POST["name"]."\",\"".$_COOKIE["user"]."\")";
  29. mysql_query($sql,$con);
  30. $sql = "UPDATE users SET money = ".($current_money-$cost)." WHERE username = \"".$_COOKIE["user"]."\"";
  31. if(!mysql_query($sql,$con))
  32. {
  33. echo "Error: ".mysql_error();
  34. }
  35. }
  36. else
  37. {
  38. echo "You do not have enough money to create a new base. Current money: $current_money.";
  39. }
  40. }
  41.  
  42. $sql = "SELECT name FROM bases WHERE usr_name = \"".$_COOKIE["user"]."\"";
  43. $result = mysql_query($sql,$con);
  44. if(mysql_num_rows($result) == 0)
  45. {
  46. $cost = 100;
  47. }
  48. elseif(mysql_num_rows($result) == 1)
  49. {
  50. $cost = 150;
  51. }
  52. elseif(mysql_num_rows($result) == 2)
  53. {
  54. $cost = 200;
  55. }
  56. elseif(mysql_num_rows($result) >= 3)
  57. {
  58. $cost = 300;
  59. }
  60. echo "New bases will cost you ".$cost.".<br /><br />";
  61.  
  62. $sql = "SELECT name,id FROM bases WHERE usr_name = \"".$_COOKIE["user"]."\"";
  63. $result = mysql_query($sql,$con);
  64. if(mysql_num_rows($result) == 0)
  65. {
  66. echo "No bases currently established.";
  67. }
  68. else
  69. {
  70. echo "<div style=\"text-decoration: underline;\">Current bases:</div><br />";
  71. $counter = 1;
  72. while($row = mysql_fetch_array($result))
  73. {
  74. echo $counter.". ".$row["name"]." <a href=\"delete_base.php?base=".$row["id"]."\">Delete</a><br />";
  75. $counter++;
  76. }
  77. }
  78. ?>
  79. <br />
  80. <br />
  81. <a href="index.php">Return</a>
  82. </body>
  83. </html>

The page was working (with other issues I could not resolve), when I moved a block of code to another position. I ftped it, reloaded, and nothing came up. I moved the code back, re-ftped, reloaded, still nothing.
Last edited by CoolGamer48 : Jun 14th, 2008 at 9:45 am.
I'm a student. If my statements seem too absolute, feel free to coat them with "In my opinion..." or "I believe...".
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2008
Location: Phoenix, AZ
Posts: 534
Reputation: R0bb0b is on a distinguished road 
Rep Power: 2
Solved Threads: 50
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Posting Pro

Re: No result from a PHP page

  #2  
Jun 14th, 2008
I'm still showing
die("Error with database".);
on line 17 which is keeping anything from being displayed.

it should be
die("Error with database.");
Last edited by R0bb0b : Jun 14th, 2008 at 10:53 am.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

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

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 8:52 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC