DELETe row

C++, C#, Java, PHP, ect...
Post Reply
Zester
Posts: 53
Joined: Sat Mar 03, 2012 11:33 pm

DELETe row

Post by Zester »

I Have changed the caps and quotes, and every thing looks good just do not see Y it will nor delete the data .

Code: Select all

session_start();
include_once 'lqlotl_functions.php';
CheckAccessSSG(1);
?>
<?php
    $userid=$_SESSION['userid'];	
	$username=$_SESSION['username'];
	$_SESSION['ingame']='lqlotl';
	$char=$_GET['char'];
	echo "the char is " . $char . "!!!!";
	
  $query = "DELETE * FROM 'lqlotl'.'characters' WHERE 'characters'.'name'=$char";
  $result = mysql_query($query) or die("Could not Delete char ");
  if (!$result) {
	  header("Location: login.php?");
	  echo "Delete failed char";
		}
	else {
	  header("Location: login.php?");
	  echo "Delete char Success"; 
	}		

?>
<!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>Lords Quest Lands of the Lost Login</title>
<link rel="stylesheet" type="text/css" href="styles/style.css"/>
</head>
<body>
<div id="wraper" align="center">
<table border="2" >
<tr>
<td>
<?php include_once '../../header.php'; ?>
</td>
</tr>

<tr>
<td>
<div id="Nav"><?php include_once '../../nav.php'; ?></div>
</td>
</tr>
<tr>
<td>
<div id="main">
<table border="2" >
	<tr>
  	  <td><div id="rightpanel">
      <?php  if ($playerfound=="yes") {	include_once 'Playerpanel.php';}?>
                
      </div></td>
  	  <td><div id="mainarea"><center>
      <?php  if ($playerfound=="yes") {
		  		include_once 'Playersheet.php';
	  			}
			else {
					echo '<center>We did not see any game data under your name<br />';
					echo 'Click the enter world button if you are entering the game world for the frist time.<br />';
					echo '<a href="register.php">Enter World</a><br />';
			}
		      
 ?>
User avatar
Ark
Posts: 427
Joined: Wed Jun 01, 2011 10:25 pm

Re: DELETe row

Post by Ark »

You can only delete the row so you don't need to specify the *

change it to:

Code: Select all

$query = "DELETE FROM 'lqlotl','characters' WHERE 'characters'='$characters' AND  'name'=$char"; // <-- use comma at from use 'AND' at where
maybe it works :roll:
Orgullo Catracho
User avatar
Chris
Posts: 1580
Joined: Wed Sep 30, 2009 7:22 pm

Re: DELETe row

Post by Chris »

Your syntax is wrong.

Code: Select all

$query = "DELETE * FROM 'lqlotl'.'characters' WHERE 'characters'.'name'=$char"; 
Should be

Code: Select all

$query = "DELETE * FROM `lqlotl`.`characters` WHERE `characters`.`name` = '$char'"; 
Or

Code: Select all

$query = "DELETE * FROM lqlotl.characters WHERE characters.name = '$char'"; 
Use mysql_error() to see what the last error mysql had was. (Only do this during development)

Code: Select all

$result = mysql_query($query) or die("Could not Delete char." . mysql_error() ); 
Fighting for peace is declaring war on war. If you want peace be peaceful.
Zester
Posts: 53
Joined: Sat Mar 03, 2012 11:33 pm

Re: DELETe row

Post by Zester »

Thankz guys,

that mysql_error() help alot.

cheers
Post Reply

Return to “Coding”