473,403 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Debug

The1corrupted
134 100+
Blah!! I can't figure out what's wrong with this php code and I can't figure out what! My debugger sees no errors in it, yet the script won't run! I know it's not the includes because they run correctly everywhere else except for buytown.post.php..

buytown.php
[PHP]
<?php
session_start();
//$_SESSION['user'] is the logged-in user's id number used to get data.
echo "<head>
<title>Empirez! The Online Empire Building Game | Build a Town</title>";
include ("includes/pageheader.php"); //included in all pages viewable
include ("includes/navbar.php"); //included in all pages viewable
include ("server/db_conn.php"); //Connect to the database

if (!isset($_SESSION['user'])) {

echo "<script language=\"javascript\" type=\"text/javascript\">alert(\"You must log in to do that!\")
parent.location=\"login.php\"</script>";

} else {
$id=$_SESSION['user']; //The $_SESSION['user'] would be an id number if it is set.

$query=mysql_query("SELECT * FROM `users` WHERE `id`='$id'");
$genarray=mysql_fetch_array($query); //General info array

settype($towncost, "float"); //Float the town cost
settype($genarray['money'], "float");

$towncost=($genarray['towns']*2800)/3; //Calculate the cost per town
$cost=round($towncost, 2); //Round the town costs

include ("server/buytown.post.php");

echo "
<td colspan=\"2\">
.: Buy a Town :.
</td>
</tr>
<tr>
<td>
Current Funds:
</td>
<td>
<font color=\"#009900\"<b>$".round($genarray['money'], 2)."</b></font>
</td>
</tr>
<tr>
<td>
Current Towns:
</td>
<td>
".$genarray['towns']."
</td>
</tr>
<tr>
<td>
Cost Per Town:
</td>
<td>
".$cost."
<input type=\"hidden\" value=".$cost." name=\"cost\">
</td>
</tr>
<tr>
<td>
Purchase Amount:
</td>
<td>
<input type=\"text\" name=\"numer\" length=\"20\">
</td>
</tr>
<tr>
<td colspan=\"2\">
<input type=\"submit\" value=\"Purchase\">
<input type=\"submit\" value=\"Confirm Purchase\">
</td>
</tr>
</table>";
}

include ("includes/pagefooter.php"); //At the end of all pages viewable
mysql_close();
?>[/PHP]

buytown.post.php
[PHP]<?php
$number=$_POST['number'];

if ($number!=NULL) {
if ($genarray['money']>=($cost*$number)) {
settype($purchase, "float");
$purchase=$cost*$number;
round($purchase, 2);

mysql_query("UPDATE `users` WHERE `id`='$id' SET `towns`=`towns`+'$number'");

echo "
<script language=\"javascript\" type=\"text/javascript\">alert(\"Town built successfully.\")
parent.location=\"viewempire.php\"</script>";
} else {
echo "
<script language=\"javascript\" type=\"text/javascript\">alert(\"Not enough funds!!\")</script>";
}
}
?>[/PHP]
Nov 22 '07 #1
3 1211
The1corrupted
134 100+
Nevermind, I solved the problem.. It was my MySQL syntax. I reversed the SET and WHERE in my buytown.post.php.
Nov 22 '07 #2
pbmods
5,821 Expert 4TB
Heya, The1corrupted.

Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Nov 22 '07 #3
The1corrupted
134 100+
Yes, actually it seems that I get a majority of my pages right on the first try, just a few tiny syntax errors here and there to occasionally occupy my time, but this is the fastest I've actually ever gotten a site's pages up and running...

What I have so far can be found at http://empirez.php0h.com

Though, I warn you about signing up because your account could be deleted due to the MySQL table changes, which are quite frequent as I sometimes find that I was missing a field or two, or just to add new features.
Nov 22 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Davy | last post by:
Hi all, I use VC and gcc/gdb to compile and debug C/C++ files. But I found some of the debug version of the compiled files are too large to be run in a small RAM. Can I compile C/C++ Debug...
4
by: emma middlebrook | last post by:
I have a question regarding asserting ... here's some code: string GetAssertMessage() { ... prepare a message string and return it... } void SomeMethod() { ...
7
by: Srinivasa Rao | last post by:
I have read in one article that when we compile the application in release mode, all the debug classes and properties will be automatically removed from the code. I tried to implement this thing by...
9
by: dee | last post by:
Hi I'm about to upload my site and I have switched to release version. Is that enough or do I still need to disable <compilation defaultLanguage="vb" debug="true" /> the debug="true" in the .pdb...
6
by: swartzbill2000 | last post by:
Hello, I have a VB 2005 Express project with a TraceListener-derived class to route Debug.Print output to a log file. It works fine for Debug builds. What is the correct combination of changes to...
6
by: pauldepstein | last post by:
To help me debug, I am writing a lot of information into a stream which I call debug. However, because of the large amount of time taken to print this information, I only want this printed while...
6
by: Andrew Rowley | last post by:
I am having trouble getting debug and release builds to work properly with project references using C++ .NET and Visual Studio 2003. I created a test solution, with a basic Windows form C++...
0
by: BA | last post by:
I posted on this once before and could not get a solution, I am hoping someone can help. I have a very strange code debug behavior that I cannot make heads or tails of: I have c# code being...
1
by: gfergo | last post by:
Good Morning, I seem to be having a problem. I thought I could display detailed debugging information (including file name and line number) on a page using two different methods: 1.)...
3
by: rorni | last post by:
Hi, I'm porting code from Windows to HP-UX 11, compiling with g++. I'm getting a compilation error on the system's debug.h include file, which is included very indirectly through a series of...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.