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
https://forums.phpfreaks.com/topic/59904-solved-query-getting-whiespace-error/
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());
?

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"]')"

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());
?>


$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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.