How to add multiple images into database using mysql and php

How to add multiple images into database using mysql and php

// start multiple image

$stmt = $conn->prepare(“INSERT INTO cat_images (img_url, cat_id) VALUES (?, ?)”);
$stmt->bind_param(“si”, $imagePath, $cat_id);
$uploadedImages = $_FILES[‘images’];

$cat_id = $conn->insert_id;

foreach ($uploadedImages[‘name’] as $key => $value) {
$targetDir = “main-images/galleries/”;
$fileName = basename($uploadedImages[‘name’][$key]);
$targetFilePath = $targetDir . $fileName;
if (file_exists($targetFilePath)) {
echo “Sorry, file already exists.<br>”;
} else {
if (move_uploaded_file($uploadedImages[“tmp_name”][$key], $targetFilePath)) {
$imagePath = $targetFilePath;
$stmt->execute();
echo “The file ” . $fileName . ” has been uploaded successfully.<br>”;
} else {
echo “Sorry, there was an error uploading your file.<br>”;
}
}
}
$stmt->close();
$conn->close();

// end multiple image

Email does not comply with addr-spec of RFC 2822. Laravel

This error message indicates that the email address you’re attempting to use doesn’t adhere to the specific formatting guidelines outlined in RFC 2822. This RFC is a fundamental standard for email addresses, defining the correct syntax and structure.

Common Reasons for Non-Compliance:

  1. Missing or Incorrect ‘@’ Symbol: The ‘@’ symbol separates the local part (the username) from the domain part (the email provider). Its absence or incorrect placement is a common cause of this error.
  2. Invalid Local Part: The local part can contain letters (both uppercase and lowercase), numbers, underscores, hyphens, and periods. However, it cannot start or end with a period, and consecutive periods are not allowed.
  3. Invalid Domain Part: The domain part typically consists of one or more domain names separated by periods. Each domain name should adhere to specific rules, such as not starting or ending with a hyphen.
  4. Whitespace or Special Characters: Email addresses should not contain any whitespace characters (spaces, tabs, etc.) or special characters (except those allowed in the local and domain parts).
  5. Case Sensitivity: While email addresses are generally case-insensitive, some systems might be more strict about case. Ensure that the case of the characters matches the expected format.

Example of a Valid Email Address:

 

Example of an Invalid Email Address:

john [email protected]  // Missing '@' and whitespace
[email protected] // Invalid local part with consecutive periods
example@ // Missing domain part

 

Troubleshooting Steps:

  1. Double-check the Email Address: Carefully review the email address for any typos, missing characters, or incorrect formatting.
  2. Consult RFC 2822: If you need more detailed information, refer to the RFC 2822 specification.
  3. Use an Online Validation Tool: There are many online tools available that can validate email addresses based on RFC 2822.

By addressing these common issues and following the guidelines in RFC 2822, you can ensure that your email addresses are valid and compliant.

Simple solution to fix this issue is:
make array of multiple emails like below:

$emails = [‘[email protected]’, ‘[email protected]’];
this issue comes when we want to add multiple email ids for receiving emails.
Hope you Understand.

Secured By miniOrange