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. 
 
snip 
 
$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()); 
} 
 
? 
 
/snip 
 
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 Jason Wong
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



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

2004-03-30 Thread Jason Wong
On Tuesday 30 March 2004 20:13, [EMAIL PROTECTED] wrote:

 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.

Yes, that would be the reason.

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

You're not performing any checks on the input you're getting from your form. 
The most simple check for whether the form was submitted is to use:

  if (!empty($_POST)) { // form was submitted }
or
  if (!empty($_GET))  { // form was submitted }

In addition you should always perform sanity checks on values of the 
individual form elements. Search the archives/web for 'sql injection' for 
more info.

-- 
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
--
/*
Place me on a BUFFER counter while you BELITTLE several BELLHOPS in the
Trianon Room!!  Let me one of your SUBSIDIARIES!
*/

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



Re: [PHP-DB] Insert problem

2003-08-14 Thread Kim Kohen
G'day All,

Duh!  Sorry, I had deleted the line that calls the query.  I need to get
home...

cheers

kim


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



RE: [PHP-DB] INSERT problem - please help!

2002-05-28 Thread Jen Swofford

Thanks everyone - it turns out that variables can not begin with a number,
as someone else on this list learned today as well.  Doh!  :)

Jen Swofford
[EMAIL PROTECTED]

 On Tuesday 28 May 2002 06:00, Jen Swofford wrote:
  I have a problem.  I am working on two separate sites on two separate
  servers (one is Linux and one is Unix) and I am doing virtually the same
  thing with each, yet only one of them works.  What can I be doing wrong?

 Check your php.ini files. The one which isn't working would probably have
 register_globals set to Off.

 --
 Jason Wong - Gremlins Associates - www.gremlins.com.hk




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




Re: [PHP-DB] INSERT problem - please help!

2002-05-27 Thread Jason Wong

On Tuesday 28 May 2002 06:00, Jen Swofford wrote:
 I have a problem.  I am working on two separate sites on two separate
 servers (one is Linux and one is Unix) and I am doing virtually the same
 thing with each, yet only one of them works.  What can I be doing wrong?

Check your php.ini files. The one which isn't working would probably have 
register_globals set to Off.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *


/*
Don't kid yourself.  Little is relevant, and nothing lasts forever.
*/


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




RE: [PHP-DB] INSERT problem - please help!

2002-05-27 Thread Jen Swofford

Sigh... they are set to On.  Anything else anyone can think of?

Jen

 On Tuesday 28 May 2002 06:00, Jen Swofford wrote:
  I have a problem.  I am working on two separate sites on two separate
  servers (one is Linux and one is Unix) and I am doing virtually the same
  thing with each, yet only one of them works.  What can I be doing wrong?

 Check your php.ini files. The one which isn't working would probably have
 register_globals set to Off.

 --
 Jason Wong - Gremlins Associates - www.gremlins.com.hk




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




Re: [PHP-DB] INSERT Problem

2001-09-05 Thread Miles Thompson

Have a look at addslashes
http://www.php.net/manual/en/function.addslashes.php
Miles

At 01:20 PM 9/5/01 +0200, shi wrote:
Hi
I'm trying to insert a text into a MYSQL DB, and here is the problem. If the
text looks like this x xx x x xxx 'xxx xxx then PHP interprets the
text following the ' as an sql statement. Does anyone know how to overcome
this problem.

Thank you
Shimon



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] INSERT Problem

2001-05-09 Thread Jeff Oien

OK, did that and it's just printing the INSERT command back to me.

INSERT INTO OVEvents (First_Name, Last_Name) VALUES(Jeff, Oien)

Any help from here? Thanks.
Jeff Oien

 HINT
 echo $sql;
 /HINT
 
 always helpful, then paste that into the command line client and check the
 error
 
 
 Cameron
 
 Jeff Oien wrote:
 
  This is driving me nuts. I can't insert anything into a mysql database
  using PHP. I can insert from the command line when logged in with Telnet.
  Using PHP I can connect and retrieve data from the database, just can't
  INSERT anything.
 
  This is what doesn't work:
  $sql = INSERT INTO $table_name (First_Name, Last_Name)
  VALUES (\Jeff\, \Oien\);
  $result = mysql_query($sql,$connection)  or die(Failed);
 
  or
 
  $sql = INSERT INTO $table_name (First_Name, Last_Name)
  VALUES (\$First_Name\, \$Last_Name\);
  $result = mysql_query($sql,$connection)  or die(Failed);
 
  yet this will work from the command line:
  INSERT INTO TheTable (First_Name, Last_Name)
  VALUES (Jeff, Oien);
 
  Am I missing something? Thanks for any help.
  Jeff Oien
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]
 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] INSERT Problem

2001-05-09 Thread Jeff Oien

That told me my problem. Thank you! I hadn't selected the database
in my connect include but had it in other scripts and not this one.
Long story but thanks for the help. I can stop banging my head now.
Jeff Oien

 on 5/9/01 12:29 PM, Jeff Oien at [EMAIL PROTECTED] wrote:
 
  Am I missing something?
 
 yes. you aren't giving yourself any feedback about what happened when the
 insert failed.
 
 instead of:
 
 $sql = INSERT INTO $table_name (First_Name, Last_Name)
 VALUES (\Jeff\, \Oien\);
 $result = mysql_query($sql,$connection)  or die(Failed);
 
 try:
 
 $sql = INSERT INTO $table_name (First_Name, Last_Name)
 VALUES (\Jeff\, \Oien\);
 if(! $result = mysql_query($sql,$connection)) {
 
 print(ERROR .mysql_errno().: .mysql_error().br\n$sqlbr\n);
 
 }
 
 also- i don't see your code for mysql_connect(). make sure you have a valid
 connection to mysql.
 
 
 
 have a great day
 andy
 
 -- 
 ***
 Andrew Rush :: Lead Systems Developer :: MaineToday.com
 ***
 
 A friend of the devil is a friend of mine - R. Hunter
 
 
 
 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]