Kako ubaciti u bazu

Autor erbi, 07. Rujan 2012, 20:31

0 Članovi i 1 Gost pregledava ovu temu.

erbi

Dal iko zna, zašto mi ovo ne radi, niti ne javi nikakve greške:
        $query = "INSERT INTO #__users (id, name, username, email, password, usertype, block, registerDate, lastvisitDate, activation, params, lastResetTime, resetCount) VALUES ('$user_id', '$name', '$name', '$email', 'qwe','','0','1','12.07.12 13:37', '12.07.12 13:37','','','0000-00-00 00:00:00','0')";
        $doinsert = CCK::DB_loadResultArray( $query ); //perform a query


Ovo sam stavio iznad jedne procedure, koja več ubacuje u bazu.

wooer

Prvo što primjećujem je da u vrijednostima imaš definirano jedno polje viška iza password ('qwe').

Hint: '','0','1' .... Ili nula van ili jedinica
UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity
Documentation & Translation Team Member

erbi

Išao sam po redu. "qwe" je password. Dal se ID ne ubacuje? Je automatski?

erbi

Evo, sad sam uradio ovako:
$query = "INSERT INTO #__users (name, username, email, password, usertype, block, registerDate, lastvisitDate, activation, params, lastResetTime, resetCount) VALUES ('$name', '$user_id', '$email', 'qwe','','0','1','12.07.12 13:37', '12.07.12 13:37','','','0000-00-00 00:00:00','0')";
        $doinsert = CCK::DB_loadResultArray( $query ); //perform a query

Isto ne radi. Samo bjela stranica, nikakvog errora.

Ovo je kod izpod mojeg i kojji radi:
$sSql = "INSERT INTO #__aprt_requests(".
"name, ".
"user_id, ".
"phone, ".
"email, ".
"sms_reminders, ".
"sms_phone, ".
"sms_dial_code, ".
"resource, ".
"category, ".
"service, ".
"startdate, ".
"starttime, ".
"enddate, ".
"endtime, ".
"request_status, ".
"payment_status, ".
"cancellation_id, ".
"booking_total, ".
"booking_due, ".
"credit_used, ".
"coupon_code, ".
"booked_seats, ".
"admin_comment, ".
"booking_language, ".
"manual_payment_collected, ".
"comment ";
$sSql = $sSql.") VALUES(".
"'".$database->getEscaped($name)."',".
"'".$user_id."',".
"'".$database->getEscaped($phone)."',".
"'".$database->getEscaped($email)."',".
"'".$sms_reminders."',".
"'".$database->getEscaped($sms_phone)."',".
"'".$sms_dial_code."',".
"'".$resource."',".
"'".$category."',".
"'".$database->getEscaped($service_name)."',".
"'".$startdate."',".
"'".$starttime."',".
"'".$enddate."',".
"'".$endtime."',".
"'".$request_status."',".
"'".$payment_status."',".
"'".$cancel_code."',".
$grand_total.",".
$amount_due.",".
$applied_credit.",".
"'".$coupon_code."',".
"'".$booked_seats."',".
"'".$database->getEscaped($admin_comment)."',".
"'".$lang->getTag()."',".
"'".$database->getEscaped($manual_payment_collected)."',".
"'".$database->getEscaped($comment)."'";
$sSql = $sSql.")";
//echo $sSql;
//exit;
$database->setQuery($sSql);

if (!$database->query()) {
$err = $database->getErrorMsg();
echo $err;
$database->setQuery("UNLOCK TABLES;");
$database->query();
exit;
}

Zašto mi treba ovo? Morao bi ubaciit neke podatke (name, email, phone) koji se ubacuju u #__aprt_requests i u #__users