[PHP-DB] Problem with INSERT Query

2003-12-30 Thread irinchiang


Hi all:

Well, when i bring out the page with the drop down list it was able to display 
all tutors' names from tutor_name column. Anyway here's a review of my code
(snip) again before i continue:
---
snip 
$sql = INSERT INTO class (class_code, tutor_name, edu_level, timetable_day,   
timetable_time)
VALUES
('$class_code','$tutor_name','$edu_level','$timetable_day','$timetable_time');


?//retrieve data from DB  display in dynamic drop down ? 

SELECT class=textarea name=tutor_name / 
?


$sql = mysql_query(SELECT DISTINCT tutor_name FROM tutor );
while ($row = mysql_fetch_array($sql))
{
 print OPTION VALUE=\$tutor_name\ SELECTED  .$row
[tutor_name]. /option ;
 }
 $result = $db- query($sql);

? 
/select 

?

while($selected_tutor_name == $tutor_name)
echo $_POST[tutor_name];

? 

/snip 

---

so when i submit the form, i am suppose to echo the values i have entered into 
the field and then INSERT the values into DB (Queries stated above). However i 
was able to echo all other values eg. class_code, edu_level, etc...but 
not tutor_namesame thing happen when i do an INSERT, all other values 
are inserted into DB but not $tutor_namewhy is this so???Really need some 
help here...Anyway i have already specify a name to be reference :

SELECT class=textarea name=tutor_name  

and then I also did an echo of tutor_name being selected:

while($selected_tutor_name == $tutor_name)
echo $_POST[tutor_name];

All help are greatly appreciated =)

Irin.

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



[PHP-DB] problem with insert query

2003-06-07 Thread Ahmed Abdelaliem
hi
i am wrote a script to read e-malis from a file and insert it into the 
tables of database
i get error when i write it
here is the code
can anyone tell me what is wrong?

?
$mails=file(mails.txt);
$number_of_mails = count($mails);
for ($i=0; $i$number_of_mails; $i++){

@ $db = mysql_connect(localhost);
mysql_select_db(me2resh00);
$query = insert into recipients (recipient_name, recipient_email) values 
('friend', '.$mails[$i].');
$result = mysql_query($query);
if ($result)
	echo mysql_affected_rows(). affected.;

  }
?
here is the error that i get

Parse error: parse error in enter.php on line 9

and line 9 is

$query = insert into recipients (recipient_name, recipient_email) values 
('friend', '.$mails[$i].');

_
MSN 8 with e-mail virus protection service: 2 months FREE* 
http://join.msn.com/?page=features/virus

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


Re: [PHP-DB] problem with insert query

2003-06-07 Thread Becoming Digital
Try this.  I made some minor syntax changes and added some error reporting.
While it may not fix things, it might help you figure out what's wrong.

?
$mails=file(mails.txt);
$number_of_mails = count($mails);

for ($i=0; $i$number_of_mails; $i++)
{
$link = @ mysql_connect(localhost)
or die( mysql_error() );
$db = mysql_select_db(me2resh00, $link);
$query = insert into recipients (recipient_name, recipient_email) values
(\friend\, \.$mails[$i].\);
$result = mysql_query($query);
if ($result)
echo mysql_affected_rows(). affected.;
}
?

Edward Dudlik
Becoming Digital
www.becomingdigital.com


- Original Message -
From: Ahmed Abdelaliem [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Saturday, 07 June, 2003 08:15
Subject: [PHP-DB] problem with insert query


hi
i am wrote a script to read e-malis from a file and insert it into the
tables of database
i get error when i write it
here is the code
can anyone tell me what is wrong?

?
$mails=file(mails.txt);
$number_of_mails = count($mails);

for ($i=0; $i$number_of_mails; $i++){

 @ $db = mysql_connect(localhost);
mysql_select_db(me2resh00);
$query = insert into recipients (recipient_name, recipient_email) values
('friend', '.$mails[$i].');
$result = mysql_query($query);
if ($result)
echo mysql_affected_rows(). affected.;

   }
 ?


here is the error that i get

Parse error: parse error in enter.php on line 9


and line 9 is

$query = insert into recipients (recipient_name, recipient_email) values
('friend', '.$mails[$i].');

_
MSN 8 with e-mail virus protection service: 2 months FREE*
http://join.msn.com/?page=features/virus


--
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



Re: [PHP-DB] problem with insert query

2003-06-07 Thread Jeff Shapiro

It seems to me that this code will not provide useful information:

if ($result)
echo mysql_affected_rows(). affected.;

If the insert was successful, it will always say 1 affected. Since 
you are only inserting one row at a time. 

On Sat, 07 Jun 2003 08:49:15 -0400, Becoming Digital wrote:
 Try this.  I made some minor syntax changes and added some error reporting.
 While it may not fix things, it might help you figure out what's wrong.
 
 ?
 $mails=file(mails.txt);
 $number_of_mails = count($mails);
 
 for ($i=0; $i$number_of_mails; $i++)
 {
 $link = @ mysql_connect(localhost)
 or die( mysql_error() );
 $db = mysql_select_db(me2resh00, $link);
 $query = insert into recipients (recipient_name, 
 recipient_email) values
 (\friend\, \.$mails[$i].\);
 $result = mysql_query($query);
 if ($result)
 echo mysql_affected_rows(). affected.;
 }
 ?
 
 Edward Dudlik
 Becoming Digital
 www.becomingdigital.com
 
 
 - Original Message -
 From: Ahmed Abdelaliem [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Saturday, 07 June, 2003 08:15
 Subject: [PHP-DB] problem with insert query
 
 
 hi
 i am wrote a script to read e-malis from a file and insert it into the
 tables of database
 i get error when i write it
 here is the code
 can anyone tell me what is wrong?
 
 ?
 $mails=file(mails.txt);
 $number_of_mails = count($mails);
 
 for ($i=0; $i$number_of_mails; $i++){
 
  @ $db = mysql_connect(localhost);
 mysql_select_db(me2resh00);
 $query = insert into recipients (recipient_name, recipient_email) values
 ('friend', '.$mails[$i].');
 $result = mysql_query($query);
 if ($result)
 echo mysql_affected_rows(). affected.;
 
}
  ?
 
 
 here is the error that i get
 
 Parse error: parse error in enter.php on line 9
 
 
 and line 9 is
 
 $query = insert into recipients (recipient_name, recipient_email) values
 ('friend', '.$mails[$i].');
---
Listserv only address.
Jeff Shapiro

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