Go to PHP.net, books @ bookstore.

Seems like you are trying to insert data from an array into a MySQL table, I
would visit http://dev.mysql.com/doc/mysql/en/index.html site too.

Good luck.

===============================


"Ronald "The Newbie" Allen" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I have no idea what a class is .  I really am a newbie.  After you guys
help
> me with this what is a good place to start with learning PHP?
>
> "Richard Hutchins" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > ...or whatever class contains $row-> functionality?
> >
> >
> >
> >
> > > -----Original Message-----
> > > From: Ronald Allen [mailto:[EMAIL PROTECTED]
> > > Sent: Friday, May 14, 2004 4:13 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: [PHP-DB] Re: inserting data into database!
> > >
> > >
> > > Now that I closed the bracket
> > >  it tells me that $row is not defined.
> > > I have plagiarized from a couple of different places to come
> > > up with my code
> > > so that is the reason that it may not work that well.  Here
> > > is my code right
> > > now
> > >
> > > $conn = mysql_connect($db_host,$db_user,$db_pass);
> > > if ($conn == true) {
> > >  $insert = "INSERT INTO $db_table SET ";
> > > $insert .= "Base = '" . $row->Base . "', ";
> > > $insert .= "Date_and_Time = '" . $row->Date_and_Time . "', ";
> > > $insert .= "Event_Type = '" . $row->Event_Type . "', ";
> > > $insert .= "Description = '" . $row->Description . "', ";
> > > $insert .= "Initials = '" . $row->Initials . "'";
> > >
> > > mysql_query($insert, $conn);
> > >
> > > }
> > > ?>
> > > "Ronald Allen" <[EMAIL PROTECTED]> wrote in message
> > > news:[EMAIL PROTECTED]
> > > > Here is my code now, but I am getting a parsing error
> > > >
> > > > Parse error: parse error, unexpected $end
> > > >
> > > > $db_table = 'log';
> > > >
> > > > $conn = mysql_connect($db_host,$db_user,$db_pass);
> > > >
> > > > if ($conn == true) {
> > > >
> > > > $insert = "INSERT INTO $db_table SET ";
> > > >
> > > > $insert .= "Base = '" . $row->Base . "', ";
> > > >
> > > > $insert .= "Date_and_Time = '" . $row->Date_and_Time . "', ";
> > > >
> > > > $insert .= "Event_Type = '" . $row->Event_Type . "', ";
> > > >
> > > > $insert .= "Description = '" . $row->Description . "', ";
> > > >
> > > > $insert .= "Initials = '" . $row->Initials . "'";
> > > >
> > > > mysql_query($insert, $conn);
> > > >
> > > > ?>
> > > >
> > > > "Torsten Roehr" <[EMAIL PROTECTED]> wrote in message
> > > > news:[EMAIL PROTECTED]
> > > > > "Ronald Allen" <[EMAIL PROTECTED]> wrote in message
> > > > > news:[EMAIL PROTECTED]
> > > > > > Two questions?
> > > > > > First why am I getting  undefined variable tmp , yet it works
> > > > > > Second how would I insert data into this table?
> > > > > > <?
> > > > > > $db_table = 'log';
> > > > > > $conn = mysql_connect($db_host,$db_user,$db_pass);
> > > > > >
> > > > > > if ($conn == true) {
> > > > > >   mysql_select_db($db_name,$conn);
> > > > > >   $result = mysql_query("SELECT * from $db_table",$conn);
> > > > > >     while($row = mysql_fetch_object($result)) {
> > > > > >         $tmp .= "ID   : $row->ID   <br>\n";
> > > > > >         $tmp .= "Base : $row->Base <br>\n";
> > > > > >         $tmp .= "Date_and_Time  : $row->Date_and_Time   <br>\n";
> > > > > >         $tmp .= "Event_Type : $row->Event_Type <br>\n";
> > > > > >         $tmp .= "Description : $row->Description <br>\n";
> > > > > >         $tmp .= "Initials : $row->Initials <br><hr>\n";
> > > > > >     }
> > > > > > } else {
> > > > > >     echo 'could not connect to database : '. mysql_error();
> > > > > > }
> > > > > > print $tmp;
> > > > > > ?>
> > > > >
> > > > > You have to initialize $temp before using it with '.='
> > > > > $temp = '';
> > > > > $temp .= 'my string';
> > > > >
> > > > > Or just set the first line with =
> > > > > $tmp = "ID   : $row->ID   <br>\n";
> > > > > $tmp .= "Base : $row->Base <br>\n";
> > > > > $tmp .= "Date_and_Time  : $row->Date_and
> > > > >
> > > > > Your insert should look like this (if ID is an
> > > auto-increment field):
> > > > > $insert = "INSERT INTO $db_table SET ";
> > > > > $insert .= "Base = '" . $row->Base . "', ";
> > > > > $insert .= "Date_and_Time = '" . $row->Date_and_Time . "', ";
> > > > > $insert .= "Event_Type = '" . $row->Event_Type . "', ";
> > > > > $insert .= "Description = '" . $row->Description . "', ";
> > > > > $insert .= "Initials = '" . $row->Initials . "'";
> > > > >
> > > > > mysql_query($insert, $conn);
> > > > >
> > > > > Hope this helps,
> > > > >
> > > > > Regards, Torsten
> > >
> > > -- 
> > > PHP Database Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to