help with php coding

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
Henning12342
Posts: 9
Joined: Fri Feb 03, 2012 2:29 pm

help with php coding

Post by Henning12342 »

hi guys im having a problem i am trying to one make a unequip link [SOLVED]
ERROR messages [SOLVED]

now im tryng to get it to add values eg.

ship base attack = 100
weapon base attack = 100

ship base attack + weapon base attack = new ship attack
new ship attack - weapon base attack = old ship attack

any ideas would be great
and thanks in advance
Last edited by Henning12342 on Wed Feb 08, 2012 6:13 pm, edited 2 times in total.
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: help with php coding

Post by SpiritWebb »

Code: Select all

or die("could not get player stats!");
Put mysql_error() with those as well, to find out the full error.

Code: Select all

or die("could not get player stats!" . mysql_error());
EDIT:
Also, place the following at the top of your scripts, this should help as well.

Code: Select all

<?php
error_reporting(E_ALL); 
?>
Image

Image
Henning12342
Posts: 9
Joined: Fri Feb 03, 2012 2:29 pm

Re: help with php coding

Post by Henning12342 »

right i have this code but dont know where to put it ill post my shipequipped.php and shipunequipped.php code as well



Code: Select all

$shipBaseAttk = 100;
		$weaponBaseAttk = 100;

		$shipAttack = $shipBaseAttk + $weaponBaseAttk;
		$oldShipAttack = $shipAttack - $weaponBaseAttk;
shipequipped.php

Code: Select all

<?php
include_once 'connect.php';
 session_start();
   include_once 'logo.php';
   ?>
     <link href="style.css" rel="stylesheet" type="text/css" />
<?php
{	
	if (isset($_SESSION['player']))

	  $player=$_SESSION['player'];
	
	else
	{
	  echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
	  exit;
	}
	$playerinfo="SELECT * from players where name='$player'";
	$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
	$playerinfo3=mysql_fetch_array($playerinfo2);
	include_once 'statpanel.php';
	$id=$playerinfo3['id'];
	
}
?>
</div>
<div id="table">
 <?php
		$type=$_GET['type'];
		$randid=$_GET['randid'];
		
	   if ($type=="w")
	   {
	 $updateequip="Update playerships SET equip=0 WHERE pid='$id' AND equip=1";
	    mysql_query($updateequip) or die("Could not update equipment");	
		 $reequip="Update playerships set equip=1 where pid='$id' AND randid='$randid'";
	    mysql_query($reequip) or die("Could not update equipment2");	
		echo "<center><big><big>Got In To Ship<br></big></big>";
		echo "<br><A href='index.php'>Go back</a>";
		}
		
	
	
		
  
  ?>

</div>
<div id="logout">
<?php
echo "<br><a href='logout.php'><img src='images/logout.gif'></a>";
?>
</div>
shipunequiped.php

Code: Select all

<?php
include_once 'connect.php';
 session_start();
   include_once 'logo.php';
   ?>
     <link href="style.css" rel="stylesheet" type="text/css" />
<?php
if (isset($_SESSION['player']))
{
  $player=$_SESSION['player'];
}
else
{
  echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
  exit;
}
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
include_once 'statpanel.php';
$id=$playerinfo3['id'];
?>
</div>
<div id="table">
 <?php
	    $type=$_GET['type'];
		$randid=$_GET['randid'];
	  
	   if ($type=="w")
	   {
	 $updateequip="Update playerships SET equip=0 WHERE pid='$id' AND equip=0";
	    mysql_query($updateequip) or die("Could not update equipment");	
		 $reequip="Update playerships set equip=0 where pid='$id' AND randid='$randid'";
	    mysql_query($reequip) or die("Could not update equipment2");	
		
		echo "<center><big><big>Got Out Of Ship<br></big></big>";
		echo "<br><A href='index.php'>Go back</a>";
		}
		
  
  ?>

</div>
<div id="logout">
<?php
echo "<br><a href='logout.php'><img src='images/logout.gif'></a>";
?>
</div>

 
Post Reply

Return to “Beginner Help and Support”