Jump to content

No Error, But Not Working


dean7

Recommended Posts

Hi all, ive been trying to code a "Create A Crew" for my website which just basicly lets users be in a group, but at the moment ive got as far as coding it where they buy one.

 

When I tryed running my script it just displayed a White Page with no Errors..

I tryed looking though agian but still couldn't work out what the error was.

 

<?php
session_start();
include ("includes/config.php");
include ("includes/functions.php");
logincheck();

ini_set ('display_errors', 1);
error_reporting (E_ALL);

$username = $_SESSION['username'];
// Select , Crew, money, crew limit etc from db

$mysql1 = mysql_query("SELECT * FROM `users` WHERE `username` = '$username'") or die ("Error, Line 10 " . mysql_error()); // Doing User Query
$userfetch = mysql_fetch_object($mysql1); // Getting User Object

$mysql2 = mysql_query("SELECT * FROM `crews` WHERE `username` = '$username'") or die ("Error, Line 13 " . mysql_error()); // Doing Crew Query
$crewfetch = mysql_fetch_object($mysql2); // Getting Crew Object

$allcrews = mysql_num_rows(mysql_query("SELECT * FROM `crews`"));

// Lets start! 
// If the user who wants to buy the crew is in one.. Lets say.

if ($userfetch->crew != "0"){
echo ("You must leave your current crew before creating your own!");
}

$crewname = $_POST['crewname']; // Name of the crew wanted
if (strip_tags($_POST['submit']) || strip_tags($_POST['crewname'])){
$price = 50000000; // 50mil
// Now, See if the posted crew name is allready taken, if so say..
if ($crewname){
$freeornot = mysql_query("SELECT * FROM `crews` WHERE `name` = '$crewname'"); // Selecting the crew if it exicts
$number = mysql_num_rows($freeornot);
if ($number != "0"){
echo ("The Crew Name Allready Made!");
// Crew name done.
}elseif (ereg('[^A-Za-z]', $crewname){
echo ("Crew Names can only contain Letters!");
// Letters only. Done!
}elseif ($userfetch->money < $price){
echo ("You do not have enouth money to buy a Crew!");
// Money check. Done!	
}else{
// Every check is done, and if all are good, we insert the crew into the db! =)
// Insert
mysql_query("INSERT INTO crews (`id`,`name`,`size`,`profile`,`bank`,`boss`,`underboss`,`recruiter`,`recruiter1`,`coowner`,`members`,`garage`,`garagesize`) VALUES ('','$crewname','10','','','$username','','','','','','','')") or die ("Error , line 42 " . mysql_error());
mysql_query("UPDATE users SET crew = '$crewname' WHERE username= '$username'") or die ("Error , Line 43 " . mysql_error());
$moneyleft = $userfetch->money - $price;
mysql_query("UPDATE users SET money = '$moneyleft' WHERE username='$username'") or die ("Error , Line 45 " . mysql_error());
echo ("Crew Made!");
}
}
} // Submit
?>
<html>
<head>
<title>Crews || SD</title>
</head>
<body class='body'>
<?php 
if ($allcrews < 51){
echo ("
<table width='40%' align='center' class='table' cellpadding='0' cellspacing='0' border='1'>
<tr>
<td class='header' align='center'>Crew Create</td>
</tr>
<tr>
<td class='omg' align='center'>Crew Name:</td>
</tr>	
<tr>
<td><input type='text' name='crewname' id='crewname' maxlength='50' class='input'></td>
</tr>	
<tr>
<td>When creating a crew it will have a member limit of <strong>10</strong> you will have chance to upgrade this though the Control Panel!</td>
</tr>
<tr>
<td align='center' class='omg'><input type='button' name='submit' class='button' value='Create Crew'></td>
</tr>
</table>");
}elseif ($allcrews > 50){
echo ("<table width='40%' align='center' class='table' cellpadding='0' cellspacing='0' border='1'>
<tr>
<td class='header' align='center'>Crew Create</td>
</tr>
<tr>
<td>Sorry, but the limit of crews have been reached. Please wait untill one is deleted.</td>
</tr>
</table>");
}
?>
</body>
</html>	

 

Anyone see why its just displaying a White Page?

 

Thanks for any help given. :)

Link to comment
Share on other sites

Basically means there is an error in your code.  If you have errors enabled and displaying them, it should give you the error.  You can also check your server log to see if there are errors there.

 

Another option is to just break down your code in sections to see if you can find the error in smaller chunks of code.

Link to comment
Share on other sites

Ive had a look though the script on a different softwhere (NetBeans - Might not be too good..) but its saying ive got the error on the }else{

 

}elseif ($userfetch->money < $price){
echo ("You do not have enouth money to buy a Crew!");
// Money check. Done!	
}else{ //---------------  This line
// Every check is done, and if all are good, we insert the crew into the db! =)
// Insert
mysql_query("INSERT INTO crews (`id`,`name`,`size`,`profile`,`bank`,`boss`,`underboss`,`recruiter`,`recruiter1`,`coowner`,`members`,`garage`,`garagesize`) VALUES ('','$crewname','10','','','$username','','','','','','','')") or die ("Error , line 42 " . mysql_error());
mysql_query("UPDATE users SET crew = '$crewname' WHERE username= '$username'") or die ("Error , Line 43 " . mysql_error());
$moneyleft = $userfetch->money - $price;
mysql_query("UPDATE users SET money = '$moneyleft' WHERE username='$username'") or die ("Error , Line 45 " . mysql_error());
echo ("Crew Made!");
}

 

But I dont see nothing wrong with that line? :S

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.