Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7794787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:52:38+00:00 2026-06-01T22:52:38+00:00

This code really made me confused. The first and second time I ran it,

  • 0

This code really made me confused.
The first and second time I ran it, it worked perfectly but after that it stopped working

Let me explain it:

I work with 2 tables.
The first table I insert to it the current date, current time and the id of the user the id I take it from the session.
Which I believe works fine.

My problem is in the second table the error I get is the error i typed in the ” print ” after the second insert.

this is my code :

session_start();

//Check whether the session variable SESS_MEMBER_ID is present or not
if(!isset($_SESSION['con_id'])) {
    header("location: login.html");
    exit();
}



$DB_USER ='root';
$DB_PASSWORD='';
$DB_DATABASE='';

$con= mysql_connect($DB_HOST ,$DB_USER , $DB_PASSWORD);
if (!$con) {
    die('Failed to connect to server :'.mysql_error());
}

$db=mysql_select_db($DB_DATABASE);
if (!$db) {
    die("unable to select database");
}


//first table   
$qry="insert into shipment values('',NOW(),CURTIME(),'".$_SESSION['con_id']."');";
$resultop=mysql_query($qry);
//to take the id frome last insert because i need it in the second insert 
$SNo=mysql_insert_id();

if ($resultop) {
$options=$_POST['op'];//this is the name of the check boxe's 
if (empty($options)) {
    header("location: manage_itemsE.php");} 

    // this is the second table .. my reaaal problem 
    $qun=$_POST['Quantit'];
    $size =count($options);

    for ($i =0; $i<$size; $i++) {
        $qqry="insert into shipmentquantity values('".$options[$i]."','".$SNo."','".$qun[$i]."');"; // $options is array of the id's which i took from the checkbox's in the html ... $qun is array of the values i took form html ... i sure this is right ;)
        $resultqun=mysql_query($qqry);
    }

    if ($resultqun) {
        header("location: shipment_order.php");
    }
        else print "error in the Quantity";
}


else print "error in the shipmet";
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T22:52:40+00:00Added an answer on June 1, 2026 at 10:52 pm

    Just add some debug statements to find out what is going wrong. Something like –

    $resultqun = mysql_query($qqry) or print mysql_error();
    

    You need to do some reading about SQL injection as this script is vulnerable. Checkout these pages on the use of prepared statements – PDO::prepare and mysqli::prepare

    UPDATE – here is an example using PDO to interact with your db –

    <?php
    session_start();
    
    //Check whether the session variable SESS_MEMBER_ID is present or not
    if(!isset($_SESSION['con_id'])) {
        header("location: login.html");
        exit();
    }
    
    $DB_USER ='root';
    $DB_PASSWORD='';
    $DB_DATABASE='';
    
    $db = new PDO("mysql:dbname=$DB_DATABASE;host=127.0.0.1", $DB_USER, $DB_PASSWORD);
    
    //first table
    $qry = "INSERT INTO shipment VALUES(NULL, CURRENT_DATE, CURRENT_TIME, ?)";
    $stmt = $db->prepare($qry);
    $resultop = $stmt->execute(array($_SESSION['con_id']));
    
    if(!$resultop){
        print $stmt->errorInfo();
    } else {
    
        $SNo = $db->lastInsertId();
    
        $options = $_POST['op'];//this is the name of the check boxe's
        if (empty($options)) {
            header("location: manage_itemsE.php");
            exit;
        }
    
        // this is the second table .. my reaaal problem
        $qun = $_POST['Quantit'];
        $size = count($options);
    
        $stmt = $db->prepare("INSERT INTO shipmentquantity VALUES(?, ?, ?)");
        for($i = 0; $i < $size; $i++) {
            $resultqun = $stmt->execute(array($options[$i], $SNo, $qun[$i]));
        }
    
        if($resultqun) {
            header("location: shipment_order.php");
        } else {
            print $stmt->errorInfo();
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this seems to be weird but it really happened. I have this code working
I need to get the maximum value out of this code, but it's really
Sorry to bother again, but I really need help transforming this Python2 code into
This is probably really stupid but i can't find the problem with my code.
I've got this really simple piece of code that I thought was the correct
This code returns an error: AttributeError: can't set attribute This is really a pity
I'm not really getting how this code does what it does: char shellcode[] =
I really do not understand how is this error happening at this code. Please
If there is any possibility to make this code simpler, I'd really appreciate it!
It's a really simple problem. I've got HTML code like this : <div> <img

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.