Re: [PHP-DB] Dates prior to Dec 31, 1969

2004-12-14 Thread Ramil Sagum
On Tue, 14 Dec 2004 15:39:52 -0600, Frank Marousek
<[EMAIL PROTECTED]> wrote:
> I'm using the following code to display dates returned from a query of a
> mySQL database.
> 
> $new_timestamp = strtotime($row_SearchPlayerRcrdSt['Date']);
> $new_date_formatted = date ("m/d/y", $new_timestamp);
> echo $new_date_formatted;
> 
> It appears that all dates prior to Dec 31, 1969 are displayed as 12/31/69.
> 
> What am I doing wrong?
> Thanks,
> Frank
> 

On my system it displays at 01/01/70. This may be related to that note
in the strtotime page of the php manual:

http://ww.php.net/manual/en/function.strtotime.php


Note:  The valid range of a timestamp is typically from Fri, 13 Dec
1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the
dates that correspond to the minimum and maximum values for a 32-bit
signed integer.) Additionally, not all platforms support negative
timestamps, therefore your date range may be limited to no earlier
than the Unix epoch. This means that e.g. dates prior to Jan 1, 1970
will not work on Windows, some Linux distributions, and a few other
operating systems.


How about letting MySQL format the date for you? 
http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html#IDX1384



ramil
http://ramil.sagum.net

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



Re: [PHP-DB] Frames & mySQL

2004-11-18 Thread Ramil Sagum
On Thu, 18 Nov 2004 21:16:51 -0500, Ron Piggott
<[EMAIL PROTECTED]> wrote:
> I have another challenge I am trying to over come.  Frames.
> 
> I have my screen set up in 3 frames.  2 for user input and the third is for
> data --- letting the user know what has just happened.  IE "RECORD UPDATED"
> is what I want to be displayed there.  The catch is this --- how do I
> display text in the data frame.  Any idea?  I know the  href="next_screen.html" TARGET="data">SUBMIT command ... But I am
> wanting to write to the database with a form and then have the same form
> come up again to be filled out again and the data window let the user know a
> message such as "RECORD RECEIVED".  Can a PHP script do this?
> 

Hi Ron,

You don't need to submit to the "data" frame. Just submit the form to
the same frame, then call a reload on the other frame using
javascript.





ramil

http://ramil.sagum.net

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



Re: [PHP-DB] session_destroy();

2004-11-08 Thread Ramil Sagum
On Tue, 9 Nov 2004 01:00:12 -0500, Chris Payne <[EMAIL PROTECTED]> wrote:
> Hi there everyone,
>
> I need to destroy a session in the browser so when they log out it clears
> all the session data from the browser, I have tried:
>
> session_destroy();
>
> But it doesn't seem to do it as the browser keeps the same PHPSessionID.
>
> What is the best way to destroy a session and generate a new sessionid
> without having to close the browser and go back again?
>

Did you unset the session variables using:

// Unset all of the session variables.
$_SESSION = array();

If you are using a cookie for the session id, you might also want to
delete the cookies

if (isset($_COOKIE[session_name()])) {
  setcookie(session_name(), '', time()-42000, '/');
}

Do these before calling session_destroy.

check it out here.

http://www.php.net/session_destroy

HTH

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



Re: [PHP-DB] The variable $_SERVER['AUTH_USER'] gives domain\\username problem

2004-09-30 Thread Ramil Sagum
On Fri, 1 Oct 2004 11:47:50 +1000, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> I made the change but the domain\username now appears in my database as:
> domainusername

You probably have the magic quotes enabled.

The manual page(
http://www.php.net/manual/en/function.mysql-real-escape-string.php )
says something about it. It even provides a sample code for
automatically handling the magic quotes setting (see the last code
block).

Do try the examples first, character escaping IS A confusing issue. 




ramil

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



Re: [PHP-DB] The variable $_SERVER['AUTH_USER'] gives domain\\username problem

2004-09-30 Thread Ramil Sagum
On Fri, 1 Oct 2004 11:32:29 +1000, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> No, still no idea :)
> $sql = "INSERT INTO aec SET date='$date', title='$title',
> ident='$ident', id='$id'";
> mysql_query($sql);

I feel good today :) so, 

$sql = "INSERT INTO aec SET date='$date', title='$title',
ident='" . mysql_real_escape_string($ident) . "', id='$id'";

(After it works and everything is crystal clear, you might want to try
validating the title, ident and id BEFORE using it in the query. )

HTH!




ramil
http://ramil.sagum.net

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



Re: [PHP-DB] The variable $_SERVER['AUTH_USER'] gives domain\\username problem

2004-09-30 Thread Ramil Sagum
Thus wrote justin:
> Thanks Ramil,
> 
> I knew it had something to do with the \, but I still can't figure out
> how to get the variable into the database without the extra '\'
> It is entered into the database via a form using the input below:
> 
> 
> 
> Where would I use the mysql_real_escape_string ?

>From the manual:

"This function will escape special characters in the unescaped_string,
taking into account the current character set of the connection so
that it is safe to place it in a mysql_query(). "

an example from the manual:

$query = sprintf("SELECT * FROM users WHERE user='%s' AND password='%s'",
   mysql_real_escape_string($user),
   mysql_real_escape_string($password));
mysql_query($query);


I hope this is enough :)




ramil

http://ramil.sagum.net

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



Re: [PHP-DB] The variable $_SERVER['AUTH_USER'] gives domain\\username problem

2004-09-30 Thread Ramil Sagum
On Fri, 1 Oct 2004 10:27:45 +1000, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> Hi,
> 
> When I use the variable $_SERVER['AUTH_USER'] it comes out as
> domain\\username when inserted into the MySQL database. So when I try to
> update the record looking for a match as below it doesn't work because
> the query is looking for where ident=domain\username.
> 
> $result = mysql_query("UPDATE aec SET filename='$filename' WHERE
> ident='".$_SERVER['AUTH_USER']."'") or die (mysql_error());
> 
> Anybody know what I am doing wrong?


In MySQL, \ is an escape character. \\ stands for an actual \.

for details, just click the link and read on

http://www.php.net/manual/en/function.mysql-real-escape-string.php






ramil
http://ramil.sagum.net

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



Re: [PHP-DB] ip address

2004-09-29 Thread Ramil Sagum
On Thu, 30 Sep 2004 11:00:35 +0530, balwantsingh
<[EMAIL PROTECTED]> wrote:
> i tried the $_SERVER['REMOTE_ADDR'] it is giving ip address of server which
> is hosting the webpage not the user's ip address.   pls. suggest how can IP
> address of an user can be obtained.

what exactly did you do? the following script works:

===

Your IP Address is : 


===




ramil

http://ramil.sagum.net

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



Re: [PHP-DB] database

2004-08-30 Thread Ramil Sagum
On Mon, 30 Aug 2004 21:44:03 -0700, Ryan Holowaychuk <[EMAIL PROTECTED]> wrote:
> And that is where I am lost?
> 
> Yes I have the data in a Mysql server, so how do I get the server to do the
> work.
> 
> thanks
> Ryan
> 

You need to execute a SELECT statement with a WHERE clause.
Your problem is more of an SQL problem than a PHP one. You need to
read up on mysql (and particularly SQL) first. Googling and picking
some "good looking" tutorials:

http://www.juicystudio.com/tutorial/mysql/index.asp
http://www.freewebmasterhelp.com/tutorials/phpmysql/

After finishing those tutorials, try implementing you problem. If you
still get stuck. then email us what you tried. :)

---

ramil

http://ramil.sagum.net

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



Re: [PHP-DB] database

2004-08-30 Thread Ramil Sagum
On Mon, 30 Aug 2004 21:29:07 -0700, Ryan Holowaychuk <[EMAIL PROTECTED]> wrote:
> 
> I have a database that has 110,000 barcodes in it.
> I am trying to create a system that I can enter barcode1 in the system and
> it return a good or bad  value.
> I have it loading in an array at the moment. which does nto seem to work
> that well as it is taking a longtime and it is causing the sytem to bog
> right down.
> is there a better way to loop a variable through this many codes?
> 
> thanks
> 
> Ryan


You are loading all of the 110,000 barcodes in an array variable?

Aren't you using any database server? (postgres, mysql..etc) Let the
database server do the searching. :)





ramil

http://ramil.sagum.net

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



Re: [PHP-DB] Update multiple tables

2004-08-25 Thread Ramil Sagum
On Wed, 25 Aug 2004 22:08:03 -0700 (PDT), Khalid Judeh
<[EMAIL PROTECTED]> wrote:
> Hello,
> I have a script that make changes to the database in more than one sql statement, as 
> i need to update more than one table at the same time, I want to know if there is a 
> method where all of those changes are committed, or rolled back if some error 
> occured(lets say in the last sql statement).
> thanks


Use transactions :

BEGIN TRANSACTION
...sql statements...
COMMIT

or

ROLLBACK

The implementation varies a little. Check out the documentation/manual
of  your database  server for "transactions".

(PHP also has built-in functions for transactions such as
mysqli_commit(), mysqli_rollback() and mysqli_autocommit()  for
mysqli.)


HTH.



ramil

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



Re: [PHP-DB] PHP Array to Javascript?

2004-08-25 Thread Ramil Sagum
On Wed, 25 Aug 2004 20:18:23 -0400, Chris Payne
<[EMAIL PROTECTED]> wrote:
> Hi there everyone,
> 
> I set an array using the following in PHP:
> 
> $ringb[$i]="$complex_area";
> 
> $i++;
> 
> It cycles through my DB and stores the info, my question is, how can I
> convert it to a value that can be read in Javascript?
> 
> I'm stumped.
> 
> 
> Chris
> 

Output javascript code in HTML that would assign values to variables. 
Asimple example would be



var  x;

x = ;



HTH


ramil

http://ramil.sagum.net

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



RE: [PHP-DB] Saving MySQL data as an Excel Spreadsheet...?

2003-08-20 Thread Ramil Sagum
have you tried saving the data as a set of comma separated values (CSV
file)?

Microsoft Excel can open/import these files.

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, August 20, 2003 4:58 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Saving MySQL data as an Excel Spreadsheet...?
>
>
> I've just done a search on goolge for this, and found several products
> that do it, but I'm convinced there's gotta be an open source option?
> Anyone able to point me in the right direction with this?
>


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