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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

PHP saving to MySQL missing characters

  • 17-10-2014 7:06pm
    #1
    Registered Users, Registered Users 2 Posts: 2,055 ✭✭✭


    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, Registered Users 2 Posts: 6,262 ✭✭✭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, Registered Users 2 Posts: 2,055 ✭✭✭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, Registered Users 2 Posts: 6,570 ✭✭✭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, Registered Users 2 Posts: 2,055 ✭✭✭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, Registered Users 2 Posts: 2,040 ✭✭✭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, Registered Users 2 Posts: 2,055 ✭✭✭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