Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP saving to MySQL missing characters

Options
  • 17-10-2014 8:06pm
    #1
    Registered Users Posts: 2,054 ✭✭✭


    Hi
    Without postings lots of code...for now..

    I'm updating a MySQL table with PHP that has four fields, two ints and two varchars...all is good except in one of the varchar fields only the first two characters of data are saved...

    anyone ever hear of ought like this?


Comments

  • Registered Users Posts: 6,250 ✭✭✭Buford T Justice


    Zipppy wrote: »
    Hi
    Without postings lots of code...for now..

    I'm updating a MySQL table with PHP that has four fields, two ints and two varchars...all is good except in one of the varchar fields only the first two characters of data are saved...

    anyone ever hear of ought like this?

    Post the SQL query


  • Registered Users Posts: 2,054 ✭✭✭Zipppy


    EDIT FUNCTION - passes values to edit.php...
    currentPage.EditItem = function(id) {
    if (confirm('Are you sure?')) {
        console.log("DetailPage :: edit");
    	var itemm = $("#itemm").val();
        var amount = $("#amount").val();
        var statuss = $("#statuss").val();
    	var Uid = localStorage.getItem("Uid");
    	
    	 if (itemm == "") {
            alert("Please enter item");
        } else if (amount == "") {
            alert("Please enter amount");
        } else if (statuss == "") {
            alert("Please enter status");
        } else {
            $.ajax({
                type:'POST',
                url:'http://www.mywebsite.com/edit.php',
                data:{'Uid':Uid,'itemm':itemm,'amount':amount,'statuss':statuss},
                success: function(data) {
                    alert("Edit item success");
                    window.location.href = "uploadtest.html"	
                },
                error: function() {
                    alert("Edit user failure");
                }
    
                });
    };
    }
    };
    



    PHP

    [PHP]$itemm_id = $_POST;
    $itemm_itemm = $_POST;
    $itemm_amount = $_POST;
    $itemm_statuss = $_POST;

    $qry = "UPDATE balancetable SET itemm = '$itemm_itemm', statuss = '$itemm_statuss', amount = '$itemm_amount'
    WHERE id ='$itemm_id'";

    if (!mysqli_query($con,$qry))
    {
    die('Error: ' . mysqli_error($con));
    }
    echo "success";[/PHP]


    Issue is the statuss field....when record is updated it's only the first two or three characters that are saved.....other fields are fine...I changed column name to statuss from status thinkin that might help but to no avail...
    I have all this working perfectly without using ajax....which has me thinking the issue is with the parameters being passed from ajax rather than the PHP ...
    Any thoughts?


  • Registered Users Posts: 6,494 ✭✭✭daymobrew


    Can you post the details of the table and the columns e.g. are the varchar columns only 2 or 3 char long?


  • Registered Users Posts: 2,054 ✭✭✭Zipppy


    daymobrew wrote: »
    Can you post the details of the table and the columns e.g. are the varchar columns only 2 or 3 char long?

    Columns:
    id: int
    itemm: varchar(50)
    amount: int
    statuss: varchar(50)

    As I said it's only via ajax PHP that this happens to the statuss column...
    Values for column are credit, debit or visa.
    Only 'cr' or 'de' is being saved....sometimes only 'v' too.
    Driving me insane..


  • Registered Users Posts: 2,018 ✭✭✭Colonel Panic


    If you log the values to the console before you make the AJAX request, are they truncated then? What about when you extract them from the $_POST in PHP land?

    You're gonna have to do a little printf debugging to figure this out!


  • Advertisement
  • Registered Users Posts: 2,054 ✭✭✭Zipppy


    Well I sorted it....

    Weird one...

    I was using Ripple Emulator ... once I switched back to normal view all was good....really weird..week of my life wasted...

    Thanks all


Advertisement