•
•
•
•
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
![]() |
•
•
Join Date: Jan 2008
Location: USA East Cost
Posts: 386
Reputation:
Rep Power: 1
Solved Threads: 37
EDIT: Ahhh.. nvm, I found it:
Might anyone know why the following php script produces no results? I.e., when I ctrl+u in Firefox, a blank screen comes up.
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.
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.
php Syntax (Toggle Plain Text)
<html> <head> <title>Create Base</title> </head> <body> <h1>Create Base</h1> <form action="bases.php" method="post"> <table> <tr><td>Name:</td><td><input type="text" name="name" /></td></tr> </table> <input type="submit" value="Create Base" /> </form> <?php $con = mysql_connect("localhost","user","pass"); if($con == NULL) { die("Error with database".); } mysql_select_db("alecbenz_rpgProj",$con); if(isset($_POST["name"]) && $_POST["name"] != "") { $sql = "SELECT money FROM users WHERE username = \"".$_COOKIE["user"]."\""; $result = mysql_query($sql,$con); $row = mysql_fetch_array($result); $current_money = $row["money"]; if($current_money >= $cost) { $sql = "INSERT INTO bases (name,usr_name) VALUES (\"".$_POST["name"]."\",\"".$_COOKIE["user"]."\")"; mysql_query($sql,$con); $sql = "UPDATE users SET money = ".($current_money-$cost)." WHERE username = \"".$_COOKIE["user"]."\""; if(!mysql_query($sql,$con)) { echo "Error: ".mysql_error(); } } else { echo "You do not have enough money to create a new base. Current money: $current_money."; } } $sql = "SELECT name FROM bases WHERE usr_name = \"".$_COOKIE["user"]."\""; $result = mysql_query($sql,$con); if(mysql_num_rows($result) == 0) { $cost = 100; } elseif(mysql_num_rows($result) == 1) { $cost = 150; } elseif(mysql_num_rows($result) == 2) { $cost = 200; } elseif(mysql_num_rows($result) >= 3) { $cost = 300; } echo "New bases will cost you ".$cost.".<br /><br />"; $sql = "SELECT name,id FROM bases WHERE usr_name = \"".$_COOKIE["user"]."\""; $result = mysql_query($sql,$con); if(mysql_num_rows($result) == 0) { echo "No bases currently established."; } else { echo "<div style=\"text-decoration: underline;\">Current bases:</div><br />"; $counter = 1; while($row = mysql_fetch_array($result)) { echo $counter.". ".$row["name"]." <a href=\"delete_base.php?base=".$row["id"]."\">Delete</a><br />"; $counter++; } } ?> <br /> <br /> <a href="index.php">Return</a> </body> </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...".
•
•
Join Date: Jun 2008
Location: Phoenix, AZ
Posts: 534
Reputation:
Rep Power: 2
Solved Threads: 50
I'm still showing
on line 17 which is keeping anything from being displayed.
it should be
die("Error with database".);it should be
die("Error with database."); Last edited by R0bb0b : Jun 14th, 2008 at 10:53 am.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
- Php Frames (PHP)
- php error HELP!!! (PHP)
- Problems with the user.php file (Growing an Online Community)
- Warning: mysql_fetch_assoc(): 2 is not a valid MySQL result resource (PHP)
- php mysql help (PHP)
- I had a experience of a website coded in PHP (PHP)
- sort on field names; refresh page? (PHP)
- updating 2 HTML tables on one PHP page (PHP)
Other Threads in the PHP Forum
- Previous Thread: php form double submit problem
- Next Thread: New any Ideas


Linear Mode