Jump to content

[SOLVED] another php question, in my coding >.<


robotman321

Recommended Posts

ok i thought this code was working, but apparently its not as it adds /// instead of just one to the variables that contain a ' , is there anyone smarter than me that can explain what i did wrong, it has to be somthing simple..

 

<?php
// Don't forget to start the session
session_start();

// is the one accessing this page logged in or not?
if (!isset($_SESSION['db_is_logged_in']) || $_SESSION['db_is_logged_in'] !== true) {
// not logged in, move to login page
header('Location: login.php');
exit;
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Add an item</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="../default.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
@import url("../layout.css");
-->
</style>
</head>
<body>
<div id="wrapper" class="bg1">
<div id="header">
	<div id="logo">

	</div>
	<div id="search" class="bg2">
		<!--<form id="form1" name="form1" method="get" action="">
			<input id="inputtext1" type="text" name="textfield" class="input1" />
			<input id="inputsubmit1" type="submit" name="Submit" value="Submit" class="submit1" />
		</form>-->
	</div>
</div>
<!-- end #header -->
	<?php include("../includes/navtop.php"); ?>
<!-- end #menu -->
<div id="page" class="bg4">
	<div class="bg5">
		<div class="bg6" style="padding: 0px 0px 50px 0px;">
			<div id="rightbar">
				<?php include("../includes/login.php");?>
				<?php include("../includes/articles.php");?>
				<?php include("../includes/additions.php"); ?>
			</div>
			<!-- end #rightbar -->
			<div id="content">
				<div id="box2">
					<div class="title bg8">
						<h2 class="text1">Add an Item</h2>
                            </div>
                            <?php
if(isset($_POST['save']))
{
$name = $_POST['name'];
$picture = $_POST['picture'];
$examine = $_POST['examine'];
$operate = $_POST['operate'];
$ituse = $_POST['ituse'];
$members = $_POST['members'];
$quest = $_POST['quest'];
$stats = $_POST['stats'];
$halch = $_POST['halch'];
$lalch = $_POST['lalch'];
$gstore = $_POST['gstore'];
$submitted = $_POST['submitted'];
$found = $_POST['found'];

if(get_magic_quotes_gpc())
{
	$name    = addslashes($name);
	$picture = addslashes($picture);
	$examine = addslashes($examine);
	$operate = addslashes($operate);
	$ituse = addslashes($ituse);
	$members = addslashes($members);
	$stats   = addslashes($stats);
	$quest   = addslashes($quest);
	$halch   = addslashes($halch);
	$lalch   = addslashes($lalch);
	$gstore  = addslashes($gstore);
	$submitted = addslashes($submitted);
	$found   = addslashes($found);
}
include '../connect/config.php';
include '../connect/itemopendb.php';

$query = sprintf("INSERT INTO item (name, picture, examine, operate, ituse, members, stats, quest, halch, lalch, gstore, submitted, found) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
	mysql_real_escape_string($name, $conn),
	mysql_real_escape_string($picture, $conn),
	mysql_real_escape_string($examine, $conn),
	mysql_real_escape_string($operate, $conn),
	mysql_real_escape_string($ituse, $conn),
	mysql_real_escape_string($members, $conn),
	mysql_real_escape_string($stats, $conn),
	mysql_real_escape_string($quest, $conn),
	mysql_real_escape_string($halch, $conn),
	mysql_real_escape_string($lalch, $conn),
	mysql_real_escape_string($gstore, $conn),
	mysql_real_escape_string($submitted, $conn),
	mysql_real_escape_string($found, $conn));
mysql_query($query) or die('Could not connect: ' . mysql_error());
include '../connect/closedb.php';

echo "Item '$name' added";
}
?>
<form method="post">
  <table width="450" border="0" cellpadding="2" cellspacing="1" align="center">
    <tr> 
      <td width="100">Item Name</td>
      <td><input name="name" type="text" class="input3" id="name" size="25"></td>
    </tr>
    <tr> 
      <td width="100">Picture Link</td>
      <td><input name="picture" type="text" class="input3" id="picture" size="25"></td>
    </tr>
    <tr> 
      <td width="100">Examin Info</td>
      <td><textarea name="examine" cols="50" rows="5" class="input3" id="examine"></textarea></td>
    </tr>
    <tr> 
      <td width="100">Operate</td>
      <td><input name="operate" type="text" class="input3" id="operate" size="25"></td>
    </tr>
    <tr> 
      <td width="100">Use</td>
      <td><input name="ituse" type="text" class="input3" id="ituse" size="25"></td>
    </tr>
    <tr> 
      <td width="100">Members <br />(Yes/No)</td>
      <td><input name="members" type="text" class="input3" id="members" size="25" maxlength="3"></td>
    </tr>
    <tr> 
      <td width="100">Stats</td>
      <td><textarea name="stats" cols="50" rows="5" class="input3" id="stats"></textarea></td>
    </tr>
    <tr> 
      <td width="100">Quest <br />(Yes/No)</td>
      <td><input name="quest" type="text" class="input3" id="quest" size="25"></td>
    </tr>
    <tr> 
      <td width="100">High Alch</td>
      <td><input name="halch" type="text" class="input3" id="halch" value="" size="25">
    </td>
    </tr>
    <tr> 
      <td width="100">Low Alch</td>
      <td><input name="lalch" type="text" class="input3" id="lalch" size="25"></td>
    </tr>
    <tr> 
      <td width="100">Gen. Store Price</td>
      <td><input name="gstore" type="text" class="input3" id="gstore" size="25"></td>
    </tr>   
    <tr> 
      <td width="100">Submitted By</td>
      <td><input name="submitted" type="text" class="input3" id="submitted" size="25"></td>
    </tr>
    <tr> 
      <td width="100">Found</td>
      <td><textarea name="found" cols="50" rows="5" class="input3" id="found"></textarea></td>
    </tr>
    <tr> 
      <td colspan="2" align="center"><input name="save" type="submit" class="submit2" id="save" value="Save Item"></td>
    </tr>
  </table>
</form>


				</div>
				<!-- end #box2 -->
			</div>
			<!-- end #content -->
			<div id="leftbar">
				<div id="box6">
					<?php include("editorsnavigation.php"); ?>
                    </div>
                   <center><a href="logout.php"><h1>Logout</h1></a></center>
			</div>
			<!-- end #leftbar -->
                
			<div style="clear: both;"> </div>
		</div>
	</div>
</div>
</div>
<!-- end #wrapper -->
<?php include("../includes/footer.php"); ?>
</body>
</html>

 

thanks, gotta love when i'm stupid >.<

 

`Robot

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.