[PHP] Re: file upload problem (files 7.5mb)

2002-03-04 Thread Joe Van Meer

Hi there:) Are you using the hidden form field with the max file limit set?

Cheers, Joe :)


Stefan [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED];
 i wrote a php uploadscript and it works fine till the file is not larger
 then 7.5mb.
 is set the max upload file size in the upladfrom as well as in php.ini to
 100mb. but it still doesn't work!
 system is linux red hat and php 4.0.6 (with mysql)
 is there anyone who had the samestefa problem and knows a solution?

 stefan





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




[PHP] Re: Sessions and templating help

2002-02-16 Thread Joe Van Meer

Hi Justin, are you using ?php session_start(); ? at the top of every page
you want to keep the session?

Cheers, Joe :)


Justin Deutsch [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi All,

 I am running Apache with PHP4 as a module.  I have also written a script
(template.php) that sets up the default envrionment, like the CSS and
navigation etc.  The script also reads in a file, as defined by the ?path=
of the URL.  The file it reads in must have the sections (includes, header
and body,  as defined by /*** ***/ and /*** end ***/ pairs).  The file is
the split into these sections and along with the templated bits of the page
compile into a single string which is the executed using the eval().  Now
this all works fine, but I also want to use sessions.  The first session
from the index.html file, which is first acessed as a login page, stores the
player class fine, but when I go to the next page (player_login.html) I seem
to loose the session.

 You might ask why I don't just use an existing templating system, well
it's because I think that you should only have to write the template once
and not have to touch it again.  The templating systems I have come across
force you to include a file at the top and bottom of the code you are
writing.  The one down side to the way I am doing it is that I have had to
force the other file into a include, header and body section, but this is a
trivial formatting issue.

 Is there something I'm missing?  I have included the code for the three
scripts below.

 
 template.php
 

 ?PHP
 /*
  * This script is the basis for a templaing engine.  The engine uses the
  * rewrite feature of the web server to capture the Virtual URL that the
  * user wants and maps it to this script with a paraeter.  This script
  * then sets up the template and includes the content from the file
  * indicated by the user.
  *
  * A directory structure containing tall of the content is required, and
  * with Apache a directory to map from.
  */


 /* Put setup here */
 require_once(site-config.php);
 require_once(html_header.php);
 require_once(html_footer.php);
 require_once(misc_function.php);


 /* Set up some defaults */
 $title = ;
 $body = ;
 $page = ;
 $file_read = false;
 $file_content = ;
 unset($content_header);

 /* Read the contents of a file into a string */
 function read_file($filename)
 {
 global $file_read;
 global $file_content;
 $file_content = ;
 $file_read = false;
 //print $filename\n\nbrbr;
 if(file_exists($filename))
 {
 $page_code = file($filename);
 foreach ($page_code as $line)
 {
 $file_content .= $line;
 }
 //print $file_content;
 $file_read = true;
 }
 else
 {
 $file_content = '
 h1File Not Found/h1
 pCould not find ?=$filename?, please let the Web Administrator
 know/p
 ';
 }
 }

 /* Get the index information */

 read_file($NAV_COLUMN);
 $navigation = $file_content;

 /*
  * garentee that if the user gives no file name then they will get the
  * index file
  */
 if(strcmp(basename($path), ) == 0)
 {
 if(!preg_match(/\/$/, $path))
 {
 $path .= /;
 }
 $path .= index.html;
 }
 /* Get the Header information and the content of the body */
 $file_name = $CONTENT_PATH/$path;
 read_file($file_name);
 if($file_read)
 {
 //print $file_name;

 /* Grab the HTTP header stuff from the file. This includes any
 * session information.
 *
 * The header section is defined by
 * *** header *** and *** end header *** at the start of the
 * file.
 */
 $section = preg_split(/\s*\*{3}\s*end\s*header\s*\*{3}\s*/im,
 $file_content,
 2
 );
 if(count($section) == 2)
 {
 $content_header = $section[0];
 $content_header = preg_replace(/\*{3}\s*header\s*\*{3}/im,
 ,
 $content_header,
 1
 );
 $body = $section[1];

 /* get the includes section */
 $section = preg_split(/\s*\*{3}\s*end\s*includes\s*\*{3}\s*/im,
 $content_header,
 2
 );
 if(count($section) == 2)
 {
 $include_files = $section[0];
 $include_files = preg_replace(/\*{3}\s*includes\s*\*{3}/im,
 ,
 $include_files,
 1
 );
 $content_header = $section[1];

 }

 }
 else
 {
 $body = $section[0];
 }
 }
 else
 {
 $body = $file_content;
 }

 if(isset($include_files))
 {
 $page .= $include_files.\n;
 }

 $page .= '?PHP
 /*
  * Start of Template code
  */

 /* include state management here in an if to see if it is wanted */

 if(defined($KEEP_STATE)  $KEEP_STATE)
 {
 session_start();
 }
 /* Set up the headers and footers */
 header(Expires: Mon, 26 Jul 1997 05:00:00 GMT);
 header(Last-Modified:  . gmdate(D, d M Y H:i:s) .  GMT);
 header(Cache-Control: no-store, no-cache, must-revalidate);
 header(Cache-Control: post-check=0, pre-check=0, false);
 header(Pragma: no-cache);

 /* keep state = '.$KEEP_STATE.' */

 ?
 ';

 if(isset($content_header))
 {
 $page .= $content_header.\n;
 }


 $page .= '
 ?PHP
 /*
  * Start of Template code section
  */
 $header = new html_header($title);
 $footer = new html_footer();
 $header-display()
 ?'.\n;
 //$header-display();
 //print h1:$title/h1;

 /*
 print 

[PHP] Re: Sessions that last for ever

2002-02-16 Thread Joe Van Meer

Hi Nigel, you could set a cookie once they enter your site, and check at the
top of each page you want accessible with this variable to see if they have
it or not.

Joe :)


Nigel Gilbert [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 By default, a session (created with session_register) seems to last just
 as long as the user has their browser open.  If a user quits the
 browser, the session is automatically destroyed.

 I want a session to last indefinitely (or until my program destroys
 it).  There are some hints about how this could be done with cookies in
 the documentation, but not a clear recipe.  What sequence of PHP
 statements should I use to achieve this?

 Thanks for any help,

 Nigel




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




[PHP] Re: How to keep form inputs from being cleared

2002-02-07 Thread Joe Van Meer

Probably the easiest way is to not get to that point at all in the first
place. Just use a client-side javascript  form validation script to prevent
un-filled fields from even occurring.

Another way around ths is to create tempory session variables on the
processing page, and if some of the form fileds( ie : all the form fields
are not filled out) you could redraw the form and fill the fields in with
those temp vars.


Hope these help you out, Joe :)


Compman86 [EMAIL PROTECTED] wrote in message
007f01c1b016$bbb45010$dd563944@cc1966780a">news:007f01c1b016$bbb45010$dd563944@cc1966780a...
 I posted about this a few days ago. I received several responses but
 none of them were very helpful (thanks for the effort though). I finally
 figured out what it was by process of elimination. At the top of my
 registration form, I put session_start() just like I did for all my
 other scripts. Well it turns out that by doing this, for some reason, it
 clears the form. I have a hunch that the cookie request by
 session_start() has something to do with it. Well, the only reason
 someone would be at the registration form would be if he/she was not a
 member, therefore the session ID would be pointless.

 This is the major flaw of PHP's built in sessions imho: If a user
 disables cookies, the session functions assign the session ID to the
 constant SID. However, if the SID is not passed on religiously, a new
 session will be made. In an instance like this where session_start()
 cannot be used, you can't pass on the SID. It seems like I'm just going
 to resort to requiring that my users enable session cookies. The hastle
 of making the code to use both SID and/or cookies just doesn't seem
 worth it. If anyone has any ideas of a resolution to this problem, feel
 free to post here or email me.




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




[PHP] Re: array variable passing in session.

2002-02-07 Thread Joe Van Meer

Hi Peter, are you limited to using arrays? If not, try  msql_fetch_row()
since you are only looking for the one record, ie: the corresponding
username and password record for the username and password that was passed.

Hope this helps, Joe :)

 ?php
session_start();

 include(config.php);
 mysql_connect($host_name, $user_name, $passwd)
   or die(Unable to connect to $hostname.);
 // select database on MySQL server
 mysql_select_db($db_name) or die(Unable to select databse.);

 // formulate the query
 $sql_statement = SELECT user_id, password FROM $table_name WHERE
user_id  = '$user_id' AND
   password = '$password';

 $result = mysql_query($sql_statement) or die(Unable to execute
query.);

//if there is a corresponding record
if(mysql_fetch_row($result)) {


$usid = mysql_result($result,0);
 $pswd = mysql_result($result, 1);


//create session variables

session_register(password);
$password = $pswd;

session_register(user_id);
$username = $usid;


//echo a friendly message or use header() function to redirect the user to
the appropriate page
echo Succesful login!;
}
else
{
//the user is not a registered member so redirect them to a sign up page or
another page to try and login again
header(Location: signup.php);

}

?





Peter Ruan [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi,
   I am running into a problem that I can't figure out the solution to.  So
 I'm hoping that someone can give me some pointers here.  I have two files
 (see below):  verify.php and edit.php
   The job of verify.php is basically to verify that a user is in the
 database before allowing him/her to edit the information.  The information
 retrieved is saved to arrary varaiable $row.  I do a session_register() to
 $row and that information should be passed to subsequent pages that has
 session_start(), right?  However, when I tried to print out the
information
 again in edit.php, it doesn't seem to register it in.  At first I thought
it
 was the array problem, so I put the array variable $dummy to test it out
and
 that can be reigstered and retrieved correctly.  What am I doing wrong???
 Also, how do I redirect to a page automatically once the user is verfied
 (right now I have to ask the user to click on a link to redirect).

 Thanks in advance,
 Peter

 /*** verify.php /
 ?php
session_start();

 include(config.php);
 mysql_connect($host_name, $user_name, $passwd)
   or die(Unable to connect to $hostname.);
 // select database on MySQL server
 mysql_select_db($db_name) or die(Unable to select databse.);

 // formulate the query
 $sql_statement = SELECT * FROM $table_name WHERE
user_id  = '$user_id' AND
   password = '$password';

 $result = mysql_query($sql_statement) or die(Unable to execute
 query.);

 $num_of_rows = mysql_num_rows($result);
 /* XXX: test array variable...take out later */
 $dummy = array(one, two, three);
 session_register(dummy);

 if (!$num_of_rows) {
 echo h3User ID and password missmatch, try again!/h3;
 } else {
 while ($row = mysql_fetch_array($result)) {
session_register(row);  // register information retrieved from
 MySQL
 }
 printf(Successfully Logged In! a href=\edit.php\Click
 Here/a);
 echo br;
 }
 ?


 /* edit.php */
 ?php
 session_start();
 foreach ($dummy as $val) {
 echo $val . br;
 }

 foreach ($row as $data) {
 echo $data . br;
 }
 ?





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




[PHP] Re: Upload script with user admin

2002-02-01 Thread Joe Van Meer

I forgot to mention that all of the pics in my small app are renamed and are
only 5 digits in length. So I always know I can count on the substr() and 5
digits/characters. Your situation is more than likely different than mine
own, and you'll have to adjust the extraction of the file name to suit your
needs.

HTH Joe :)


Lerp [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Deleting and editing is accomplished by selecting out of the db the
 appropriate record. So if you had a page that looped through 35 (for
 example) records, and each record had a link that was created (a
 class='link_black_02' href='deletephotoconfirm.php?photoid=$photoid' .
 delete . /a) -- use the querystring to pass the $photoid to a
 confirmation page. On that confirmation page (I usually do this) create 2
 forms with one button in each. Both post/get to the processing page, one
 button has a value (for example) 'dodelete' and the other form's button
 'dontdoit'. Then at the top of the processing page, figure out which
button
 was pressed and go from there.  For editing the actual path for the image,
 it is done the same old way, select the record according to an id, dump
the
 values you want changed into a form , edit and post/get it back up the
same
 way it was done the first time around.

 Hope this helps you out :)

 Joe/ Lerp :)

 ##grab records from
 db

 $connectionToDB = odbc_connect(gdff, jgdfoldff, jdfdfgrf);
 $sqlp = SELECT photoid, caption, datesubmitted FROM PHOTO WHERE
 golferid='$sesgolferid' .  ORDER BY datesubmitted DESC;
 $resultset = odbc_do($connectionToDB, $sqlp);

 //start table for display here
 print table width='500' cellspacing='0' cellpadding='0' border='0';

   print tr colspan='3';
   print td bgcolor='#363C70' colspan='3'img
 src='images/pixel_transparent.gif' width='1' height='5' border='0'
 alt=''/td;
   print /tr;

   print tr;
   print td bgcolor='#363C70' align='left' width='200';
   print font face='verdana' color='#FF' size='2'
 class='text_size_9';
   print bCaption/b;
   print /font;
   print /td;
   print td bgcolor='#363C70' align='left' width='230';
   print font face='verdana' color='#FF' size='2'
 class='text_size_9';
   print bDate Submitted/b;
   print /font;
   print /td;
   print td bgcolor='#363C70' align='left' width='70';
   print font face='verdana' color='#FF' size='2'
 class='text_size_9';
   print bDelete/b;
   print /font;
   print /td;
   print /tr;

   print tr;
   print td bgcolor='#363C70' colspan='3'img
 src='images/pixel_transparent.gif' width='1' height='5' border='0'
 alt=''/td;
   print /tr;

 print tr height='10'/td/td/tr;


 while(odbc_fetch_row($resultset)){

 $photoid = odbc_result($resultset,1);
 $caption = odbc_result($resultset,2);
 $datesubmitted = odbc_result($resultset,3);


 //format the datesubmitted for display below
 $month = substr($datesubmitted, 5, 2);
 //print $month . BR;
 $day = substr($datesubmitted, 8, 2);
 //print $day . BR;
 $year = substr($datesubmitted, 0, 4);
 //print $year . BR;

 $dateinsecs = mktime(0,0,0,$month, $day, $year);


 $formattedsubdate = date('F j Y',$dateinsecs);
 //print $formattedsubdate;


 file://display the records --create a link for
 each###
 print tr;
 print td align='left' bgcolor='#ff' width='200'bfont
 face='verdana' color='#00' size='2' class='text_size_9'  .  $caption
.
 /font/b/td .  td align='left' width='230'
bgcolor='#ff'font
 face='verdana' color='#00' size='2' class='text_size_9' .
 $formattedsubdate . /font/td .  td align='left' width='70'
 bgcolor='#ff'font face='verdana' color='#00' size='2'ba
 class='link_black_02' href='deletephotoconfirm.php?photoid=$photoid' .
 delete . /a/b/font/td;
 print /tr;
 print tr height='10'/td/td/tr;
 }

 }



 // close the connection
 odbc_close($connectionToDB);

 ##end of display from
 database###




 ##confirmation
 page##


 div align='center'
 table cellspacing=0 cellpadding=5 border=0 
   tr
   td align=center

 form action=dodeletep.php method=post
 input type=hidden name=photoid value=?php echo $photoid; ?

 input type=hidden name=dodelete value=dodelete
 input type=Submit name=submit value=nbsp;nbsp;Yesnbsp;nbsp;
 style=background-color: #FF; font-family: verdana; font-weight: bold;
 color: #363C70; font-size: 10pt;
 /form

/td
td align=center

 form action=dodeletep.php method=post
 input type=hidden name=photoid value=?php echo $photoid; ?

 input type=hidden name=dontdelete value=dontdelete
 input type=Submit name=submit
 value=nbsp;nbsp;Nonbsp;nbsp;nbsp; style=background-color: #FF;
 font-family: verdana; font-weight: bold; color: #363C70; font-size:
10pt;
 /form

/td
   /tr
   /table

[PHP] Re: Images and Mysql

2002-01-30 Thread Joe Van Meer

See my reply to Image fields and PHP on the 14th of january.
HTH Joe :)

David Orn Johannsson [EMAIL PROTECTED] wrote in message
006501c1a99a$31ce5cb0$6500640a@gandalf">news:006501c1a99a$31ce5cb0$6500640a@gandalf...
I need to find out how to upload images to a database and then
displaying them again, can anybody
direct me to a howto or any thing like that to help me figure out how
it's done.

 http://www.atom.is/ 
Davíð Örn Jóhannssson
Vefforritari

Atómstöðin hf.
Garðastræti 37
101 Reykjavík

sími: 595-3643
fax: 595-3649
 mailto:[EMAIL PROTECTED] [EMAIL PROTECTED]
 http://www.atom.is/ http://www.atom.is






-- 
PHP General 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] Re: application variable

2002-01-19 Thread Joe Van Meer

Hi there, I usually test at the top of the page that does my 'logging-in' to
see if the variable I set for each user once they actually login is set.
So if I set a variable called '$isloggedin' upon a successful login, I would
check at the top of that page to see if it is set or not, if it's already
set bypass the login and redirect them to a new page.

HTH Joe :)




Ye Tun [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Do we have application variable in PHP as in ASP?

 I have a small database running with user name and password kept in MySQL
 database.  Once user is login, how can I prevent the same user from
 logging in again?

 REgards,

 Ye




-- 
PHP General 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] Record Paging Using Arrays

2002-01-12 Thread Joe Van Meer

Hi there, I have a small php/data driven website and would like to
incorporate record paing. Unfortunately I'm working with sql Server
temporarily, but I'm still required to do this. So since I wasn't allowed to
use the handy LIMIT in my sql statement I figured I'd dump my results into a
mulitdiensional array and navigate through the records that way. I know this
propbabbly isn't the best method, but it's the way I have to do it for now.
I've managed to display my records out of the array, but would now like to
incorporate a next' and a 'previous' button to navigate through the array.
Can someone take a look at my code below and tell me how I'm to go about
doing this? I thought maybe by having 2 functions that would advance my
array pointer and another to retreat the pointer would do the trick. I'm
unsure how to incorporate it. I've added two functions within the
 below, not sure if they are appropriate or not though.

Thx Joe :)






Code:
if(!isset($consultantarray)){


//connect to db
$connectionToDB = odbc_connect(cdxcffcoltant, jo7gecon, josje7con);

//create query statement
$sqls = SELECT consultantid, firstname, lastname, city, stateprovince,
country, category, yearsexp FROM CONSULTANT WHERE category ='$category'
ORDER BY yearsexp DESC ;

//execute the sql statement (query) on the connection made
$resultset = odbc_do($connectionToDB, $sqls);




//initialize the consultant arrays
$consultantdetailsarray[] = array();
$consultantarray[] = array();

//initialize a variable to zero for start of array below in while loop
$x = 0;

// while there is still results fetch the data from the database --- while
loop
while(odbc_fetch_row($resultset)){

  $consultantdetailsarray[0] = odbc_result($resultset, 1);
  $consultantdetailsarray[1] = odbc_result($resultset, 2);
  $consultantdetailsarray[2] = odbc_result($resultset, 3);
  $consultantdetailsarray[3] = odbc_result($resultset, 4);
  $consultantdetailsarray[4] = odbc_result($resultset, 5);
  $consultantdetailsarray[5] = odbc_result($resultset, 6);
  $consultantdetailsarray[6] = odbc_result($resultset, 7);
  $consultantdetailsarray[7] = odbc_result($resultset, 8);




//dump each consultant into the new array called $consultantarray
  $consultantarray[$x] = $consultantdetailsarray;

 //increment to next element of array
  $x++;
}

}



*
function nextFive($array, $number){
for ($counter = 0; $counter  $number; $counter++){
next($array);

}
}




function previousFive($array, $number){
for ($counter = 0; $counter  $number; $counter++){
prev($array);
}
}



*

//loop through the elements of retrieved array (2nd one holding the
consultant details)

 //second loop to grab through $consultant details array elements
 foreach($consultantarray as $y){

 list($cid, $firstname, $lastname, $city, $stateprovince, $country,
$category, $yearsexp) = $y;

 print trtd align=leftfont color='#663399' face='verdana' size=2a
href='consultantdetails.php?cid= . $cid . '  . $firstname .   .
$lastname . /a/font/tdtd align=leftfont color='#663399'
face='verdana' size=2 . $city . /font/tdtd align=leftfont
color='#663399' face='verdana' size=2 . $stateprovince . /font/tdtd
align=leftfont color='#663399' face='verdana' size=2 . $country .
/font/tdtd align=leftfont color='#663399' face='verdana' size=2 .
$category . /font/tdtd align=leftfont color='#663399' face='verdana'
size=2 . $yearsexp . /font/td/tr;


 }






-- 
PHP General 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] File download results question

2001-11-20 Thread Joe Van Meer

Hi there. I have a small php app that allows a user to download a txt file
that's created 'on the fly' from a database. Everything is working great
except for the actual results displayed on the file...it get results similar
to the code below...it's insertng br tags (and square characters) all over
the place. Could someone tell me the name of the function that removes this?

Thx Joe :)

Delete from databaseBRphpBR//connect to db
br /
$connectionToDB = odbc_connect(codesnipits, joecode, joecode);
br /
br /




-- 
PHP General 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] Re: odbc_num_rows always returns -1

2001-11-20 Thread Joe Van Meer

Hi Peter, from what I hear (and what I've read) with sqlServer you'll always
get a result of -1 for num_rows. To get an accurate count you'll have to use
the count() on the db in a select query. That's one workaround, no doubt
there are others.

SELECT COUNT(my_id) FROM TABLE ...

Cheers Joe :)


Peter Lavender [EMAIL PROTECTED] wrote in message
017301c171b9$dab26f60$090ba8c0@winnie">news:017301c171b9$dab26f60$090ba8c0@winnie...
 Hi Everyone,

 As the subject says.

 I'm using 4.0.6 on IIS/win2k to a MSSQL 2000 database.

 I wish to check if a query returns any values, so the code I have is
nothing
 more than:

 $numRows = odbc_num_rows($result);
 print ($numRowsbr);
 if ($numRows = 0) {

 print(Nothing to show);

 }

 Have I missed something.. with the result always being -1, it causes me
some
 problems.. :)

 Thanks

 Pete




-- 
PHP General 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] Re: odbc_num_rows always returns -1

2001-11-20 Thread Joe Van Meer

Also (I forgot to tell you) you can use that -1 number. The fact that it
is -1 tells you you have records that have been retrieved. Otherwise it will
return 0.

Cheers, Joe :)


Joe Van Meer [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi Peter, from what I hear (and what I've read) with sqlServer you'll
always
 get a result of -1 for num_rows. To get an accurate count you'll have to
use
 the count() on the db in a select query. That's one workaround, no doubt
 there are others.

 SELECT COUNT(my_id) FROM TABLE ...

 Cheers Joe :)


 Peter Lavender [EMAIL PROTECTED] wrote in message
 017301c171b9$dab26f60$090ba8c0@winnie">news:017301c171b9$dab26f60$090ba8c0@winnie...
  Hi Everyone,
 
  As the subject says.
 
  I'm using 4.0.6 on IIS/win2k to a MSSQL 2000 database.
 
  I wish to check if a query returns any values, so the code I have is
 nothing
  more than:
 
  $numRows = odbc_num_rows($result);
  print ($numRowsbr);
  if ($numRows = 0) {
 
  print(Nothing to show);
 
  }
 
  Have I missed something.. with the result always being -1, it causes me
 some
  problems.. :)
 
  Thanks
 
  Pete
 





-- 
PHP General 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] Re: File download results question

2001-11-20 Thread Joe Van Meer

I figured it out...  strip_tags() function did the trick .

Joe


Joe Van Meer [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi there. I have a small php app that allows a user to download a txt file
 that's created 'on the fly' from a database. Everything is working great
 except for the actual results displayed on the file...it get results
similar
 to the code below...it's insertng br tags (and square characters) all
over
 the place. Could someone tell me the name of the function that removes
this?

 Thx Joe :)

 Delete from databaseBRphpBR//connect to db
 br /
 $connectionToDB = odbc_connect(codesnipits, joecode, joecode);
 br /
 br /






-- 
PHP General 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] Re: File download results question

2001-11-20 Thread Joe Van Meer

Is there another way to do this...I'd like to be able to display html code
on my php pages (code examples)
Thx Joe

Henrik Hansen [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 [EMAIL PROTECTED] (Joe Van Meer) wrote:

   I figured it out...  strip_tags() function did the trick .
 

 use strip_tags with caution because it removes some valid text ex:

 something  something

 will be

 something

 after using strip_tags on the text.

 --
 Henrik Hansen



-- 
PHP General 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] File Download Inquiry

2001-11-19 Thread Joe Van Meer

Hi there. How would I go about downloading a file off of the server. The
filename will always be the same in my case. Say it is sitting in a
directory called 'textfiles'. What method/function would I use to download
it to a user's local system?

Thx Joe:)



-- 
PHP General 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] Download File Problem - text not appearing on downloaded file

2001-11-19 Thread Joe Van Meer

Hi there. I managed to get the prompt for a file download when a user clicks
on a text link. The file downloads properly to the client machine, howevr,
when I open up the file there is no content. What do I have to add to the
following code to get the content sent back to the user?

Thx Joe :)

?PHP

header(Content-type: application/octet-stream);
header(Content-Disposition: attachment; filename=file.txt);

?




-- 
PHP General 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] Array From DB sQLServer

2001-11-16 Thread Joe Van Meer

Hi there. I have a table called IMAGES and I would like to retrieve all
image_ids and dump into an array. I'm new to php so any help would greatly
be appreciated. I started my code below, but am unsure what to do next :(

Thx Joe:)

'connect to db
$connectionToDBid = odbc_connect(codesnipits, joecode, joecode);


// sql statement
$sqlb = SELECT image_id FROM IMAGES;

'execute the query and dump into $row variable
$row = odbc_fetch_row($connectionToDBid, $sqlb);


'loop through each record and dump image_ids into array

for each($row as $value){
// assign ids to array here???


}







-- 
PHP General 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] Re: Array From DB sQLServer

2001-11-16 Thread Joe Van Meer

got it :) thx for looking

Joe Van Meer [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi there. I have a table called IMAGES and I would like to retrieve all
 image_ids and dump into an array. I'm new to php so any help would greatly
 be appreciated. I started my code below, but am unsure what to do next :(

 Thx Joe:)

 'connect to db
 $connectionToDBid = odbc_connect(codesnipits, joecode, joecode);


 // sql statement
 $sqlb = SELECT image_id FROM IMAGES;

 'execute the query and dump into $row variable
 $row = odbc_fetch_row($connectionToDBid, $sqlb);


 'loop through each record and dump image_ids into array

 for each($row as $value){
 // assign ids to array here???


 }









-- 
PHP General 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] random images fom db

2001-11-16 Thread Joe Van Meer

Hi there. I have s a php page that randomly grabs an image's path from a db
field and displays it on my php page. My problem is that sometimes when I
refresh the image won't display. So I guess you can say I'm getting
intermittent images...sometimes it displays and sometimes not. I've checked
all of my paths for all of the images and they are all the same. My code is
below.

Thx,  Joe

/connect to db
$connectionToDBid = odbc_connect(codesnipits, joecode, joecode);


// sql statement
$sqlb = SELECT image_id FROM IMAGES;

/run the query and dump into $row variable
$row = odbc_do($connectionToDBid, $sqlb);

//  create an array
$myArray = Array();
srand ((float) microtime() * 1000);

/loop through each record and dump image_ids into array

while(odbc_fetch_row($row)){
// grab and assign ids to array
$imageid = odbc_result($row,1);
$myArray[] = $imageid ;

}

/loop through and print out array values
foreach ($myArray as $value){
print $value;
}


/create $randomimageid  variable here
$randomimageid = array_rand($myArray,1);





/create query statement to grab random image path and dump into variable --
randomimage
$sqlr = SELECT imagepath FROM IMAGES WHERE image_id = $randomimageid;


/run the sql statement on the connection made
$resultset = odbc_do($connectionToDBid, $sqlr);

/dump into $randomimage here
$randomimage = odbc_result($resultset, 1);


/close connection to db
odbc_close($connectionToDBid);

print brbrbrdiv align='center';
print table width='400' border=0 cellpadding=2 ;
print trtd align='left' ;
print  font color='#ff' face='verdana'h4 . Welcome back  .
$firstname . /h4/font;
print /td/tr;
print trtd align='center' ;
print img src='$randomimage'  align='center' border='0'br;
print /td/tr;
print /table;



-- 
PHP General 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] Re: random images fom db

2001-11-16 Thread Joe Van Meer

Got it...if anyone's interested the code is below :)

/connect to db
$connectionToDBid = odbc_connect(codesnipits, joecode, joecode);


// sql statement
$sqlb = SELECT imagepath FROM IMAGES;

/ run the query and dump into $numberofrecords variable
$row = odbc_do($connectionToDBid, $sqlb);

//  create an array
$myArray = Array();

/ seed random number generator
srand ((float) microtime() * 1000);

/ loop through each record and dump image paths into array

while(odbc_fetch_row($row)){
// grab and assign all image paths to array
$imagepath = odbc_result($row,1);
$myArray[] = $imagepath ;

}


/ grab a random index from $myArray here
$imagearrayindex = array_rand($myArray);
$randomimage = $myArray[$imagearrayindex];


print brbrbrdiv align='center';
print table width='400' border=0 cellpadding=2 ;
print trtd align='left' ;
print  font color='#ff' face='verdana'h4 . Welcome back  .
$firstname . /h4/font;
print /td/tr;
print trtd align='center' ;
print img src=' . $randomimage .'  align='center' border='0'br;
print /td/tr;
print /table;




Joe Van Meer [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi there. I have s a php page that randomly grabs an image's path from a
db
 field and displays it on my php page. My problem is that sometimes when I
 refresh the image won't display. So I guess you can say I'm getting
 intermittent images...sometimes it displays and sometimes not. I've
checked
 all of my paths for all of the images and they are all the same. My code
is
 below.

 Thx,  Joe

 /connect to db
 $connectionToDBid = odbc_connect(codesnipits, joecode, joecode);


 // sql statement
 $sqlb = SELECT image_id FROM IMAGES;

 /run the query and dump into $row variable
 $row = odbc_do($connectionToDBid, $sqlb);

 //  create an array
 $myArray = Array();
 srand ((float) microtime() * 1000);

 /loop through each record and dump image_ids into array

 while(odbc_fetch_row($row)){
 // grab and assign ids to array
 $imageid = odbc_result($row,1);
 $myArray[] = $imageid ;

 }

 /loop through and print out array values
 foreach ($myArray as $value){
 print $value;
 }


 /create $randomimageid  variable here
 $randomimageid = array_rand($myArray,1);





 /create query statement to grab random image path and dump into
variable --
 randomimage
 $sqlr = SELECT imagepath FROM IMAGES WHERE image_id = $randomimageid;


 /run the sql statement on the connection made
 $resultset = odbc_do($connectionToDBid, $sqlr);

 /dump into $randomimage here
 $randomimage = odbc_result($resultset, 1);


 /close connection to db
 odbc_close($connectionToDBid);

 print brbrbrdiv align='center';
 print table width='400' border=0 cellpadding=2 ;
 print trtd align='left' ;
 print  font color='#ff' face='verdana'h4 . Welcome back  .
 $firstname . /h4/font;
 print /td/tr;
 print trtd align='center' ;
 print img src='$randomimage'  align='center' border='0'br;
 print /td/tr;
 print /table;





-- 
PHP General 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] Image Upload, renaming question

2001-11-15 Thread Joe Van Meer

Hi there, I have an upload form on my website that works great, however I
have come to a roadblock...how the heck do I rename the copied file?
Everytime I upload an image it overwrites the old one with the new. The code
below uploads the file and displays the following:

Your photo has been uploaded successfully.
Size of Image in Bytes: 36315
Image Type: image/pjpeg
File exists on server.
/rotatingimages/C:\PHP\uploadtemp\php12D.tmp   -- I notice that this is a
temporary name

Here's the code

if(copy($userfile, /ez/codesnipits/temprotatingimages/newimage.jpg)){
print Your photo has been uploaded successfully.br ;
}
else
{
print No luck with the upload dude.br;
}


print Size of Image in Bytes:  . $userfile_size . BR;
print Image Type:  . $userfile_type . BR;

if(file_exists($userfile)){
print File exists on server.br;

 grab newly added filename from directory on server
$filename =  $userfile;


rename file
$newfilename = /rotatingimages/ . $filename;
print $newfilename;

}
else
{
print File doesn't exist on server.br;
}

?


Thx a bunch, Joe:)



-- 
PHP General 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] Re: Image Upload, renaming question

2001-11-15 Thread Joe Van Meer

Thx Richard, I would like the files to all be dumped into one directory,
each with a unique name. Then I will create a path and store that in the db.
Thx for the ideas, I will check them out and get back to youvia this thread.

Cheers Joe:)


Richard Lynch [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Joe Van Meer wrote:

  Hi there, I have an upload form on my website that works great, however
I
  have come to a roadblock...how the heck do I rename the copied file?
  Everytime I upload an image it overwrites the old one with the new. The
  code below uploads the file and displays the following:
 
  Your photo has been uploaded successfully.
  Size of Image in Bytes: 36315
  Image Type: image/pjpeg
  File exists on server.
  /rotatingimages/C:\PHP\uploadtemp\php12D.tmp   -- I notice that this is
a
  temporary name

 If two files were being uploaded at once, you'd get two different names...

 But it's entirely up to *YOU* to decide where to copy the file to.  Maybe
 you'd *WANT* to replace files as they were uploaded.

 I tend to use the user's filename and preg_replace() to get rid of
 everything except a-zA-Z._-  and then checking where I'm copying to tack
on
 1, 2, 3, ... until I find a new filename that's not in use.

 You should also start using http://php.net/move_uploaded_file instead of
 copy or whatever you are doing.

 --
 Like music?  http://l-i-e.com/artists.htm




-- 
PHP General 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] Login/Security Problem

2001-11-14 Thread Joe Van Meer

Hi there. I'm new to php and would like some insight on securing a website.
Upon successful login to my site (checks against database for username and
password) I assign a session variable called '$islogged' to 'yes'. On all
other pages throughout my site I use the following code to determine if this
variable is set, and if not redirect them to the login page.

if($islogged = = no){

header(Location:index.php);
}
elseif(EMPTY($islogged))
{
header(Location:index.php);
}


This seems to work, however, if I close out my browser and say type in
main.php (this page has the above code) in the address bar I can still
access the page. How can I fix this? Is there something else I could be
doing to improve the functionality?
Any insights would greatly be appreciated.

Cheers Joe:)



-- 
PHP General 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] Re: Login/Security Problem

2001-11-14 Thread Joe Van Meer

Thx for replying, so I can do away with the session variable that I was
setting and just set a cookie on their machine and delete it when they
logout? I don't have to check on each page?

Cheer Joe:)


Daniel Masur [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 set a cookie, and delete it with a logout button or when the user leaves
 your domain


 Joe Van Meer [EMAIL PROTECTED] schrieb im Newsbeitrag
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Hi there. I'm new to php and would like some insight on securing a
 website.
  Upon successful login to my site (checks against database for username
and
  password) I assign a session variable called '$islogged' to 'yes'. On
all
  other pages throughout my site I use the following code to determine if
 this
  variable is set, and if not redirect them to the login page.
 
  if($islogged = = no){
 
  header(Location:index.php);
  }
  elseif(EMPTY($islogged))
  {
  header(Location:index.php);
  }
 
 
  This seems to work, however, if I close out my browser and say type in
  main.php (this page has the above code) in the address bar I can still
  access the page. How can I fix this? Is there something else I could be
  doing to improve the functionality?
  Any insights would greatly be appreciated.
 
  Cheers Joe:)
 
 





-- 
PHP General 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] Advice Needed

2001-11-13 Thread Joe Van Meer

Hi there. I have a small php app connected to sqlServer db. The app is used
as a code library for various programming languages. Basically, a code
repository.  My problem is this, I would like to be able to insert the code
for a function (the actual code) into the db. However, I keep running into
the quote problem when inserting. In Asp for example, commenting is done by
using a ' . When I try to insert some asp code into the db via my php app,
it throws errors. Somebody had mentioned that using addslashes() and
stripslashes () functions would do the trick. Is there a better way to do
this or are these two functions the best to use? Also, how do I keep the
formatting of a function to stay the same while inputting and retrieving?

Your time is greatly appreciated!
Thx Joe



-- 
PHP General 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] Cookies, Sessions and Login Process

2001-11-12 Thread Joe Van Meer

Hi there, I'm new to php coming from an asp background and would like to
know the easiest way to automate a login process. I have one page called
'index.php' and it contains a form with 2 elements, username and password.
This page is posted to th 'login.php' and here I do a check against the
database to see if the person is who they say they are. This where I came
across a problem...I would like to set a cookie on the user's machine once I
know they are who they say they are. So I attempted to create a cookie to
hold their username and password upon successful login..I received the
following error...Warning: Cannot add header information - headers already
sent by (output started at E:\ez\codesnipits\login.php:16) in
E:\ez\codesnipits\login.php on line 66.

So I looked up in the manual and found that I can't do it this way. I can't
send header info after the header has been sent for obvious reasons. So how
the heck do I manage to do this?  What I would to do is have the user login
once, and each subsequent time they visit , skip the login process via their
username and password in the cookie.

Any insight to this type of process would greatly be appreciated.

Thx Joe
p.s  Sorry about the bold font ;)





-- 
PHP General 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] Cookies, Sessions and Login Proceess

2001-11-12 Thread Joe Van Meer

Thx Christopher for replying. Ok, let me see if I understand you
correctly...

The user enters username and password on index.php, this is posted to
login.php. On login.php after I verify the user is who he/she says they are
I set a cookie called accessedbefore to yes and redirect them to the
main page. Am I allowed to set a cookie and redirect them after determining
who the user is? How would I redirect them after setting the cookie? Header
function or is there a better way?

Thx Joe :)


Christopher William Wesley [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Just do your authentication before you send any HTML (including any
 whitespace).  I actually recommend not sending ANY HTML from your
 authentication script.  Authenticate them, set your cookie, and redirect
 the visitor to an appropriate next page, based on whether or not they've
 successfully authenticated.

 BTW - storing the username/password in the cookie makes no sense They've
 already authenticated ... just store a user-is-logged-in cookie which
 expires after X minutes/hours/etc.  It's a good practice for when you'll
 have to deal with privacy  security concerns.

 ~Chris   /\
  \ / September 11, 2001
   X  We Are All New Yorkers
  / \ rm -rf /bin/laden

 On Mon, 12 Nov 2001, Joe Van Meer wrote:

  Hi there, I'm new to php coming from an asp background and would like to
  know the easiest way to automate a login process. I have one page called
  'index.php' and it contains a form with 2 elements, username and
password.
  This page is posted to th 'login.php' and here I do a check against the
  database to see if the person is who they say they are. This where I
came
  across a problem...I would like to set a cookie on the user's machine
once I
  know they are who they say they are. So I attempted to create a cookie
to
  hold their username and password upon successful login..I received the
  following error...Warning: Cannot add header information - headers
already
  sent by (output started at E:\ez\codesnipits\login.php:16) in
  E:\ez\codesnipits\login.php on line 66.
 
  So I looked up in the manual and found that I can't do it this way. I
can't
  send header info after the header has been sent for obvious reasons. So
how
  the heck do I manage to do this?  What I would to do is have the user
login
  once, and each subsequent time they visit , skip the login process via
their
  username and password in the cookie.
 
  Any insight to this type of process would greatly be appreciated.
 
  Thx Joe
  p.s  Sorry about the bold font ;)
 
 
 
 
 
  --
  PHP General 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 General 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] Cookies, Sessions and Login Proceess

2001-11-12 Thread Joe Van Meer

Thanx a bunch you guys! Got my login process going the way I wanted it. I
appreciate your help, as I['m new to php. The first of many questions I
suppose :)
Cheers Joe


Christopher William Wesley [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Mon, 12 Nov 2001, Joe Van Meer wrote:

  Thx Christopher for replying. Ok, let me see if I understand you
  correctly...
 
  The user enters username and password on index.php, this is posted to
  login.php. On login.php after I verify the user is who he/she says they
are
  I set a cookie called accessedbefore to yes and redirect them to the

 Exactly.

  main page. Am I allowed to set a cookie and redirect them after
determining
  who the user is? How would I redirect them after setting the cookie?
Header

 You can set a cookie any time before any standard output is sent to the
 browser (and before you send a new Location header).

 Your login.php can look something like this (with pseudo-ish code) ...

 ?php
 $input_ok = validate_user_input( $username, $password );
 if( $input_ok ){
 $user_ok = authenticate_user( $username, $password );
 if( $user_ok ){
 setcookie( myuser, ok, time()+7200, / );
 header( Location: congratulations.html );
 } else {
 header( Location: go_away.html );
 }
 } else {
 header( Location: go_away.html );
 }
 ?


 ~Chris   /\
  \ / September 11, 2001
   X  We Are All New Yorkers
  / \ rm -rf /bin/laden




-- 
PHP General 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] Destroying Session Prob

2001-11-12 Thread Joe Van Meer

   Hi again, I've just completed my logout process, everything is going
great but after I log out (logout.php has session_start() followed by
session_destroy(). )
I get two weird symbols printing out. One is like a box and the a B. My
code is below.

?php session_start(); ?

?php
session_destroy();
print You are now logged off.  BR
?


Any ideas why I'm getting these 2 symbols printing out?

Thx Joe :)



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