[PHP-DB] Need HELP with UPDATE & DELETE

2003-12-11 Thread irinchiang

Hi all, 

Right now I'm trying to do a UPDATE and DELETE queries using the following 
code below: But i kept getting error 
"Undefined variable: tutor_id in /usr/local/apache/htdocs/tutor/edit.php on 
line .
Didn't I defined my variable "$tutor_id"I thought I have...
Anyone can help???
Thanks in advance =)

Below is a snip of my code :

---
===edit.php

$dsn = "mysql://root:[EMAIL PROTECTED]/tb1";
$db = DB::connect ($dsn);

   if (DB::isError ($db))
   die ($db->getMessage());

$action = $_GET["action"];

if($action == "delete")
{
$sql = mysql_query ("DELETE FROM tutor WHERE tutor_id='$tutor_id'");
}

if($action == "edit")
{
$sql = mysql_query ("SELECT * FROM tutor WHERE tutor_id 
='$tutor_id'");**ERROR HERE!!*

$row = mysql_fetch_array($sql);

echo "";
echo "Tutor ID : ".$row['tutor_id']."";
echo "";
echo "Name : ";
echo "Contact No : ";
echo "E-mail : ";
echo "Profile : ";
echo "";
echo "";

}
?>

$result = $db->query($sql);

if( DB::isError($result) ) {
die ($result->getMessage());
}

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



[PHP-DB] Need help!!!

2003-12-12 Thread irinchiang


Hi..

Anyone can help me with this script???I kept getting error saying i did not 
define the variable "$tutor_id" and whenever I define it as $tutor_id = $_POST
['tutor_id'], I got error saying there was an "Undefined index"!
What was exactly the problem??
Need help desperately , greatly appreciate any suggestions/help/solutions 
given...

---

===edit.php 
 
$dsn = "mysql://root:[EMAIL PROTECTED]/tb1"; 
$db = DB::connect ($dsn); 

   if (DB::isError ($db)) 
   die ($db->getMessage()); 

$action = $_GET["action"]; 

if($action == "delete") 
{ 
$sql = mysql_query ("DELETE FROM tutor WHERE tutor_id='$tutor_id'"); 
} 

if($action == "edit") 
{ 
$sql = mysql_query ("SELECT * FROM tutor WHERE tutor_id 
='$tutor_id'");**ERROR HERE!!* 

$row = mysql_fetch_array($sql); 

echo ""; 
echo "Tutor ID : ".$row['tutor_id'].""; 
echo ""; 
echo "Name : "; 
echo "Contact No : "; 
echo "E-mail : "; 
echo "Profile : "; 
echo ""; 
echo ""; 

} 
?> 

$result = $db->query($sql); 

if( DB::isError($result) ) { 
die ($result->getMessage()); 
} 
---


Irin.

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



RE: [PHP-DB] Need help!!!

2003-12-12 Thread irinchiang


Yes I'm using a hyperlink to access this page (see below)
echo "Modify";

and so I defined my variable "$tutor_id" as $tutor_id = $_GET['tutor_id'];
but i still got the error: "Undefined index: tutor_id 
in /usr/local/apache/htdocs/tutor/edit.php "

WHat could be the problem?;(


---

how are you getting the $tutor_id var?, in your script you are using "$action 
= $_GET["action"];" so you will need to define $tutor_id like $tutor_id = $_GET
['tutor_id'], or just use $_GET['tutor_id']. 

a form can only put variables in the POST array OR the GET array, and if your 
using hyperlinks to access this script then they will of course be GET vars. 

-Original Message- 
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: 12 December 2003 09:38 
To: [EMAIL PROTECTED] 
Subject: [PHP-DB] Need help!!! 




Hi.. 

Anyone can help me with this script???I kept getting error saying i did not 
define the variable "$tutor_id" and whenever I define it as $tutor_id = $_POST 
['tutor_id'], I got error saying there was an "Undefined index"! 
What was exactly the problem?? 
Need help desperately , greatly appreciate any suggestions/help/solutions 
given... 

---
 

===edit.php 
 
$dsn = "mysql://root:[EMAIL PROTECTED]/tb1"; 
$db = DB::connect ($dsn); 

   if (DB::isError ($db)) 
   die ($db->getMessage()); 

$action = $_GET["action"]; 

if($action == "delete") 
{ 
$sql = mysql_query ("DELETE FROM tutor WHERE tutor_id='$tutor_id'"); 
} 

if($action == "edit") 
{ 
$sql = mysql_query ("SELECT * FROM tutor WHERE tutor_id 
='$tutor_id'");**ERROR HERE!!* 

$row = mysql_fetch_array($sql); 

echo ""; 
echo "Tutor ID : ".$row['tutor_id'].""; 
echo ""; 
echo "Name : "; 
echo "Contact No : "; 
echo "E-mail : "; 
echo "Profile : "; 
echo ""; 
echo ""; 

} 
?> 

$result = $db->query($sql); 

if( DB::isError($result) ) { 
die ($result->getMessage()); 
} 
---
 


Irin. 

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



[PHP-DB] Thanks alot Griffiths!=)

2003-12-12 Thread irinchiang


Thanks alot for your help! That was very careless of me..;p I was stil quite a 
newbie to php-db coding...

By the way one last favour to ask of u hope u dun mind...

I have a script which was used to INSERT data into the database:
(See script below):

But everytime when I execute it I got the error "DB constraint"

I think the problem lies here:

$sql = "INSERT INTO tutor (tutor_name, tutor_contact, tutor_email, 
tutor_profile)
VALUES ($tutor_name,$tutor_contact,$tutor_email,$tutor_profile)";

Whenever I single quote the string value:
 VALUES ($tutor_name','$tutor_contact','$tutor_email','$tutor_profile')";
it actually insert a NULL value into the DB though I did enter values into the 
text field.But if I dun quote it, I got the error:
"DB constraint". By right I ought to quote it right??
I have gone thru my code umpteen times but to no avail. 
Where have i gone wrong??? ;(

---

$dsn = "mysql://root:[EMAIL PROTECTED]/table1";

$db = DB::connect ($dsn);
   if (DB::isError ($db))
   die ($db->getMessage());

//create variables ready to go into DB

$tutor_name = $db->quote($_POST["tutor_name"]);
$tutor_contact = $db->quote($_POST["tutor_contact"]);
$tutor_email = $db->quote($_POST["tutor_email"]);
$tutor_profile = $db->quote($_POST["tutor_profile"]);

$sql = "INSERT INTO tutor (tutor_name, tutor_contact, tutor_email, 
tutor_profile)
VALUES ($tutor_name,$tutor_contact,$tutor_email,$tutor_profile)";

$result = $db->query($sql);
  if( DB::isError($result) ) {
die ($result->getMessage());
}
?>

Add Tutor










"  
method="post">



 Name:
 
   

Contact No:

   

Email:
 
   


Profile:
 





 

   








Teacher:




Contact No:





E-mail Address:





Profile:










---
(I'm terribly sorry if the code is kinda messy)

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] Display Mysql Result in drop down list

2003-12-22 Thread irinchiang

Hi all, 

Right now I'm trying to retrieve one of the column "tutor_name" and display al 
the tutor's name in a drop down list. The problem now is, the drop down list 
only manage to display 1 record from that row instead of all tutor's name 
under "tutor_name" column...wonder where the problem lies??
Hope to get some help soon.
Below is a snip of the code: 
Drop me a msg if anyone needs the entire code.




" .$row
["tutor_name"]. "";
 }
 $result = $db->query($sql);

?>



Thanks in advance =)

Irin.

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



Re: [PHP-DB] Re: Display Mysql Result in drop down list

2003-12-23 Thread irinchiang
Hi:

then now i'm trying to select a value from the drop down list, echo the value 
i have selected and lastly INSERT the value into DB with the following :
Below's a snippet of code:


//retrieve all "tutor_name" from DB and display in drop down list


" .$row
["tutor_name"]. "";
 }
 $result = $db->query($sql);

?>





***INSERT selected values into DB**
$tutor_name = $_POST["tutor_name"];

$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')";

//execute query statement
$result = $db->query($sql);





*echo the value i have selected***





Problem: I was unable to echo the value i selected from drop down as well as 
INSERT into DB...wonder where have i gone wrong???
Reali need some help here...all help are greatly appreciated =)
Thanks in advance.


Irin.

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



[PHP-DB] INSERT into 2 different tables??

2003-12-23 Thread irinchiang


Hi all:

Just wana ask is it possible to have only one form and when i submit, it 
should INSERT data into 2 diff tables??
Hope u get my idea...


Merry X'Mas!!

Irin.

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



RE: [PHP-DB] Re: Display Mysql Result in drop down list

2003-12-25 Thread irinchiang
Hi:

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

$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')";





" .$row
["tutor_name"]. "";
 }
 $result = $db->query($sql);

?>






---

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_name"same 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 :



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.

---
On Tue, 23 Dec 2003 16:00:04 -0500, "Aleks @ USA.net" <[EMAIL PROTECTED]> wrote:
---
Hi, 

I am looking at your code and have a question, in your code you have 

print "" .$row ["tutor_name"]. 
""; 

Doesn't the SELECTED piece mark everything listed as selected?? When you 
bring up the page with the drop down list and open the source, what does it 
show?? 

I handle this  a little differently, I create my drop down list as follows: 

=== Code used  

// First I retrieve all customer information 

$BB = mysql_query("SELECT * FROM customer ORDER BY CID "); 



// Then I create the drop down list 

 


$Sname     $SCity 
    $SState     $SCountry \n");   

  } 
  
?> 

 

=== Code used  

This will create a drop down list where the value of the option is the sites 
ID. In another part of this form, if there is a value set for $Customer, 
then it will set the $add to selected. This will then make the drop down 
list auto select the customer. 

The code above is passed to another form for processing and is were the 
insert data occurs. Using this method I can echo the form data easily 

Hope this helps... 

Aleks 



-Original Message- 
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, December 23, 2003 4:33 AM 
To: David Robley 
Cc: [EMAIL PROTECTED] 
Subject: Re: [PHP-DB] Re: Display Mysql Result in drop down list 

Hi: 

then now i'm trying to select a value from the drop down list, echo the 
value i have selected and lastly INSERT the value into DB with the following 
: 
Below's a snippet of code: 

 
//retrieve all "tutor_name" from DB and display in drop down list 

 " 
.$row ["tutor_name"]. "";  }  $result = $db->query($sql); 

?> 
 

 

 
***INSERT selected values into 
DB** $tutor_name = $_POST["tutor_name"]; 

$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' 
)"; 

//execute query statement 
$result = $db->query($sql); 

 


 
*echo the value i have 
selected*** 
 

 


Problem: I was unable to echo the value i selected from drop down as well as 
INSERT into DB...wonder where have i gone wrong??? 
Reali need some help here...all help are greatly appreciated =) Thanks in 
advance. 


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-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:
---
 
$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')";


 

 
 " .$row
["tutor_name"]. " ";
 }
 $result = $db-> query($sql);

?> 
 

 

 

---

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_name"same 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 :

 

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] INSERT into mysql from dynamic drop down

2004-01-06 Thread irinchiang

Hi all, 

   Right now i would like to INSERT the values from a dynamic drop down 
menu into mysql database but encountered some problem here. Values in the drop 
down menu are retrieved from DB as follows:




" .$row["tutor_name"]. "";
 }
$result = $db->query($sql);

?>




---

echo $_POST["tutor_name"];

INSERT statement:

$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')";

---

I am trying to POST the values and then INSERT into DB but was not able to do 
so(all other values eg. class_code, edu_level etc...was able to be 
INSERTED into DB but not "tutor_name". So, how do i insert values into DB from 
a dynamic drop down and where have i gone wrong???Hope to get some help real 
soon.=)

All help are greatly appreciated. Thanks in advance.


Regards, 
Irin. 

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



[PHP-DB] INSERT dynamic values problem - Need help urgently!

2004-02-27 Thread irinchiang
Hi all:

I am trying to create a registration form whereby one of the user input is as 
follows: (a drop down menu with values retrieved from DB):
-

Class Code:


" .$row["class_code"]. "";
 }
$result = $db->query($sql);

?>



-

My problem was:

1. I was unable to print the values I have selected from this drop down menu 
and 

2. insert this "dynamic values" into the DB??

I was able to insert static values into DB but not "dynamic" values...
How should I go about doing this? 
Really need some help here...


Thanks in advance. All help are greatly appreciated.


Regards,
 
Irin.

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



[PHP-DB] Select Query--Need help urgently

2004-03-26 Thread irinchiang
Hi all, 

I am having having a slight problem with SELECT query statement.

I have a table "Class". The table are as follow:

++--+--+-+-++
| Field  | Type | Null | Key | Default | Extra  |
++--+--+-+-++
| class_id   | int(11)  |  | PRI | NULL| auto_increment |
| class_code | varchar(255) |  | | ||
| edu_level  | varchar(16)  |  | | ||
| student_name   | varchar(255) |  | | ||
| tutor_name | varchar(255) |  | | ||
| timetable_day  | varchar(255) |  | | ||
| timetable_time | varchar(255) |  | | ||
++--+--+-+-++

I am doing a SELECT query to retrieve some of the fields like timetable_time, 
tutor_name, class_code and edu_level from the table WHERE the timetable_day is 
equal to "Monday" . Meaning it will display fields only when the timetable_day 
value is "Monday"

Below is a snip of my code:



$timetable_time = $_GET["timetable_time"];
$class_code = $_GET["class_code"];
$edu_level = $_GET["edu_level"];
$tutor_name = $_GET["tutor_name"];

$sql = mysql_query("SELECT * FROM class where timetable_day='Monday'");

$row = mysql_fetch_array($sql);
$result = $db->query($sql);
$numofrows = mysql_num_rows($sql);

echo "";
echo "";
echo "\n";
echo "";
echo "Monday";
echo "Time";
echo "Classcode";
echo "Level";
echo "Tutor";
echo "";


echo "".$row
['timetable_time']."";
echo "".$row
['class_code']."";
echo "".$row
['edu_level']."";
echo "".$row
['tutor_name']."";
echo "";



But I was unable to retrieve the values from database. Was it because I have 
written the SELECT query wrongly??

Realli need some help urgently..Hope to hear from all soon. Thanks in advance.

Regards, 
Irin

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



[PHP-DB] INSERT problem--Need help urgently

2004-03-29 Thread irinchiang
Hi all:

I was having some problem with INSERT query here and do hope to get some help 
real soon.

I have a form whereby once the form is submitted, the values entered shall be 
inserted into the database. Next I have also written a SELECT query to view the 
records which have just been inserted into the database. 

Data was able to insert into the database and I was also able to retrieve these 
data from database. However, my problem is, whenever a form was being 
submitted, it actually INSERT another row of null values into the database. And 
so, when I clicked to view my data, i can see the previously inserted values as 
well as an empty row of records. 

Why is this so? How can I prevent the row of null value to be inserted?

I have included a snip of my code below and hope to get some help real soon. 
All help are greatly appreciated. Thanks in advance.



$dsn = "mysql://root:[EMAIL PROTECTED]/databaseName";

$db = DB::connect ($dsn);
   if (DB::isError ($db))
   die ($db->getMessage());

$tutor_name = $_POST["tutor_name"];
$tutor_contact = $_POST["tutor_contact"];
$tutor_email = $_POST["tutor_email"];
$tutor_profile = $_POST["tutor_profile"];

$sql ="INSERT INTO tutor (tutor_name, tutor_contact, tutor_email, tutor_profile)
   VALUES('$tutor_name','$tutor_contact','$tutor_email','$tutor_profile')";


$result = $db->query($sql);

if( DB::isError($result) ) {
die ($result->getMessage());
}

?>



Is there anything wrong with my SELECT query ??

Thanks in advance.

Regards, 
Irin

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



Re: [PHP-DB] INSERT problem--Need help urgently

2004-03-30 Thread irinchiang
sorie it was my typo error. actually in my code there is already {} with my 
first if statement and there is also a space after VALUES...
I still need some help here with my code...how can I prevent it from inserting 
a duplicate row of null values>???

Anyone can help ?

Thanks in advance.

Regards, 
Irin
---
Hi, 

I'm not very good at reading other people code, but : 
there is no { } with your first if statement 
there is no space after VALUES 

Sorry I don't have time to test what I'm writing. 
hope it helps 
Chris 

>Hi all: 
> 
>I was having some problem with INSERT query here and do hope to get some help 
>real soon. 
> 
>I have a form whereby once the form is submitted, the values entered shall be 
>inserted into the database. Next I have also written a SELECT query 
>to view the 
>records which have just been inserted into the database. 
> 
>Data was able to insert into the database and I was also able to 
>retrieve these 
>data from database. However, my problem is, whenever a form was being 
>submitted, it actually INSERT another row of null values into the 
>database. And 
>so, when I clicked to view my data, i can see the previously 
>inserted values as 
>well as an empty row of records. 
> 
>Why is this so? How can I prevent the row of null value to be inserted? 
> 
>I have included a snip of my code below and hope to get some help real soon. 
>All help are greatly appreciated. Thanks in advance. 
> 
> 
> 
>$dsn = "mysql://root:[EMAIL PROTECTED]/databaseName"; 
> 
>$db = DB::connect ($dsn); 
>if (DB::isError ($db)) 
>die ($db->getMessage()); 
> 
>$tutor_name = $_POST["tutor_name"]; 
>$tutor_contact = $_POST["tutor_contact"]; 
>$tutor_email = $_POST["tutor_email"]; 
>$tutor_profile = $_POST["tutor_profile"]; 
> 
>$sql ="INSERT INTO tutor (tutor_name, tutor_contact, tutor_email, 
>tutor_profile) 
> 
>VALUES('$tutor_name','$tutor_contact','$tutor_email','$tutor_profile')"; 
> 
> 
>$result = $db->query($sql); 
> 
>if( DB::isError($result) ) { 
> die ($result->getMessage()); 
>} 
> 
>?> 
> 
> 
> 
>Is there anything wrong with my SELECT query ?? 
> 
>Thanks in advance. 
> 
>Regards, 
>Irin 

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



Re: [PHP-DB] INSERT problem--Need help urgently

2004-03-30 Thread irinchiang
Hi Jason:

okay I have echoed $sql and before I did enter anything into the form, the form 
is already inserting null values into the database. Maybe that is the reason 
for the duplicate row of null values. 

Do you know how can I prevent this from happening??Hope to hear from you soon.

Regards, 
Irin.
---

On Tuesday 30 March 2004 19:46, [EMAIL PROTECTED] wrote: 
> sorie it was my typo error. actually in my code there is already {} with my 
> first if statement and there is also a space after VALUES... 

Whenever you post code, use copy and paste, or be extremely meticulous that 
you do not introduce typos. This will ensure that people can focus on your 
real problem and not on your erroneously introduced typos. 

> I still need some help here with my code...how can I prevent it from 
> inserting a duplicate row of null values>??? 

echo() your $sql statement just before you execute it. Are you doing any 
redirections or refreshing the page? 

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz 
Open Source Software Systems Integrators 
* Web Design & Hosting * Internet & Intranet Applications Development * 
-- 
Search the list archives before you post 
http://marc.theaimsgroup.com/?l=php-db 
-- 
/* 
I've read SEVEN MILLION books!! 
*/ 

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