0

I am in need of help on this one :( i cannot seem to figure out what i have done wrong, i set up my code just like in teh examples i read and i dont really see anything wrong with the logic (as far as i can tell) but the code will RETURN as data added successfully but i know better cause nothing shows up in teh database.

heres the html

<input type="hidden" name="cnotes" values="<?php echo $u ?>"/>
                              <textarea class="field span12" id="note_text" name="note_text" type="text" rows="9" maxlength="10000"></textarea>
                              <input id="add_note" type="submit" class="pull-right" name="add_note" value="Add Note"></submit>

this code is what i used to collect the data for the submission, i used a hidden input to get the value of the rom number for each entry in my table, then i just take the textarea and add that to the database, really im updating the database with that value being added to an already existing entry in my database, but this is where my issue starts.

In my sql line $note_sql it doesnt seem to really update anything

$note_sql = "UPDATE users SET customer_notes='".$customer_notes."' WHERE id='".$row."'";

here is the whole code

$con = mysqli_connect($host,$uname,$pass,$database) or die(mysqli_error($con));

$customer_notes                     = NULL;

if(isset($_GET['add_note']))
{
    $customer_notes                 = $_GET['note_text'];
    $row                            = $_GET['cnotes'];
}

// $sql = "INSERT INTO userprofile
//             (customer_notes)
//             VALUES
//             ('".$customer_notes."')";

$note_sql = "UPDATE users SET customer_notes='".$customer_notes."' WHERE id='".$row."'";

$result = mysqli_query($con, $note_sql);  
if($result){
    echo ("DATA SAVED SUCCESSFULLY");
} else{
    echo("Input data has failed Please go back and resubmit");
}

if anyone can help it would be GREATLY appreciated!

2
Contributors
3
Replies
24
Views
2 Years
Discussion Span
Last Post by berserk
1

post the code for your form

what method are you using to submit the form?
did you try printing out your variables to make sure you have data?

$note_sql = "UPDATE users SET customer_notes='".$customer_notes."' WHERE id='".$row."'";

$result would return true even if $row = ''

Votes + Comments
excellent advice for debugging
0

i apologize for not including this before

here is the full form code

<form action="addnote.php" method="get">
                            <div class="span12">
                              <h4 style="color:#1577a6;">Notes</h4>

                              <input type="hidden" name="cnotes" values="<?php echo $u ?>"/>
                              <textarea class="field span12" id="note_text" name="note_text" type="text" rows="9" maxlength="10000"></textarea>
                              <input id="add_note" type="submit" class="pull-right" name="add_note" value="Add Note"></submit>
                            </div>
                          </form>

and im glad you pointed out printing it cause this narrows it down a bit, theres no data being passed to my id element of my sql string

UPDATE users SET customer_notes='sdasdcsdfvsdfvsdfvdfsvsdfv' WHERE id=''

this is what i got when i printed out $note_sql

1

NOPE NOPE NOPE i apologize for wasting your time jstfsklh211 this was a stupid error and i should have seen it but i simply was not paying enough attention, NOW TO MAKE UP FOR IT!

ill explain what i did wrong and how i fixed this, you see when i echo out the value in the html part of the form it was actually not echoing anything because i was missing THIS ";" at the end of my line, this method entirely works now that i have managed to fix it but yeah that was my ONLY issue. again sorry for the mix up, but regardless jstfsklh211 thank you for you assistence.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.