Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Coding help...

Asked Modified Viewed 5,638 times
U
Unknown98
U
  • Member, joined since
  • Contributed 113 posts on the community forums.
  • Started 32 threads in the forums
  • Started this discussions
asked
Member


<?php

$database ='database';
$data ='data';

if (!is_numeric($_REQUEST['capital']) || $_REQUEST['capital'] < 75000)
{
     echo "Please enter at least $75,000 for the Capital.";
     echo "<br><br>";
}


$sql = "SELECT * FROM fusion_users WHERE user_id = '".$userdata['user_id']."'";
If ($data['strength'] <40 || $data['money'] <75000 ){
   echo "You don't qualify to establish a business! you need at least 40 strength and $75,000.";
   echo "<br><br>";
   }else{

$sql="INSERT INTO companies (founder_username, company_name, capital)
VALUES
('".$userdata['user_name']."', '$_POST[companyname]','$_POST[capital]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }

    $up="Update fusion_users set money=money-$_POST[capital] where user_id = '".$userdata['user_id']."'";
mysql_query($up) or die("error");

$up="Update fusion_users set strength=strength-40 where user_id = '".$userdata['user_id']."'";
mysql_query($up) or die("error");




echo "Congrats! You've just made a new business! You can manage this business through the company control panel";

?>


It's not working. :/. When it processes, it shows all 3 errors, no matter what. And even though I have 15000 "strength" and 1500000 "money" it still says I don't have the requirements to make the business. So what is wrong that you can see?
0 replies

12 posts

G
googlebot
G
Visit the new home of the merge between Hacking Vs. Security and Security Override!
My copyright removal has been switched over from HvS to SecurityOverride.
  • Senior Member, joined since
  • Contributed 638 posts on the community forums.
  • Started 28 threads in the forums
answered
Senior Member

Well, at a glance, find this line:

('".$userdata['user_name']."', '$_POST[companyname]','$_POST[capital]')";

Shouldn't that be this?

('".$userdata['user_name']."', '".$_POST[companyname]."','".$_POST[capital]."')";
0 replies
U
Unknown98
U
  • Member, joined since
  • Contributed 113 posts on the community forums.
  • Started 32 threads in the forums
  • Started this discussions
answered
Member

Ok, It now shows undefined index errors on line 6, and 2 more errors on line 19. It's not inserting the data into the DB even though I have the requirements.


<?php

$database ='database';


if (!is_numeric($_REQUEST['capital']) || $_REQUEST['capital'] < 75000)
{
     echo "Please enter at least $75,000 for the Capital.";
     echo "<br><br>";
}

If ($userdata['strength'] <40 || $userdata['money'] <75000 ){

   echo "You don't qualify to establish a business! you need at least 40 strength and $75,000.";
   }else{

$sql="INSERT INTO companies (founder_username, company_name, capital)
VALUES
('".$userdata['user_name']."', '".$_REQUEST['companyname']."','".$_REQUEST['capital']."')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }

    $up="Update fusion_users set money=money-$_POST[capital] where user_id = '".$userdata['user_id']."'";
mysql_query($up) or die("error");

$up="Update fusion_users set strength=strength-40 where user_id = '".$userdata['user_id']."'";
mysql_query($up) or die("error");




echo "Congrats! You've just made a new business! You can manage this business through the company control panel";

?>
Edited by Unknown98 on 07-08-2008 16:18,
0 replies
U
Unknown98
U
  • Member, joined since
  • Contributed 113 posts on the community forums.
  • Started 32 threads in the forums
  • Started this discussions
answered
Member

Ok, here's the form:


Cool! You're now going to Establish a Business.<br><br>

You need atleast $75,000 to establish a company.

<form action="viewpage.php?page_id=26" method="post" name="createenterprise">
Business Name:<br>
<input type="text" name="companyname" maxlength="32" /><br>
Capital (At least $75,000):<br>
<input type="text" name="capital" /><br><br>
<input type="submit" name="makeenterprise" value="Make Business" />


And the processing page:


<?php

$database ='database';


if (!is_numeric($_REQUEST['capital']) || $_REQUEST['capital'] < 75000)
{
echo "Please enter at least $75,000 for the Capital.";
echo "<br><br>";
}

If ($userdata['strength'] <40 || $userdata['money'] <75000 ){

echo "You don't qualify to establish a business! you need at least 40 strength and $75,000.";
}else{

$sql="INSERT INTO companies (founder_username, company_name, capital)
VALUES
('".$userdata['user_name']."', '".$_REQUEST['companyname']."','".$_REQUEST['capital']."')";

if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}

$up="Update fusion_users set money=money-$_POST[capital] where user_id = '".$userdata['user_id']."'";
mysql_query($up) or die("error");

$up="Update fusion_users set strength=strength-40 where user_id = '".$userdata['user_id']."'";
mysql_query($up) or die("error");


}

echo "Congrats! You've just made a new business! You can manage this business through the company control panel";

?>


And the errors that show up on preview:


Notice: Undefined index: capital in /www/oxyhost.com/s/a/l/salesmangame/htdocs/administration/custom_pages.php(72) : eval()'d code on line 6
Please enter at least $75,000 for the Capital.


Notice: Undefined index: companyname in /www/oxyhost.com/s/a/l/salesmangame/htdocs/administration/custom_pages.php(72) : eval()'d code on line 19

Notice: Undefined index: capital in /www/oxyhost.com/s/a/l/salesmangame/htdocs/administration/custom_pages.php(72) : eval()'d code on line 19

Notice: Undefined variable: con in /www/oxyhost.com/s/a/l/salesmangame/htdocs/administration/custom_pages.php(72) : eval()'d code on line 21

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /www/oxyhost.com/s/a/l/salesmangame/htdocs/administration/custom_pages.php(72) : eval()'d code on line 21
Error:
Edited by N/A on 08-08-2008 05:38,
0 replies
U
Unknown98
U
  • Member, joined since
  • Contributed 113 posts on the community forums.
  • Started 32 threads in the forums
  • Started this discussions
answered
Member

I removed the $con varible. The revised processing page:


<?php

$database ='database';


if (!is_numeric($_REQUEST['capital']) || $_REQUEST['capital'] < 75000)
{
echo "Please enter at least $75,000 for the Capital.";
echo "<br><br>";
}

If ($userdata['strength'] <40 || $userdata['money'] <75000 ){

echo "You don't qualify to establish a business! you need at least 40 strength and $75,000.";
}else{

$sql="INSERT INTO companies (founder_username, company_name, capital)
VALUES
('".$userdata['user_name']."', '".$_REQUEST['companyname']."','".$_REQUEST['capital']."')";

if (!mysql_query($sql))
{
die('Error: ' . mysql_error());
}

$up="Update fusion_users set money=money-$_REQUEST[capital] where user_id = '".$userdata['user_id']."'";
mysql_query($up) or die("error");

$up="Update fusion_users set strength=strength-40 where user_id = '".$userdata['user_id']."'";
mysql_query($up) or die("error");


}

echo "Congrats! You've just made a new business! You can manage this business through the company control panel";

?>


I also changed the $up update codes from $_POST[capital] to $_REQUEST[capital]. Is that ok?
And, if you can't tell, I'm still a newbie at PHP. Which page has the undefined $_POST values?
0 replies
U
Unknown98
U
  • Member, joined since
  • Contributed 113 posts on the community forums.
  • Started 32 threads in the forums
  • Started this discussions
answered
Member

Ok, thanks. And how do I pass them on? Lol, I'm sorry. But the good thing is I learned some things today. :)
0 replies
U
Unknown98
U
  • Member, joined since
  • Contributed 113 posts on the community forums.
  • Started 32 threads in the forums
  • Started this discussions
answered
Member

Yes.
0 replies
U
Unknown98
U
  • Member, joined since
  • Contributed 113 posts on the community forums.
  • Started 32 threads in the forums
  • Started this discussions
answered
Member

It works now. Thank you!
0 replies
U
Unknown98
U
  • Member, joined since
  • Contributed 113 posts on the community forums.
  • Started 32 threads in the forums
  • Started this discussions
answered
Member

Ok, help again.


<?php

If ($userdata['strength'] <2 || $userdata['money'] <250 ){

echo "You don't qualify to create a bank account! You need at least 2 strength and $250.";
}else{

$sql="INSERT INTO bank (founder_username, account_name)
VALUES
('".$userdata['user_name']."', '".$_POST['accountname']."')";

if (!mysql_query($sql))
{
die('Error: ' . mysql_error());
}

$up="UPDATE fusion_users set money=money-250 where user_id = '".$userdata['user_id']."'";
mysql_query($up) or die("error");
$up="UPDATE fusion_users set strength=strength-2 where user_id = '".$userdata['user_id']."'";
mysql_query($up) or die("error");

?>


The error says "Unexpected "$end" on line 23 (Or the last line, not sure what number exactly).
Edited by Unknown98 on 12-08-2008 03:25,
0 replies
X
Xessive
X
I am not always right, but I'm never wrong.
http://www.xessive.nl
  • Senior Member, joined since
  • Contributed 327 posts on the community forums.
  • Started 4 threads in the forums
answered
Senior Member

Your missing a } sign.
At the line "If ($userdata['strength'] <2 || $userdata['money'] <250 ){" it is opened (see { sign here left) but is is never closed.

Try placing this sign } before or after the last 2 SQL statements.

So it will look like this:


<?php

If ($userdata['strength'] <2 || $userdata['money'] <250 ){
   echo "You don't qualify to create a bank account! You need at least 2 strength and $250.";
}else{
$sql="INSERT INTO bank (founder_username, account_name) VALUES ('".$userdata['user_name']."', '".$_POST['accountname']."')";

if (!mysql_query($sql))
  {
  die('Error: ' . mysql_error());
  }
}
    $up="UPDATE fusion_users set money=money-250 where user_id = '".$userdata['user_id']."'";
mysql_query($up) or die("error");
   $up="UPDATE fusion_users set strength=strength-2 where user_id = '".$userdata['user_id']."'";
mysql_query($up) or die("error");

?>


or look like this:


<?php

If ($userdata['strength'] <2 || $userdata['money'] <250 ){
   echo "You don't qualify to create a bank account! You need at least 2 strength and $250.";
}else{
$sql="INSERT INTO bank (founder_username, account_name) VALUES ('".$userdata['user_name']."', '".$_POST['accountname']."')";

if (!mysql_query($sql))
  {
  die('Error: ' . mysql_error());
  }

    $up="UPDATE fusion_users set money=money-250 where user_id = '".$userdata['user_id']."'";
mysql_query($up) or die("error");
   $up="UPDATE fusion_users set strength=strength-2 where user_id = '".$userdata['user_id']."'";
mysql_query($up) or die("error");
}
?>
Edited by Xessive on 12-08-2008 09:16,
0 replies
U
Unknown98
U
  • Member, joined since
  • Contributed 113 posts on the community forums.
  • Started 32 threads in the forums
  • Started this discussions
answered
Member

Yep works now thank you.
0 replies
U
Unknown98
U
  • Member, joined since
  • Contributed 113 posts on the community forums.
  • Started 32 threads in the forums
  • Started this discussions
answered
Member

Sigh... Can you help me "Fusionify" this?:


<?php
echo "Welcome, ".$userdata['user_name']."!";
?>
<BR><BR>

Here you can see all of your accounts, and their details. <Br><br>

<?php

$result = mysql_query("SELECT * FROM bank WHERE founder_username = ".$userdata['user_name']."");

echo "<table border='1'>
<tr>
<th>Account Name</th>
<th>Account Money</th>
<th>Daily Interest</th>
<th>Account loan Amount</th>
<th>Accumlated Iterst. on Crnt. loan</th>
</tr>";while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['account_name'] . "</td>";
echo "<td>" . $row['account_money'] . "</td>";
echo "<td>" . $row['account_daily_interest'] . "</td>";
echo "<td>" . $row['account_loan'] . "</td>";
echo "<td>" . $row['account_loan_interest'] . "</td>";


echo "</tr>";
}
echo "</table>";

?>


Doesn't show the results and shows an error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /www/oxyhost.com/s/a/l/salesmangame/htdocs/viewpage.php(26) : eval()'d code on line 19
Edited by Unknown98 on 13-08-2008 02:39,
0 replies
U
Unknown98
U
  • Member, joined since
  • Contributed 113 posts on the community forums.
  • Started 32 threads in the forums
  • Started this discussions
answered
Member

Will do, server's down as of now but should be back up soon. Thanks again.
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 12 posts
  • Votes 0 votes
  • Topic users 3 members

0 participants

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet