-1

When I try to execute my insert query then, I get the following error: enter image description here

Below is my code:

$fname = $posted['firstname'];
$email = $posted['email'];
$phone = $posted['phone'];
$productinfo = $posted['productinfo'];
$amount = $posted['amount'];
$address2 = $posted['address2'];
$country = $posted['country'];
$state = $posted['state'];
$city = $posted['city'];
$zipcode = $posted['zipcode'];
$date = date('y:m:d:h:m:s');

$query = "INSERT INTO `#__rays_donat` (`full_name`, `email`, `phone`, `production_info`, `amount`, `address`, `country`, `city`, `state`, `zipcode`, `form_submit_date`) VALUES ('$fname','$email','$phone', '$productinfo', '$amount', '$address2', '$country', '$city', '$state', '$zipcode', '$date')";

$db->setQuery( $query );

$db->query();

Please help me

  • 2
    The error message says that you are trying to insert into a table that doesn't exist. Check that the table name is correct and that you haven't made any spelling mistakes. – TryHarder Mar 31 '16 at 12:47
  • Flagging to close (and recommend deletion) because this question fails to provide enough detail to confidently provide a solution. (We can only offer blind guesses as to what is wrong) The OP has abandoned this question and this question has a low-likelihood of helping future researchers. – mickmackusa Jun 11 '18 at 2:51
1

Please try sticking to Joomla's coding methods and ensure your table name is correct:

$db = JFactory::getDbo();

$query = $db->getQuery(true);

$columns = array('full_name', 'email', 'phone', 'production_info', 'amount', 'address', 'country', 'country', 'city', 'state', 'zipcode', 'form_submit_date');

$fname       = $db->quote($posted['firstname']);
$email       = $db->quote($posted['email']);
$phone       = $db->quote($posted['phone']);
$productinfo = $db->quote($posted['productinfo']);
$amount      = $db->quote($posted['amount']);
$address2    = $db->quote($posted['address2']);
$country     = $db->quote($posted['country']);
$state       = $db->quote($posted['state']);
$city        = $db->quote($posted['city']);
$zipcode     = $db->quote($posted['zipcode']);
$date        = $db->quote(date('y:m:d:h:m:s'));

$values = array($fname, $email, $phone, $productinfo, $amount, $address2, $country, $state, $city, $zipcode, $date);

$query->insert($db->quoteName('#__rays_donat'))
      ->columns($db->quoteName($columns))
      ->values(implode(',', $values));

$db->setQuery($query);
$db->execute();

Remember that #__ is Joomla's generic table name prefix, so make sure you table name has the same prefix as other tables, for example:

  • jos_users
  • jos_content
  • jos_extensions
  • jos_rays_donat

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.