Re: [PHP-DB] SELECT query with multiple WHERE Clause

2008-02-27 Thread Stephen Johnson
$query = mysql_query(SELECT * from gig WHERE gigName='$gig_name' or
gig_fdate='$sdate');

You can not use more then one WHERE in your sql statement... And SQL accepts
OR and AND..  


--
Stephen Johnson c | eh
The Lone Coder

http://www.thelonecoder.com
continuing the struggle against bad code

http://www.fortheloveofgeeks.com
I¹m a geek and I¹m OK!
--




 From: Nasreen Laghari [EMAIL PROTECTED]
 Date: Wed, 27 Feb 2008 15:44:23 -0800 (PST)
 To: php-db@lists.php.net
 Subject: [PHP-DB] SELECT query with multiple WHERE Clause
 
 
 
 $query = mysql_query(SELECT * from gig WHERE gigName='$gig_name' ||
 gig_fdate='$sdate');

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



Re: [PHP-DB] force to download file

2007-12-17 Thread Stephen Johnson
IE likes excel files, and wants to open them for you since it is such a
helpful application...

If you want to force the download you need to lie to the browser and claim
you are passing a file that it won't know what to do with.

You can try an exe header, but that will likely prompt security warnings
that will bug your users.



--
Stephen Johnson c | eh
The Lone Coder

http://www.thelonecoder.com
continuing the struggle against bad code

http://www.thumbnailresume.com
--




 From: Hiep Nguyen [EMAIL PROTECTED]
 Date: Mon, 17 Dec 2007 15:13:45 -0500
 To: php-db@lists.php.net
 Subject: [PHP-DB] force to download file
 
 hi all,
 
 i have this on top of my php page:
 
 header(Content-Type: application/vnd.ms-excel);
 header(Content-Disposition: inline; filename=excelfile.xls);
 
 but it is not prompt to save the file instead it opens right in IE.
 
 my question is how do i force the browser prompts to save the file?
 
 thanks

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



Re: [PHP-DB] decimal point

2007-12-16 Thread Stephen Johnson
You will lose your decimal places during normal calculations...

But you can display them back to the user using number_format.

http://php.net/number_format

Bear in mind that you should always pass the formatted number into a
different variable as you will NOT be able to perform any further
calculations on the formatted variable since it now considered a string.

Hope this helps
--
Stephen Johnson c | eh
The Lone Coder

http://www.thelonecoder.com
continuing the struggle against bad code

http://www.thumbnailresume.com
--




 From: Ron Piggott [EMAIL PROTECTED]
 Organization: Acts Ministries Christian Evangelism
 Reply-To: [EMAIL PROTECTED]
 Date: Sun, 16 Dec 2007 12:55:01 -0500
 To: Micah Stevens [EMAIL PROTECTED]
 Cc: php-db@lists.php.net
 Subject: Re: [PHP-DB] decimal point
 
 Ok.  I have this resolved.
 
 One more question about this --- is there any way I may keep the 2
 decimal places when I use math to manipulate the variable ---
 
 
 $rate_plan_rate = ($rate_plan_rate / 100) * (100 - $discount);
 
 $ 28.8
 
 I would like the result to be $28.80
 
 Thanks for your help Micah.
 
 Ron
 
 On Sat, 2007-12-15 at 19:58 -0800, Micah Stevens wrote:
 If I make a test table with a field that is DECIMAL(4,2), I can:
 
 
 INSERT INTO `testaa` ( `a` )
 VALUES ( 
 
 '8.00'
 )
 
 Then I can
 SELECT * FROM `testaa`
 
 I get '8.00' from the 'a' field.
 
 It looks like you're using an abstraction library? Perhaps that's the
 problem?
 
 -Micah 
 
 
 
 On 12/15/2007 07:13 PM, Ron Piggott wrote:
 INSERT INTO rate_plans VALUES ( '12', 'One Week', '1', '2', '2',
 '8.00' )
 
 When I use 
 
 $advertisement_rate = mysql_result($rate_plan_result,0,rate);
 
 $advertisement_rate has a value of 800 instead of 8.00 --- how can I get
 my 2 decimal places back?
 
 Ron
 
 On Sat, 2007-12-15 at 18:18 -0800, Micah Stevens wrote:
   
 What's your insert statement?
 
 On 12/15/2007 05:11 PM, Ron Piggott wrote:
 
 How do I get the decimal point back when I am retrieving from a column
 that is set up as:
 
 rate decimal(4,2)
 
 Example: Right now it is giving me 800 instead of 8.00
 
 Ron
 
   
   
 
   
 
 -- 
 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] Am I missing something?

2007-01-27 Thread Stephen Johnson
My first thought is that your values in your insert statement are not in
quotes..

 
  $insert = 'INSERT INTO domains ( picture, thumbnail ) values(
 $picture, $thumbnail )';

Should be 

$insert = 'INSERT INTO domains ( picture, thumbnail ) values( $picture,
$thumbnail)';

Hope that helps.

?php
/*

Stephen Johnson c | eh
The Lone Coder

http://www.ouradoptionblog.com
Join our journey of adoption

http://www.thelonecoder.com
[EMAIL PROTECTED]

continuing the struggle against bad code

*/ 
?


 From: Alexander [EMAIL PROTECTED]
 Date: Sat, 27 Jan 2007 19:55:17 -0600
 To: PHP-DB php-db@lists.php.net
 Subject: [PHP-DB] Am I missing something?
 
 I fixed my code and it shows up fine now. It says it supposedly enters the
 data when I input the fields but when I check the MySQL database, the info
 isn't there.
 
 Here's the fixed code if you wish to test it:
 
 html
 
 body
 
 ?php
 
   function add_to_table( $picture, $thumbnail ) {
  $picture = mysql_real_escape_string($picture);
  $thumbnail = mysql_real_escape_string($thumbnail);
 
  $user = user;
  $pass = password;
  $database = mydata;
 
$link = mysql_connect(localhost, $user, $pass);
 if(!$link) {
   echo 'Error in linking';
 }
 
  $db = mysql_select_db($database, $link);
 
  $insert = 'INSERT INTO domains ( picture, thumbnail ) values(
 $picture, $thumbnail )';
  $indata = mysql_query( $insert, $link );
 
 
 }
 
 function write_form() {
  echo form method='post' action='{$_SERVER['PHP_SELF']}';
 
  echo pEnter url of large picture: input type='text'
 name='picture' /;
 
  echo pEnter url of thumbnail: input type='text'
 name='thumbnail' /;
 
  echo pinput type='submit' value='Add to Database' /;
 
  echo /form;
 }
 
  if ( !empty( $_REQUEST['picture'] )  !empty(
 $_REQUEST['thumbnail'] ) ) {
$input = add_to_table( $_REQUEST['picture'],
 $_REQUEST['thumbnail'] );
  if(!input) {
echo 'Error\!';
  }
  else {
   echo 'Data enter successfully\!';
   $idreturn = mysql_insert_id($input);
   echo 'Image inserted to ID ' . $idreturn;
 }
   }
  else {
write_form();
}
 
 ?
 
 /body
 
 /html 
 
 -- 
 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] Am I missing something?

2007-01-27 Thread Stephen Johnson
What version of php are using?  It is odd that mysql_real_escape_string is
undefined..

Alternately you could addslashes...
Hope this helps

?php
/*

Stephen Johnson c | eh
The Lone Coder

http://www.ouradoptionblog.com
Join our journey of adoption

http://www.thelonecoder.com
[EMAIL PROTECTED]

continuing the struggle against bad code

*/ 
?


 From: Alexander [EMAIL PROTECTED]
 Date: Sat, 27 Jan 2007 20:17:54 -0600
 To: PHP-DB php-db@lists.php.net
 Subject: Re: [PHP-DB] Am I missing something?
 
 Alright, this may be the problem:
 
 Fatal error: Call to undefined function mysql_real_escape_string() in
 C:\apache2triad\htdocs\gallery.php on line 10
 
 which is refering to :
 
 $picture = mysql_real_escape_string($picture);
 
 
 /* never again use direct code from an example in a book, there's always an
 error */
 
 - Original Message -
 From: Alexander [EMAIL PROTECTED]
 To: PHP-DB php-db@lists.php.net
 Sent: Saturday, January 27, 2007 8:13 PM
 Subject: Re: [PHP-DB] Am I missing something?
 
 
 No change.
 
 I echod my insert statement and got : INSERT INTO domains ( picture,
 thumbnail ) values( $picture, $thumbnail )
 
 excatly like that. Shouldn't the values echo as what should be inserted
 into the database?
 
 - Original Message -
 From: Stephen Johnson [EMAIL PROTECTED]
 To: Alexander [EMAIL PROTECTED]; PHP-DB php-db@lists.php.net
 Sent: Saturday, January 27, 2007 8:01 PM
 Subject: Re: [PHP-DB] Am I missing something?
 
 
 My first thought is that your values in your insert statement are not in
 quotes..
 
 
  $insert = 'INSERT INTO domains ( picture, thumbnail ) values(
 $picture, $thumbnail )';
 
 Should be
 
 $insert = 'INSERT INTO domains ( picture, thumbnail ) values( $picture,
 $thumbnail)';
 
 Hope that helps.
 
 ?php
 /*
 
 Stephen Johnson c | eh
 The Lone Coder
 
 http://www.ouradoptionblog.com
 Join our journey of adoption
 
 http://www.thelonecoder.com
 [EMAIL PROTECTED]
 
 continuing the struggle against bad code
 
 */
 ?
 
 
 From: Alexander [EMAIL PROTECTED]
 Date: Sat, 27 Jan 2007 19:55:17 -0600
 To: PHP-DB php-db@lists.php.net
 Subject: [PHP-DB] Am I missing something?
 
 I fixed my code and it shows up fine now. It says it supposedly enters
 the
 data when I input the fields but when I check the MySQL database, the
 info
 isn't there.
 
 Here's the fixed code if you wish to test it:
 
 html
 
 body
 
 ?php
 
   function add_to_table( $picture, $thumbnail ) {
  $picture = mysql_real_escape_string($picture);
  $thumbnail = mysql_real_escape_string($thumbnail);
 
  $user = user;
  $pass = password;
  $database = mydata;
 
$link = mysql_connect(localhost, $user, $pass);
 if(!$link) {
   echo 'Error in linking';
 }
 
  $db = mysql_select_db($database, $link);
 
  $insert = 'INSERT INTO domains ( picture, thumbnail ) values(
 $picture, $thumbnail )';
  $indata = mysql_query( $insert, $link );
 
 
 }
 
 function write_form() {
  echo form method='post' action='{$_SERVER['PHP_SELF']}';
 
  echo pEnter url of large picture: input type='text'
 name='picture' /;
 
  echo pEnter url of thumbnail: input type='text'
 name='thumbnail' /;
 
  echo pinput type='submit' value='Add to Database' /;
 
  echo /form;
 }
 
  if ( !empty( $_REQUEST['picture'] )  !empty(
 $_REQUEST['thumbnail'] ) ) {
$input = add_to_table( $_REQUEST['picture'],
 $_REQUEST['thumbnail'] );
  if(!input) {
echo 'Error\!';
  }
  else {
   echo 'Data enter successfully\!';
   $idreturn = mysql_insert_id($input);
   echo 'Image inserted to ID ' . $idreturn;
 }
   }
  else {
write_form();
}
 
 ?
 
 /body
 
 /html
 
 -- 
 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
 
 
 -- 
 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] Query was empty - Strange problem

2005-03-16 Thread Stephen Johnson
I do not see where you are populating $Query -- therefore your query  
would be empty --

On Mar 16, 2005, at 10:30 PM, Vinayakam Murugan wrote:
Hi
I have an application in which i am connecting to three different
databases. I have three  connect and query procedure. I am facing
problems with one of these databases.
--- 

$Conn = mysql_pconnect($Hostname,$Loginname,$Passwd);

$Ret = mysql_select_db ($Dbname, $Conn);
if (!$Ret)
{
$Error = Error opening Database : $Dbname BR;
return FALSE;
}
$Ret = mysql_query ($Query, $Conn) or $Error = BRBR .
mysql_errno() . --- . mysql_error() . BRBR;
echo $Error;
--- 


I am getting an Error - Query was empty.
I have tried echoin $Query before and after the mysql_query. It shows
a proper query which if I copy and execute in phpmyadmin, i get the
required results. It is not workign through PHP only.
Any pointers would be very helpful.
--
Warm Regards

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

*
Stephen Johnson
[EMAIL PROTECTED]
http://www.thelonecoder.com
--continuing the struggle against bad code--
*
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] PHP and PostgreSQL

2005-03-10 Thread Stephen Johnson
Did you compile php or did you install from a binary?

If you compiled -- did you configure the PHP module --with-pgsql?

I have not installed a binary in the past so I am not sure how you activate
the pgsql module in that regard.

The problem though is that the version of PHP you are running is not
configured to support pgsql and you will need to do that to get it recognize
the pgsql specific functions.


?php
/*

Stephen Johnson c | eh
The Lone Coder

http://www.thelonecoder.com
[EMAIL PROTECTED]

562.924.4454 (office)
562.924.4075 (fax) 

continuing the struggle against bad code

*/ 
?

 From: Van Ingen, Lane [EMAIL PROTECTED]
 Date: Thu, 10 Mar 2005 14:32:39 -0500
 To: php-db@lists.php.net
 Subject: [PHP-DB] PHP and PostgreSQL
 
 I am new to PHP. Trying to install it and PostgreSQL 8.0 on Slackware Linux
 10.0.0 . I am getting
 the following error out of Apache:
   Fatal Error: Call to undefined function: pg_connect()
 
 After browsing your web site, I found http://us2.php.net/pgsql . But am unable
 to proceed because I
 am not sure what to do. Specific questions:
 (1) How do I determine what version of PHP I have? Browsed PHP directories,
 but couldn't find it.
 (2) The information I found said I could use a shared object module and/or
 (I think) alter php.ini .
 
 I don't think this is hard to fix, but I need to find a blow-by-blow of what
 to do. Can somebody help me?
 

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



Re: [PHP-DB] Insertion problem

2005-03-09 Thread Stephen Johnson
Did I miss the actual insert statement?

Can you please show me your insert statement?



?php
/*

Stephen Johnson c | eh
The Lone Coder

http://www.thelonecoder.com
[EMAIL PROTECTED]

562.924.4454 (office)
562.924.4075 (fax) 

continuing the struggle against bad code

*/ 
?

 From: sultan Ibraheem [EMAIL PROTECTED]
 Date: Wed, 9 Mar 2005 14:30:35 -0800 (PST)
 To: php-db@lists.php.net
 Subject: [PHP-DB] Insertion problem
 
 I'm sure that I typed the insertion query corrctly, but it still not
 committed. I mean that there is no record actually inserted. Is there any
 possible error, such as configuration error.
 I am using PHP 5 and MySQL Database Version 4.0.20.
 
 Sultan.

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



Re: [PHP-DB] insertion problem (2)

2005-03-09 Thread Stephen Johnson
Do you receive any errors or anything that might indicate a problem other
then the date not appearing the db ?

Be wordy -- hold nothing back -- give me as much as you can.




?php
/*

Stephen Johnson c | eh
The Lone Coder

http://www.thelonecoder.com
[EMAIL PROTECTED]

562.924.4454 (office)
562.924.4075 (fax) 

continuing the struggle against bad code

*/ 
?

 From: sultan Ibraheem [EMAIL PROTECTED]
 Date: Wed, 9 Mar 2005 14:50:57 -0800 (PST)
 To: [EMAIL PROTECTED], php-db@lists.php.net
 Subject: [PHP-DB] insertion problem (2)
 
 Thanks for your time,,
 
 This is the code:
 
 $uu=mysql_query(insert into voters2
 ('id','username','constnum','name','fname','gname','lname')values('$T10','$T1'
 ,'$T11','$T4,'$T5','$T6','$T7'));
 
 $uu2=mysql_query(insert into voters2 ('sex','birth_day','email','password')
 values('$D1','$T9','$T8','$T2'));
 
 
 
 -
 Celebrate Yahoo!'s 10th Birthday!
 Yahoo! Netrospective: 100 Moments of the Web 

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



Re: [PHP-DB] insertion problem (2)

2005-03-09 Thread Stephen Johnson
This may not necessarily be the problem.  But I am not sure that you should
be capitalizing the first character of your variable.

That is a special type of PHP variable - which I do not use normally - so I
can not remember what it is called.

However, put all your variables to lower case except the pre-defined
variables such as $_POST and $_GET etc.

See if that helps

?php
/*

Stephen Johnson c | eh
The Lone Coder

http://www.thelonecoder.com
[EMAIL PROTECTED]

562.924.4454 (office)
562.924.4075 (fax) 

continuing the struggle against bad code

*/ 
?

 From: sultan Ibraheem [EMAIL PROTECTED]
 Date: Wed, 9 Mar 2005 14:50:57 -0800 (PST)
 To: [EMAIL PROTECTED], php-db@lists.php.net
 Subject: [PHP-DB] insertion problem (2)
 
 Thanks for your time,,
 
 This is the code:
 
 $uu=mysql_query(insert into voters2
 ('id','username','constnum','name','fname','gname','lname')values('$T10','$T1'
 ,'$T11','$T4,'$T5','$T6','$T7'));
 
 $uu2=mysql_query(insert into voters2 ('sex','birth_day','email','password')
 values('$D1','$T9','$T8','$T2'));
 
 
 
 -
 Celebrate Yahoo!'s 10th Birthday!
 Yahoo! Netrospective: 100 Moments of the Web 

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



Re: [PHP-DB] Random Password problem

2005-03-08 Thread Stephen Johnson
I know that true randomness only exists in nature.  However, the
randomization in PHP is fairly good. I have only used it on fairly small
scales (i.e. Randomizing 200 quotes to give a random quote when people log
onto a page.) 

For passwords I have always gone an easier route.

$password = time();

This will produce an impossible to guess string of numbers I think about 9
or 10 characters in length.

I am sure others here will have better options.  But this has worked well
for me and is very very easy.



?php
/*

Stephen Johnson c | eh
The Lone Coder

http://www.thelonecoder.com
[EMAIL PROTECTED]

562.924.4454 (office)
562.924.4075 (fax) 

continuing the struggle against bad code

*/ 
?

 From: J. Connolly [EMAIL PROTECTED]
 Date: Tue, 08 Mar 2005 14:41:11 -0500
 To: PHP list php-db@lists.php.net
 Subject: [PHP-DB] Random Password problem
 
 I am using this php in order to create, store and send random passwords
 to people who want to join my mailing list.
 
 ?php
 function random_password () {
 $seed = (integer) md5(microtime());
 mt_srand($seed);
 $password = mt_rand(1,);
 $password = substr(md5($password), 3,9);
 return $password;
 }
 ?
 
 ?php
 $msg = random_password();
 echo $msg;
 ?
 
 I seem to be getting the same number very often which makes me fear that
 this is not so random. I am a noob so I do not know if this is
 coincidence or a fault in my coding.
 Right now, I have been setting up passwords manually, but would like
 users to be as free from me as possible. Any direction would be helpful.
 
 BTW, I keep getting the following number an absurd amount of times. I
 have deleted cookies and even gone to other machines, and yet it still
 generates this number.
 
 8f31a3
 
 Thank you,
 jozef
 
 -- 
 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



[PHP-DB] test

2001-11-13 Thread Stephen Johnson

hello? 


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