I am creating a custom joomla module based on form submission
but i am having some problems in inserting the values
I have a html form which has certain fieldsets which pass values to mod_score.php which checks for empty validation and proceeds for helper.php where i have the function for inserting the form values.
Testing it on my localhost (XAMPP )
Version 3.4
Template Protostar
// This is the class
class modScoreCardHelper
{
function saveCard($params)
{
$input= new JInput;
$match_id = $input->get('match_id',null);
$match_time = $input->get('match_time',null);
$match_venue = $input->get('match_venue',null);
$match_team_one = $input->get('match_team_one',null);
$match_team_two = $input->get('match_team_two',null);
$match_result = $input->get('match_result',null);
$match_umpire_one = $input->get('match_umpire_one',null);
$match_umpire_two = $input->get('match_umpire_two',null);
$match_mom = $input->get('match_mom',null);
$match_toss = $input->get('match_toss',null);
$match_fow = $input->get('match_fow',null);
$match_comments = $input->get('match_comments',null);
$match_debutants = $input->get('match_debutants',null);
// Get a db connection.
$db = JFactory::getDbo();
echo 'starting to insert in db';
// Create a new query object.
$query = $db->getQuery(true);
// Insert columns.
$columns = array('match_id', 'match_time', 'match_venue', 'match_result','match_team_one',
'match_team_two','match_umpire_one','match_mom','match_comments','match_debutants',
'match_umpire_two','match_toss','match_fow');
$values = array($match_id, $match_time, $match_venue,$match_result,$match_team_one,
$match_team_two,$match_umpire_one,$match_mom,$match_comments,
$match_debutants,$match_umpire_two,$match_toss,$match_fow);
// Prepare the insert query.
$query->insert($db->quoteName('#__match_record'))
->columns($db->quoteName($columns))
->values(implode(',', $values));
// Set the query using our newly populated query object and execute it.
$db->setQuery($query);
$db->execute();
}
}
I simply copied the query in phpmyadmin and executed the code it gave me error 1064 as it is showing on the site.I searched a lot on google and added double quotes to the column values field like "MI "," RCB " in phpmyadmin and the query executed sucessfully .there but i do not know how to add double quotes.Also in the query it is deleting the spaces in the values
For example : actual value = MI won becomes MIwon.
how to remove those spaces and double quotes in my query and remove this error Thanks in advance
match_id
exist? Have you also ensured that all the values are being pulled correctly? Tryvar_dump($match_id);
and see what the outcome is