473,800 Members | 2,711 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Debug

The1corrupted
134 New Member
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.ph p..

buytown.php
[PHP]
<?php
session_start() ;
//$_SESSION['user'] is the logged-in user's id number used to get data.
echo "<head>
<title>Empire z! 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($_SESSI ON['user'])) {

echo "<script language=\"java script\" type=\"text/javascript\">al ert(\"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_qu ery("SELECT * FROM `users` WHERE `id`='$id'");
$genarray=mysql _fetch_array($q uery); //General info array

settype($townco st, "float"); //Float the town cost
settype($genarr ay['money'], "float");

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

include ("server/buytown.post.ph p");

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=\"Purchas e\">
<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.ph p
[PHP]<?php
$number=$_POST['number'];

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

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

echo "
<script language=\"java script\" type=\"text/javascript\">al ert(\"Town built successfully.\" )
parent.location =\"viewempire.p hp\"</script>";
} else {
echo "
<script language=\"java script\" type=\"text/javascript\">al ert(\"Not enough funds!!\")</script>";
}
}
?>[/PHP]
Nov 22 '07 #1
3 1231
The1corrupted
134 New Member
Nevermind, I solved the problem.. It was my MySQL syntax. I reversed the SET and WHERE in my buytown.post.ph p.
Nov 22 '07 #2
pbmods
5,821 Recognized Expert Expert
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 New Member
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
2699
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 partially? Something like: fileA.c fileB.c And I can compile fileA.c with debug info and compile fileB.c without debug info?
4
4533
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
2918
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 using the following code in Page_Load event handler. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim intcount As Integer intcount = 0 For intcount = 0 To 4
9
2001
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 file? Is the .pdb necessary for the release version? Thanks a bunch. Dara
6
4120
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 make it work in Release build? Bill
6
3666
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 I am in debugging mode as indicated by a preprocessor directive: #define DEBUG In other words, I need code which says "Whenever I write debug <<
6
9143
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++ project. I then add a class library, and add a reference to this project in the first project. When I do a release build, I see the following in the output from the DLL compile: /OUT:"C:\Documents and Settings\Andrew\My Documents\Visual Studio
0
1804
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 executed in BizTalk assemblies which is repeating debug statements. I tried debug.flush() and debug.close() which did not solve the problem. In my BizTalk process I call a static method:
1
1719
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.) modify the debug attribute of the compilation element in the web.config file -
3
3271
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 other system include files. The one I am including is <map> . The errors I am getting are: /opt/hp-gcc-4.2.1/lib/gcc/ia64-hp-hpux11.23/4.2.1/../../../../include/c++/4.2.1/debug/debug.h: At global scope:...
0
9691
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10507
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10255
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10036
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9092
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2948
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.