Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11

Thread: Error

  1. #1
    Regular Coder
    Join Date
    Aug 2013
    Posts
    181
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Error

    PHP Code:


    $maxRooms 
    10;
        
    $fetchQuery "SELECT bookingsystem FROM adult 
                  WHERE startDate = '$_POST[startDate]'"
    ;
        
    $fetchResult mysql_query($fetchQuery);
        
    $numberRooms mysql_num_rows($fetchResult);
            if(
    $numberRooms >= $maxRooms)
            {
                echo 
    "error: All ".$_POST['roomReservation'."s are currently booked."];
            }
            
             else
            {
                
    $insertQuery "INSERT into adult VALUES('$_POST[numberdays]')";
                
    mysql_query($insertQuery) or die(mysql_error());                        
                echo 
    "Registration Complete.";
            } 

    I need help i am getting ,Column count doesn't match value count at row 1.

    I am pretty close to finish making code working, after one month of the making them.

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,029
    Thanks
    23
    Thanked 588 Times in 587 Posts
    Column count doesn't match value count at row 1
    What does this mean??? And your code doesn't do a Column count.

    This
    Code:
    $insertQuery = "INSERT into adult VALUES('$_POST[numberdays]')";
    Should be something like:
    Code:
    INSERT INTO adult (numberdays) VALUES('$_POST[numberdays]');
    And it's bad practice to insert directly from a $_POST. You should clean that up before inserting it into your DB.
    Evolution - The non-random survival of random variants.

  • #3
    Regular Coder
    Join Date
    Aug 2013
    Posts
    181
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Error

    Column count doesn't match value count at row 1 ,that is what am i getting on the page where spouse to be echo "error: All ".$_POST['rooms'."s are currently booked."]; when 11th($maxRooms = 10) rooms same style and same date occupied.

  • #4
    Regular Coder
    Join Date
    Aug 2013
    Posts
    181
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Error

    Any helppppppppp please.

  • #5
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,029
    Thanks
    23
    Thanked 588 Times in 587 Posts
    Did you look at what I said?
    Doing inserts this way:
    Code:
    $insertQuery = "INSERT into adult VALUES('$_POST[numberdays]')";
    the number of things in the values() have to match the columns. To just insert into a single column you need to to do this:
    Code:
    INSERT INTO adult (numberdays) VALUES('$_POST[numberdays]');
    This in red is the name of the column!!!
    Evolution - The non-random survival of random variants.

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Indeed, but you'll probably have to go further than that.
    Since the columns are not required so long as they are in order and either have all values provided OR default values, you'll need to verify that you've provided a valid value for each property in the DB OR that there is a default. You cannot skip over extra using INSERT. . . VALUES syntax, but you can using INSERT. . . SET syntax.

    Also, this makes no sense: echo "error: All ".$_POST['roomReservation'."s are currently booked."];. Do you really have an input on your form named:
    Code:
    <input type="anytypereally" name="roomReservations are currently booked."/>
    or is that simply a misplaced concatination?

    Edit:
    Oh, also you should use a SELECT COUNT, not a SELECT x. No point in wasting memory and time finding records when you just need to count them.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #7
    Regular Coder
    Join Date
    Aug 2013
    Posts
    181
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Error

    echo "error: All ".$_POST['roomReservation'."s are currently booked."];
    roomresarvations i don't have that input just input rooms.
    So this code spouse check datebase for availability of the rooms 10 of the each i do have input rooms if enter number 1 that is mean onebedroom,if enter number 2 that is mean twobeedroms and number 3 apartment.Name of the datebase is bookingsystem ,table name is adult and row call rooms.

    So if someone book rooms number 2 it is 11th booked in same range of the time this code should show on next page echo "error: All ".$_POST['roomReservation'."s are currently booked."];

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    I don't think you understand:
    PHP Code:
    $_POST['roomReservation'."s are currently booked."]; 
    Refers to a posted value with the name 'roomReservations are currently booked', such as a field named:
    Code:
    <input type="anytypereally" name="roomReservations are currently booked."/>
    If you use HTML.
    I would assume that's a typo, and likely just 'roomReservations' is what you want. The rest of the junk in the [] should likely be outside of it.

    This of course won't fix your SQL issue. That's likely a cause of incorrect required properties not being provided during insertion.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #9
    Regular Coder
    Join Date
    Aug 2013
    Posts
    181
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Error

    I have been working on this almost a month,and my bad, because i can't give up.Fou do you have team viewer that you can take look ,in all code and try to fix it.I think you can do.Or you have some suggestions about this code to help me out.I
    deleted $_POST['rooms'."s are currently booked."] but i still have same problem.

  • #10
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    I'm not going to fix this for you.
    Deleting the line won't fix your SQL issues. That is a completely distinct problem for which you need to determine if you have a properly formed SQL query. According to the error, you do not have a valid sql query for your structure.
    The removal of the input field isn't going to fix the issue. That only affects the output in the event of an error.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #11
    Regular Coder
    Join Date
    Aug 2013
    Posts
    181
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Error

    I did fix the problem yeah(hahahha)

    This is code




    $maxRooms = 10;



    $fetchQuery = "SELECT rooms FROM adult
    WHERE startDate = '$_POST[startDate]'";
    $fetchResult = mysql_query($fetchQuery);
    $Rooms = mysql_num_rows($fetchResult);
    if($Rooms >= $maxRooms)
    {
    echo " All rooms are currently booked.";
    }



    But now i have problem how defined maxrooms (number 1-onebedrooms),


    maxrooms (number 2-twobedrooms),


    maxrooms (number 3-threebedrooms),


  •  

    Posting Permissions

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