0

I'm developing a booking calendar, but am having an issue with my 'addactivity' form. The basic logic is that for each date/time a new activity object is created and calls the function toDataBase which then takes the info from the form and puts it into the database. I've stripped out all of the foreach and other logic. Here's the relevant code.

from the form method:

$name=$_POST['activityname'];
$cost=$_POST['activitycost'];
$spaces=$_POST['activityspaces'];
$venue=$_POST['activityvenue'];
$month=$_POST['month'];
$year=$_POST['year'];
$day=$_POST['day'];
$dates[$count]=date('Y-m-d', mktime($month,$day,$year))
$time=$_POST['activitytime'];

and the toDataBase function

public function toDataBase()
{
    $dbc=mysqli_connect($host, $user, $pass,$db);
    if(!$dbc)
    {
        echo ("could not connect".mysqli_connect_error());
        exit();
    }
    $stmt=mysqli_prepare($dbc, "INSERT INTO events(
    name,
    date,
    venue,
    cost,
    spaces,
    time) 
    VALUES (?,?,?,?,?,?)");
    mysqli_stmt_bind_param($stmt,'sssiis',$event_name,$dates,$price,$max_spaces,$venue,$times);
    mysqli_execute($stmt);
    mysqli_stmt_close($stmt);



}

what confuses me most is that I don't get a MySQL error of any sort. I know the activity object's data fields are filling because I have methods for each datafield to echo its value. All fields are filling just fine but aren't going into the DB. My next assumption was that the db is expecting values of a different type. The event table structure is as follows:

name: varchar
date: date
venue: varchar
cost: smallint
spaces: smallint
time: varchar

Sorry for the wall of text, but I'm getting frustrated banging my head against aforementioned wall of text.

edited: switched to better practice: still same issue.

4

1 回答 1

0

经过一些严肃的禅宗发现后,我意识到 $event_name 等是私有变量......只需更改为 $this->event_name 并且一切正常。无论如何,感谢您的帮助。至少我的代码现在不能被利用 =)

于 2012-10-21T23:08:59.340 回答