Jump to content

[SOLVED] Query Getting whiespace error


cooldude832

Recommended Posts

I've tried moving stuff around changing quotes still get a whitespace escaped error

here is the query

<?php
mysql_query("INSERT INTO `items` 
	(`Status`,`Attack`,`Defense`,`HP`,`ItemClass`,`Version`) 
	VALUES('0','$items['attack']','$items['defense']','$items['hp']','$item['class']','$_POST['version']')"
	or die(mysql_error());
?>
{/code]

Link to comment
Share on other sites

Try this,

<?php
mysql_query("INSERT INTO `items`
	(`Status`,`Attack`,`Defense`,`HP`,`ItemClass`,`Version`)
	VALUES('0','$items["attack"]','$items["defense"]','$items["hp"]','$item["class"]','$_POST["version"]')"
	or die(mysql_error());
?

Link to comment
Share on other sites

now i get:

 

Parse error: syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /hsphere/local/home/pira00/pira00.worldispnetwork.com/kash/createitem.php on line 76

 

line 76 is:

VALUES('0','$items["attack"]','$items["defense"]','$items["hp"]','$item["class"]','$_POST["version"]')"

Link to comment
Share on other sites

I got it, not the way i wanted to do it take it like this

<?php

$values = "'0','".$item['attack']."','".$item['defense']."','".$item['hp']."','".$item['class']."','".$_POST['version']."'";
mysql_query("INSERT INTO `items`
	(`Status`,`Attack`,`Defense`,`HP`,`ItemClass`,`Version`)
	VALUES($values)")or die(mysql_error());
?>

Link to comment
Share on other sites


$attack = $items['attack'];
.
.
.
.
$version = $_POST['version'];

<?php
mysql_query("INSERT INTO `items` 
	(`Status`,`Attack`,`Defense`,`HP`,`ItemClass`,`Version`) 
	VALUES('0','$attack','$items['defense']','$items['hp']','$item['class']','$version')"
	or die(mysql_error());
?>

 

 

Just finish it up.

Link to comment
Share on other sites

Well I'd much rather use a OO Concept, but I'm doing the best with what you gave me.

 

Using POST values directly in your Query string is laughable at best. It's also VERY prone to SQL Injection in it's current state.

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.