www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] MySQLi fail - trying to INSERT

Hybrid View

  1. #1
    Join Date
    Apr 2011
    Location
    New Home Team - Everett, WA
    Posts
    261

    resolved [RESOLVED] MySQLi fail - trying to INSERT

    Ok, so I've pinpointed the problem to this spot:

    PHP Code:
    $query "INSERT INTO project(`id`, `name`, `summary`, `client_id`, `detail`, `link`, `scope`, `type`, `progress`, `status`)
    VALUES (NULL, 'Project Title', 'Summary of Project', '2', 'Details', NULL, 'Scope Example', 'project type', NULL, 1)"

    if ($result $mysqli->query($query)) {
        
    // Never gets to this spot...
        
    echo("Success!");
    }else{
        
    // This is what it gives me... every time
        
    echo("Error Message");

    I've tried a bunch of different display-a-specific-error-message things, but none of them show anything.

    Any help or advice would be greatly appreciated. Thanks in advance!

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,921
    See if this gives you any useful info:
    PHP Code:
    else {
        echo 
    "<pre>".print_r($mysqli->errortrue)."</pre>";

    (Ultimately you'll want something that doesn't splash application/database info on the user's screen, but for now it should hopefully give you the needed info.)
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Apr 2011
    Location
    New Home Team - Everett, WA
    Posts
    261
    That helped immensely! Apparently one of the values being passed (a 0 where it is anything from 0 to 100) was being passed as NULL, but "NULL" wasn't marked in the database, so I made it number_format($variable) and that did the trick. Thank you very much!

    An alternative solution would've been to change it to accept "NULL" in the database too, but I prefer it be stored as a number, so oh well -- and this is the only place it can be added or edited from, so if that's covered then there's really no harm in keeping it as it is.

    And now that it's fixed, I can clean it up and remove (or hide) the comment bits. I had a whole list of them with each step in the process, which is how I narrowed it down to which one was having a problem.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles