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 7590483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:24:46+00:00 2026-05-30T20:24:46+00:00

I want to insert / update data into a MySQL table by using a

  • 0

I want to insert/update data into a MySQL table by using a csv-like data :

function execInsertOrUpdateCompteRendu($compterendu)  // here $compterendu is something like this : -1;2012/03/06 09h 50mn;3;1; 
{
        $resultat = explode("\n",$compterendu);
        $connec = mysql_connect("192.168.1.123:3306","root", "mysqlroot");
        mysql_set_charset('utf8', $connec);
        mysql_select_db("finance",$connec);
        for($i = 0; $i < count($resultat) ; $i++)
        {
            $valeur=explode(";",$resultat[$i]);
            if ($valeur[0] > 0)
            {
                $requete = mysql_query("UPDATE compte_rendu SET  
                cr_date    = '".convertFromDateHM($valeur[1])."',
                cr_lieu    = '".$valeur[2]."',
                cred_id    = '".$valeur[3]."',
                cr_resultat = '".$valeur[5]."',
                cr_comment = '".$valeur[6]."',
                adc_id = '".$valeur[7]."' 
                WHERE cr_id = '".$valeur[0]."'");
            }
            else
            {
                $requete = mysql_query("INSERT INTO compte_rendu SET 
                                        cred_id = '".$valeur[3]."',
                                        cr_date = '".convertFromDateHM($valeur[1])."',
                                        cr_lieu = '".$valeur[2]."',
                                        cr_resultat = '".$valeur[5]."',
                                        cr_comment = '".$valeur[6]."',
                                        adc_id = '".$valeur[7]."'");
            }
        }
        return $resultat[0];
}

This PHP code is a web-service which I call from a J2ME client. The problem is that new data are not inserted in the table when I run the J2ME application ! I debugged the java program and there are no errors there. So what is wrong in my PHP code ?

  • 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-05-30T20:24:47+00:00Added an answer on May 30, 2026 at 8:24 pm

    First, you could try escaping all the text you’re entering into your database with mysql_real_escape_string – otherwise you’re leaving potential for issues to arise. e.g.

    //cr_lieu    = '".mysql_real_escape_string($valeur[2])."',
    

    Also – to convert a string to integer?

    $int = (int)$string;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to merge data into a MySQL table from PHP : <?php function
I'm using a stored procedure to update\insert data into a table using MERGE. One
I have some CSV data files that I want to import into mySQL. I
I want to have an 'updateinfo' table in order to record every update/insert/delete operations
I want to insert something into a STL list in C++, but I only
In my asp.net application,I want to use the detailsview to show/insert/update data in the
I have mysql table with data like this. record will have server with total
I want to insert data in another table only when the data is different.
So i learned how to do a bulk insert using data from one table
I am trying to insert some data into one table and after that is

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.