RE: [PHP-DB] Variables in MySQL Insert Queries

2001-08-24 Thread KSchneider

plague --

unfortunately i don't have the beginnings of this thread, but if your code 
below is verbatim, it looks as though you are missing the mysql_query() 
statement.  that should drop your information.  


kate

 -Original Message-
 From: plague [mailto:[EMAIL PROTECTED]]
 Sent: Friday, August 24, 2001 12:57 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Variables in MySQL Insert Queries
 
 
 I am using this code to connect to my database and insert form data from
 a
 user:
 
 $connect = mysql_connect(myhost,user,pass) or die ( not
 connected);
 @mysql_select_db(dbname);
 $sql=INSERT INTO tablename
 (id,first,last,age,email,sfuser,sfship,icq,ac,loca,ref)
 Values(,`$first`,`$last`,'$age',`$email`,`$sfuser`,`$sfship`,`$icq`,`$ac`,`$
 loca`,`$ref`);
 echo (mysql_affected_rows()?success:failure);
 mysql_close($connect);
 
 The script returns success except for it doesn't insert the data (
 from a
 form ).
 
 The age column is BLOB, not INT.
 
 I would really appreciate the help of someone, as this has really
 stumped
 me.
 
 Thanks,
 
 plague
 
 
 

-- 
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] Newbie: Modify - Delete entries

2001-08-17 Thread KSchneider

Sébastien,

modify and delete submit buttons would probably be your best bet.  my usual
modus operandi is to send an id number (or other qualifying criteria) to
the next page (often i use the very same page so as to not have to re-write
the form).  

ex:
modify:  send id in an input hidden statement with your form information
and use an update query --

input type=hidden name=address_id value=$id

then on the next page

$query = update table set address_lname=$lname address_mname=$mname
address_phone=$phone where address_id = '$id';

for a delete, use the same id field to locate the unique record in the
database:

$query = delete from table where address_id = '$id';

for sort order, use ORDER BY in your select statement:

$result = mysql_db_query($database,select * from addressbook order by nom);
and
$result = mysql_db_query($database,select * from addressbook order by nom
DESC);
will result in a descending sort order.

good luck,
Kate




--
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] list entries alphabetically

2001-08-15 Thread KSchneider

$query = SELECT * FROM table WHERE field = 'criteria' ORDER BY field;
$result = mysql_query(db,$query);

this sort order is ascending.  to get descending order, use:
ORDER BY field DESC

you should, however, go to the previously recommended site for a tutorial.
your questions will be answered in spades there.

cheerio.
kate

At 10:44 PM 8/15/2001 +0200, Andrius Jakutis wrote:
Hello again,

How to list entries alphabeticall way?

Using MYSQL.

Thanks
 


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