Quantcast

Jump to content


Photo

PHP SQL help needed.


  • Please log in to reply
No replies to this topic

#1 Nano

Nano
  • a delicious kiwi

  • 325 posts


Users Awards

Posted 21 June 2015 - 09:41 PM

$id = $_GET['id'];
$name = $_GET['name'];
$image = $_GET['image'];
$description = $_GET['description'];
$type = $_GET['type'];

$mysqli = new mysqli($hostname, $username, $password, $database);

if (mysqli_connect_errno()){
    printf("Connect failed: %s\n", mysqli_connect_error());
		exit();
}else{
	$stmt = $mysqli->prepare("INSERT INTO item_data (id, name, description, image, type) VALUES (?, ?, ?, ?, ?)");
	$stmt->bind_param('isssi', $id, $name, $description, $image, $type);
		if (!$stmt->execute()) {
			echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
		}
	$stmt->close();
}

Why would that be returning 'Execute failed: (1048) Column 'image' cannot be null' when getting called in another PHP Script but fine when I request the exact same URL in browser. Have confirmed that it doesn't receive the $image = $_GET['image'];.

 

Also;

    $data = file_get_contents('http://items.jellyneo.net/?go=item&showitem=' . $value);
	$name = GetBetween('b id="itemname">', '</b>', $data);
	$image = GetBetween('<td id="itemimgcell"><img src="http://images.neopets.com/items/', '.gif"', $data);
	$description = GetBetween('[Super Rare]</b><br>', '<br>', $data);
	$type = GetBetween('&amp;cat=', '&', $data);
	$send = 'id=' . $value . '&name=' . $name . '&image=' . $image . '&description=' . $description . '&type=' . $type;

DERP; sorted it. It was the spaces in the Item Name and Description breaking the posted URL.


Edited by Freestyle, 21 June 2015 - 10:09 PM.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users