Click to See Complete Forum and Search --> : Problem with SQL query from array


katten
08-14-2006, 06:22 AM
well i have got a problem excuting a query i have located the problem to the varible $info but i don't know whats wrong

Database class

public function createCharacter($account, $name, $vocation, $sex, $access, $info, $content)
{
// check if player exists
if($this->_checkExists($name))
{
throw new SiteException(20, 'Character with the name ('.$name.') allready exists.');
}


// first we need to insert the player info into the table
// so we can get its id
$this->_query("INSERT INTO `players`
(
`account`,
`name`,
`access`,
`sex`,
`level`,
`experience`,
`maglevel`,
`vocation`,
`health`,
`healthmax`,
`mana`,
`manamax`,
`speed`,
`cap`
)
VALUES
(
'". $account."',
'".mysql_real_escape_string($name)."',
'".$access."',
'".$sex."',
'".$info['level']."',
'".$info['exp']."',
'".$info['maglevel']."',
'".$vocation."',
'".$info['health']."',
'".$info['health']."',
'".$info['mana']."',
'".$info['mana']."',
'".$info['speed']."',
'".$info['cap']."'
)");

}


the module witch calls the function

<?php
extract( $http->extract('name','vocation','sex') );
$name = ucwords(trim(strtolower($name)));

// time to prosses the name
if(!ereg('[a-zA-Z][:space:]', $name))
{
throw new SiteException(20, 'Character name can only consist of a to z and space.');
}
if(strlen($name) <= 3)
{
throw new SiteException(20, 'Character name must be longer then three characters');
}
// checks so that the name is not trying to start with admin or gm
if(!$func->validName($name))
{
throw new SiteException(20, 'Trying to in personate a Gamemaster or other staff is not aloud');
}

// stops gamemaster when creating a new char becoming a Gamemaster
$access = $session->access == 3 ? 2 : $session->access;

$charInfo = $sql->select('charsettings', array(), $sql->fieldName('voc').'='.(int) $vocation);
$charItems = $sql->select('playercontent', array(), $sql->fieldName('vocation').'='.(int) $vocation);

$db->createCharacter($session->user['accno'], $name, $vocation, $sex, $access, $charInfo, $charItems);

return array('mode' => 'goto', 'to' => 'account.php');
?>


If i would use this as the function

public function createCharacter($account, $name, $vocation, $sex, $access, $info, $content)
{
// check if player exists
if($this->_checkExists($name))
{
throw new SiteException(20, 'Character with the name ('.$name.') allready exists.');
}


// first we need to insert the player info into the table
// so we can get its id
$this->_query("INSERT INTO `players`
(
`account`,
`name`,
`access`,
`sex`,

)
VALUES
(
'". $account."',
'".mysql_real_escape_string($name)."',
'".$access."',
'".$sex."',

)");

}


it will work

if i print_r($info); i get

SQLResults Object ( [_driver:protected] => MySQL [_connectionID:protected] => Resource id #6 [_results:protected] => Resource id #17 [_row:protected] => Array ( [level] => 15 [voc] => 1 [exp] => 37800 [maglevel] => 4 [health] => 220 [mana] => 240 [cap] => 400 [skill_1] => 10 [skill_2] => 10 [skill_3] => 10 [skill_4] => 10 [skill_5] => 10 [skill_6] => 10 [speed] => 234 ) [_index:protected] => 0 [_eof:protected] => [_numRows:protected] => 1 )


No error is displayed :( error_reporting is set to E_ALL