[PHP] Re: registering a session variable from a select statment.
Hi there :) Try something like this: session register (user_auth_level); $user_auth_level = $user_level; HTH, Joe :) Matthew Darcy [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]; Hi, I have a user auth script. Very simple and works. when I check the username and password I check it against a select all the values from the user table where the username and password match. (inputted from a 2 text boxes) like so file://sets and runs SQL statement that brings back all info on user which matches us ername and password. $sql_authorisation = SELECT * FROM account_details WHERE account_name='$login_username' AND account_password=PASSWORD'$login_password'); $sql_authorisation_result = mysql_query($sql_authorisation); I then register 2 session variables $login_username and $login_password I would like to register a session variable from the select * I did earlier from the field user_level in the select statment so session register $user_auth_level='user_level' is this the correct way to do this ??? Thanks, Matt. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: registering a session variable from a select statment.
Ammendment: You'll have to dump that value (the user's level) into a variable called user_level first. HTH Joe :) Lerp [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]; Hi there :) Try something like this: session register (user_auth_level); $user_auth_level = $user_level; HTH, Joe :) Matthew Darcy [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]; Hi, I have a user auth script. Very simple and works. when I check the username and password I check it against a select all the values from the user table where the username and password match. (inputted from a 2 text boxes) like so file://sets and runs SQL statement that brings back all info on user which matches us ername and password. $sql_authorisation = SELECT * FROM account_details WHERE account_name='$login_username' AND account_password=PASSWORD'$login_password'); $sql_authorisation_result = mysql_query($sql_authorisation); I then register 2 session variables $login_username and $login_password I would like to register a session variable from the select * I did earlier from the field user_level in the select statment so session register $user_auth_level='user_level' is this the correct way to do this ??? Thanks, Matt. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Form Annoyances
Hi there :) Use the addslashes() function prior to insertion to database, and stripslashes() on retrieval from db before you display it. //prior to db insertion $myvar = addslashes($myvar); //on retrieval $myvar = stripslashes($myvar); Since you are wanting to display it to the user before inserting to the databse, you'll have to add, then strip before displaying, and then use the addslashes() again prior to inserting. When retrieving this data at a later point you'll have to use stripslashes() again. Hope this helps, Joe :) James Taylor [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I'm having this one issue that's really bugging me - I have a textarea where you can type in something - After typing it in, it goes to another page asking you to verify, if it's correct, it inserts it into a database. The page that asks you to verify holds the value of the textbox in a hidden form field. If the value the user entered in contains any single (') or double () quotes, it will mess everything up. Single quotes end up having a backslash thrown automatically in front of it, and it inserts it into the database WITH THE backslash. If there are double quotes, the HTML will get messed up due to the fact that when it sees the quote, it will cut off the rest of the value because if: value=this is an example: Hello how are you. everything after example: is going to get cut off. I tried putting the value in a query string, but when traveling across two pages, it seems to do the exact same thing. Any suggestions? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php - assigning date variables
Hi there :) 1. mysql_query(SELECT * FROM table WHERE date ='$mydate'); # where date is same 2. mysql_query(SELECT * FROM table WHERE date '$mydate'); # where date is newer 3. mysql_query(SELECT * FROM table WHERE date '$mydate'); # where date is older 4.mysql_query(SELECT * FROM table WHERE date BETWEEN '$myfirstdate' AND '$myseconddate'); # where date is between 2 dates Hope this helps, Joe :) Craig Westerman [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... $query = mysql_query(SELECT * FROM table WHERE date LIKE '%. $query .%'); // returns all items in database $query = 2001-01-01 mysql_query(SELECT * FROM table WHERE date LIKE '%. $query .%'); // returns all rows that have 2001-01-01 as the date What is proper way to define a variable to include all dates newer than 1995-01-01? $query = ??? What is proper way to define a variable to include all dates older than 1995-01-01? $query = ??? What is proper way to define a variable to include all dates between 1995-01-01 and 1998-12-31? $query = ??? Everything I tried gives me a error. This has to be simple, but I must be overlooking something. Where would I find the answer? Thanks Craig [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Uploading Files with PHP
Hi Jim, here's how I do it. I test for the file size on the processing page as well, if it's too large I redraw out the upload form. //test for file extension type if needed //determine file size -- if too big ( greater 50kb) then redirect $siz = filesize($userfile); if ($siz = 51200){ //redraw upload form print font face='verdana' size='2' class='text_size_9'The photo you attempted to upload was too large in file size. Please ensure that the file size does not exceed 50kb./font; print form method='POST' action='photoupload.php' enctype='multipart/form-data'input type='hidden' name='MAX_FILE_SIZE' value='51200' input type='file' name='userfile' size='15' style='font-family: Verdana; font-size: 8pt;'input type='submit' name='submit' value='Upload' style='font-family: Verdana; font-size: 8pt;'; print /form; } elseif ($siz 51200) { $timestamp = time(); $userfile_name = $timestamp.$userfile_name ; // copy the file being posted if(copy($userfile, /dir/dir/pics/. $userfile_name)){ print font face='verdana' size='2' class='text_size_9'Your photo has been uploaded and is viewable in the photo gallery./fontbrbr ; } else { print font face='verdana' size='2' class='text_size_9'A problem was encountered during your photo upload./fontbr; } $patharola = pics/. $userfile_name; //connect to db $connectionToDBid = odbc_connect(dgsff, sdgsdfg, sdfgsdfg); //create query statement $sqlr = INSERT INTO PHOTO (golferid, photo, caption, datesubmitted) VALUES ('$sesgolferid' , '$patharola', '$caption', '$todaysdate' ); //execute the sql statement (query) on the connection made $resultset = odbc_do($connectionToDBid, $sqlr); blah blah blah ... Hope this helps you out, Joe :) Jim Koutoumis [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Joe, Do you know when the file size is checked ?? I think it only gets checked after the form is posted and file uploading is finished ?? I don't know how it's possible to catch things before user uploads - now that would be neat :-) Jim. Lerp [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi there :) Did you set a max file size in your upload form? See my form below, notice the 'MAX_FILE_SIZE' value='102400' part within hidden field. This should appear before the rest of the form. You can adjust this value as you wish. form action='resumeupload.php' method='post' enctype='multipart/form-data' input type='hidden' name='MAX_FILE_SIZE' value='102400' font color='#663399' face='verdana' size=2bUpload Resume:/b/font input type='file' name='userfile' style='background-color: #FF; font-family: verdana; font-weight: bold; color: #FF; font-size: 9pt;' input type='submit' value='Upload!!!' style='background-color: #FF; font-family: verdana; font-weight: bold; color: #FF; font-size: 9pt;' name=submit /form Hope this helps, Joe :) Chuck Pup Payne [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi, I am trying to set a small script that would let my clients upload file with a Explorer or Netscape, but the problem is it would let me upload any file that is great than a 1MB. We get an error that the file none could not be read. I have set the upload_tmp_dir=/tempupload is has been chmod to 777, php.ini as been set to 20MB, I know that is a lot but we are engingeering company that work with CADD files. Any clues where to look? The PHP 4 Bible from IDG states that we have to under HTTP uploads, but nothing else. Is there some where on the net that explains better what I have to set up, turn on, or haven't done? Thanks, Chuck -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Uploading Files with PHP
Ammendment: Actually, I was just looking at one of my photoupload processes and I actually removed the MAX_FILE out of the upload form and only tested the file size on the processing page like in the previous message. Cheers, Joe :) Lerp [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi Jim, here's how I do it. I test for the file size on the processing page as well, if it's too large I redraw out the upload form. file://test for file extension type if needed file://determine file size -- if too big ( greater 50kb) then redirect $siz = filesize($userfile); if ($siz = 51200){ file://redraw upload form print font face='verdana' size='2' class='text_size_9'The photo you attempted to upload was too large in file size. Please ensure that the file size does not exceed 50kb./font; print form method='POST' action='photoupload.php' enctype='multipart/form-data'input type='hidden' name='MAX_FILE_SIZE' value='51200' input type='file' name='userfile' size='15' style='font-family: Verdana; font-size: 8pt;'input type='submit' name='submit' value='Upload' style='font-family: Verdana; font-size: 8pt;'; print /form; } elseif ($siz 51200) { $timestamp = time(); $userfile_name = $timestamp.$userfile_name ; // copy the file being posted if(copy($userfile, /dir/dir/pics/. $userfile_name)){ print font face='verdana' size='2' class='text_size_9'Your photo has been uploaded and is viewable in the photo gallery./fontbrbr ; } else { print font face='verdana' size='2' class='text_size_9'A problem was encountered during your photo upload./fontbr; } $patharola = pics/. $userfile_name; file://connect to db $connectionToDBid = odbc_connect(dgsff, sdgsdfg, sdfgsdfg); file://create query statement $sqlr = INSERT INTO PHOTO (golferid, photo, caption, datesubmitted) VALUES ('$sesgolferid' , '$patharola', '$caption', '$todaysdate' ); file://execute the sql statement (query) on the connection made $resultset = odbc_do($connectionToDBid, $sqlr); blah blah blah ... Hope this helps you out, Joe :) Jim Koutoumis [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Joe, Do you know when the file size is checked ?? I think it only gets checked after the form is posted and file uploading is finished ?? I don't know how it's possible to catch things before user uploads - now that would be neat :-) Jim. Lerp [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi there :) Did you set a max file size in your upload form? See my form below, notice the 'MAX_FILE_SIZE' value='102400' part within hidden field. This should appear before the rest of the form. You can adjust this value as you wish. form action='resumeupload.php' method='post' enctype='multipart/form-data' input type='hidden' name='MAX_FILE_SIZE' value='102400' font color='#663399' face='verdana' size=2bUpload Resume:/b/font input type='file' name='userfile' style='background-color: #FF; font-family: verdana; font-weight: bold; color: #FF; font-size: 9pt;' input type='submit' value='Upload!!!' style='background-color: #FF; font-family: verdana; font-weight: bold; color: #FF; font-size: 9pt;' name=submit /form Hope this helps, Joe :) Chuck Pup Payne [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi, I am trying to set a small script that would let my clients upload file with a Explorer or Netscape, but the problem is it would let me upload any file that is great than a 1MB. We get an error that the file none could not be read. I have set the upload_tmp_dir=/tempupload is has been chmod to 777, php.ini as been set to 20MB, I know that is a lot but we are engingeering company that work with CADD files. Any clues where to look? The PHP 4 Bible from IDG states that we have to under HTTP uploads, but nothing else. Is there some where on the net that explains better what I have to set up, turn on, or haven't done? Thanks, Chuck -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Link Inquiry
Hi there, been thinking about how to retrieve all links on a webpage. How would I go about grabbing all links from a particular page? Thx Joe :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Link Inquiry
Thx Julio :) Lerp [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi there, been thinking about how to retrieve all links on a webpage. How would I go about grabbing all links from a particular page? Thx Joe :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Upload script with user admin
I forgot to add the security at the top of that code I sent. Upon a successful login you might want to create a session variable to signify that they are logged in. At the top of the pages you want to be secure from 'other' users just do a test at the top to check to see if that variable was set. If not, redirect them to another page like in the example below: HTH Joe :) if (!isset($HTTP_SESSION_VARS[islogged])){ header(Location:index.php); } Lerp [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi there, here's a bit of code to get you started. It includes a form that allows uploads, and the code to process the upload on the receiving page. Basically, you have a form that allows an upload of a file on one page, and some code on the receiving page to insert a path to that file in the database and store the newly uploaded file in a directory on the webserver. Of course you'll have to ensure that you have the proper write and read permissions on that folder. There are a few 'print' lines sprinkled throughout the code. For debugging you might want to un-comment them to see how everything is working. Hoe this helps you out! Joe/Lerp :) Here's a common form that allows you to upload a file (say an image or any type of file for that matter) to the db form action='upload.php' method='post' enctype='multipart/form-data' input type='hidden' name='MAX_FILE_SIZE' value='25000' Pfont color='#ff' face='verdana' size=1Upload Photo:/fontinput type='file' name='userfile'input type='submit' value='Upload!!!'/form/p end of upload form ## start of upload process to db ?php #$userfile is the file being uploaded file://print $userfile . BR; file://print $userfile_name . BR; file://determine file size -- if too big ( greater 50kb) then redirect $siz = filesize($userfile); file://print $siz; $ext = substr($userfile_name, -4); // if the file not of type 'jpg' then redraw out upload form if($ext != .jpg){ print font face='verdana' size='2' class='text_size_9'The photo you attempted to upload was of the wrong file type. Please ensure that the file type is a 'jpg'./font; print form method='POST' action='photoupload2.php' enctype='multipart/form-data'input type='file' name='userfile' size='15' style='font-family: Verdana; font-size: 8pt;'input type='submit' name='sub mit' value='Upload' style='font-family: Verdana; font-size: 8pt;'; print /form; print /td/tr/table; print table width='470' cellspacing='10' cellpadding='10' border='0'; print trtd height=30/tdtd height=30/td/tr; print trtd align=leftform name='forma' method='' action='photos.php'input type='submit' name='submit' value='laquo;nbsp;Photos' style='background-color: #FF; font-family: verdana; font-weight: bold; color: #363C70; font-size: 10pt;'/form/tdtd/td/tr; print /table/td; print td width='1' bgcolor='#FF' height='341'img src='images/pixel_transparent.gif' width='1' height='1' border='0' alt=''/td; print td width='245' bgcolor='#363C70' align='center' valign='top' height='341'; print table cellspacing='0' cellpadding='0' border='0'; print tr td/td/trtr; print td bgcolor='#FF'img src='images/pixel_transparent.gif' width='1' height='1' border='0' alt=''/td/tr/table; print table cellspacing='0' cellpadding='5' border='0'tr; print tdimg src='images/bullet_quick_tips_small.gif' width='17' height='17' border='0' alt=''/td; print tdfont face='verdana' size='1' class='text_size_8' a href='contact.php' class='link_white_02'Send us some feedback!/a/font/td; print /tr/table/td/tr/table; exit; } if ($siz = 51200){ file://redraw upload form print font face='verdana' size='2' class='text_size_9'The photo you attempted to upload was too large in file size. Please ensure that the file size does not exceed 50kb./font; print form method='POST' action='photoupload2.php' enctype='multipart/form-data'input type='file' name='userfile' size='15' style='font-family: Verdana; font-size: 8pt;'input type='submit' name='submit' value='Upload' style='font-family: Verdana; font-size: 8pt;'; print /form; } elseif ($siz 51200) { $timestamp = time(); $userfile_name = $timestamp.$userfile_name ; // copy the file being posted -- remember to escape backslashes!!! if(copy($userfile, /ez/golfPHP/pics/. $userfile_name)){ print font face='verdana' size='2' class='text_size_9'Your photo has been uploaded and is viewable in the photo gallery./fontbrbr ; } else { print font face='verdana' size='2' class='text_size_9'A problem was encountered during your photo upload./fontbr; } $patharola = pics/. $userfile_name; file://print $patharola; $caption = No Caption.; // insert path into database here file://connect to db $connecti
[PHP] Re: Escaping a double-quote problem
Look up addslashes and stripslashes in the manual. Normally you'd use addslashes going into the db, and stripslashes coming out for display. HTH Joe :) Anton Kolev [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Any idea why when I print the value of $text, I get a backslash in front of the result? $text=preg_replace(/\/, quot;, $text); $text=preg_replace(/\/, A, $text); $text=str_replace(\, A, $text); Contrary: $text=preg_replace(//, amp;, $text); works quite well. cheerz -- 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: Upload script with user admin
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 /div end of confirmation page### ###processing page### ?php session_start(); ? ?php if (!isset($HTTP_SESSION_VARS[islogged])){ header(Location:index.php); } if(isset($dodelete)){ //connect to db $connectionToDB = odbc_connect(gfghf, jofgh6lf, hghdfg); //determine which file to delete off of the server (and delete it) before deleting it out of db $sqlphoto = SELECT photo
[PHP] Re: Problems with date function
Hi there :) Check this out. It grabs the date from your table, and uses the mktime and date functions to format the date properly :) //format the gamedate for display below $month = substr($gamedate, 5, 2); //print $month . BR; $day = substr($gamedate, 8, 2); //print $day . BR; $year = substr($gamedate, 0, 4); //print $year . BR; $gamedateinsecs = mktime(0,0,0,$month, $day, $year); $formattedgamedate = date('F j Y',$gamedateinsecs); //print $formattedgamedate; Hope this helps you out :) Joe / Lerp :) Jorge Arechiga [EMAIL PROTECTED] wrote in message 21B9FB8DEA88D41195890050BF064487093C9E@CORREO">news:21B9FB8DEA88D41195890050BF064487093C9E@CORREO... Hi everybody I hope someone can help me in an issue on where i've been stuck for a while. I'm trying to show a date from a Table in SQLServer7 when i use this : trtd align=right width=60%? echo (odbc_result($resultd1,'date1'));?/td/tr the browser shows me the date correctly and the result is this: 2002-02-01 11:31:00 Obviously i want to format the date so i use the date() function and the code is like this: trtd align=right width=60%? echo date(m d Y,odbc_result($resultado,'fechaasignacion'));?/td/tr But when i want to see the date in the browser the date doesn´t match with the real date and the result is this: 12 31 1969 Does anybody knows how coul i fix this, so the displayed date matches with the one that is in the database? Thank a lot George -- 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: How do I use a confirm box to confirm before deletion from a database
Hi Ivan, I've this a number of times. What I suggest is that you have two forms, each with a button on the page that receives the delete request. Both forms post to the processing page. The first button passes a value called dodelete and the second one passes another value say, dontdelete. On the processing page you determine if $dodelete is set, if it is then do your delete. If not, redirect them to another page and bypass the whole deleteion process. Below if the code I use on the processing page: ?php session_start(); ? ?php if (!isset($HTTP_SESSION_VARS[islogged])){ header(Location:index.php); } if(isset($dodelete)){ // connect to db $connectionToDB = odbc_connect(4gdols4f, jolf, rty); $sqldel = DELETE FROM RECOMMENDATION WHERE recid ='$recid'; odbc_do($connectionToDB, $sqldel); } else { header(Location:login.php); } ? Ivan Carey [EMAIL PROTECTED] wrote in message 006301c1a7f4$a195ea60$0201a8c0@icarey">news:006301c1a7f4$a195ea60$0201a8c0@icarey... Hello, Thankyou for your reply. When a user clicks upon a delete link that deletes a record from a database, I would like to be able to give them the option to OK or Cancel this action. I have tried coding the browsers built in confirm box (I can bring up this) but am unable to combine it with php or a combination of php and a javascript funtion Thanks, Ivan -- 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 Fields and PHP...
Hi again, I guess one really good reason for not storing images directly in a db table is performance. When you store a blob in a table it affects the whole database's performance. It slows it down, that's why the most common method is to store the images in a dir on the webserver and store only the path to the image in the databse field. That code I posted in the previous will allow uploading of an image to a directory on the server, store the path to the image in the correct record for retrieval at a later point. It also retrieves an image for a particular record. HTH Joe :) Zara E Gonzalez [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Not sure if this is off topic for this list or not, but thought I would try... I have a Linux server running Redhat 7.0, PHP 4.1.1, and freetds 0.53. My Linux server connects to a Win2k server running MSSQL 2000. Everything works wonderfully, except, I have an image field in one of my tables and I can't seem to find a way to pull it out without having PHP completely freak out. (i.e. I get no error message at all just page cannot be displayed) So I'm wondering, can you pull image fields out with PHP? If so, I'm guessing my limitation is freetds. If not, is there any way to pull an image out of a database using php? (i.e. store it in a different type of field not image.) Any help is appreciated, Thanks, Zara -- 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 Fields and PHP...
Hi Zara, are you storing a path to the images in your db? Or the actual image? It's recommended that you stay away from storing actual images in the db. If you are storing a path the code below might help you out. It select a firstname, and an image according to an id. You'll have to change the youridentityfield and youridentity values to suit your needs. If you are looking for an image upload script # display image from db # #connect to db $connectionToDBid = odbc_connect(ceo34deesnr43ipits, joeyscode, joeyscode); // sql statement $sqlb = SELECT imagepath, firstname FROM IMAGES WHERE youridentityfield = . $youridentity; # execute the query $resultset = odbc_do($connectionToDBid, $sqlb); $image = odbc_result($resultset,1); $firstname = odbc_result($resultset,2); 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=' . $image.' align='center' border='0'br; print /td/tr; print /table; # close the db connection here # end of display image from db # #photo upload form Here's a common form that allows you to upload a file (say an image) to the db form action='upload.php' method='post' enctype='multipart/form-data' input type='hidden' name='MAX_FILE_SIZE' value='102400' Pfont color='#ff' face='verdana' size=1Upload Photo:/fontinput type='file' name='userfile'input type='submit' value='Upload!!!'/form/p end of photo upload form ## start of upload process to db ?php # $userfile is the file being uploaded # print $userfile . BR; # print $userfile_name . BR; #use a time stamp to uniquely name the image before storing in db to prevent two files with the same name $timestamp = time(); $userfile_name = $timestamp.$userfile_name ; // copy the file being posted -- remember to escape backslashes!!! if(copy($userfile, /ez/codesnipits/consultant/tempimages/. $userfile_name)){ print font face='Verdana, Arial, Helvetica, sans-serif' color='#663399' size='2'Your picture has been uploaded successfully and has been made available for online users to view./fontbrbrbr ; } else { print font face='Verdana, Arial, Helvetica, sans-serif' color='#663399'Error encountered during resume upload process./fontbr; } $patharola = tempimages/. $userfile_name; // insert path into database here # connect to db $connectionToDBid = odbc_connect(cdefc5onwesulertt, joeyscon, joeyscon); session_register(consultantid); $consultantid = $consultantid; # create query statement -- update image field in db using path $sqlr = UPDATE CONSULTANT SET image= '$patharola' WHERE consultantid= . $consultantid; # execute the sql statement (query) on the connection made $resultset = odbc_do($connectionToDBid, $sqlr); ? end of image to db process ## Hope this helps you out :) Cheers Joe :) Zara E Gonzalez [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Not sure if this is off topic for this list or not, but thought I would try... I have a Linux server running Redhat 7.0, PHP 4.1.1, and freetds 0.53. My Linux server connects to a Win2k server running MSSQL 2000. Everything works wonderfully, except, I have an image field in one of my tables and I can't seem to find a way to pull it out without having PHP completely freak out. (i.e. I get no error message at all just page cannot be displayed) So I'm wondering, can you pull image fields out with PHP? If so, I'm guessing my limitation is freetds. If not, is there any way to pull an image out of a database using php? (i.e. store it in a different type of field not image.) Any help is appreciated, Thanks, Zara -- 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] Paging using arrays Question
Hi there, I have a db with only one table in it called CONSULTANT. I'm using sqlServer and would like to do record paging, say 5 at a time. I'm aware that sqlServer doesn't support the LIMIT statement so I've decided to do it using arrays. So I've written the appropriate query statement, managed to grab details for each consultant and dump that array into a new array called $consultantarray. Now, what I'd like to be able to do is this...return 5 records at a time. Have 2 links called next and previous that when clicked adjusts the $consultantarray accordingly. Can someone take a look at my code below and tell me where I have to go from here. So far the arrays are fine (meaning they are holding the appropriate values), just the display of the appropriate records from the array is my big problemo. :) I currently have a foreach loop being used, but am unsure if this is the correct route to take, in fact, I know this isn't right because it's displaying the records oddly. Thx for your help, Joe :) ?php #connect to db $connectionToDB = odbc_connect(cdxcet, joecqon, joecoqdsn); #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); print h4 align='left'font color='#663399' face='verdana'Consultant Search Results for: . $category . /font/h4; #print out results here #start the table -- loop through rows below print table width='740' cellpadding='5' cellspacing='0' border='0'; print trtd align='left' width='230'font color='#663399' face='verdana'bName/b/font/tdtd align='left' width='200'bfont color='#663399' face='verdana'City/font/b/tdtd align='left' width='200'bfont color='#663399' face='verdana'State/Province/font/b/tdtd align='left' width='200'bfont color='#663399' face='verdana'Country/font/b/tdtd align='left' width='200'bfont color='#663399' face='verdana'Category/font/b/tdtd align='left' width='200'bfont color='#663399' face='verdana'Years Exp/font/b/td/tr; print trtd height=10/tdtd/tdtd/td/tr; #initialize the consultant details array $consultantdetailsarray[] = array(); // fetch the data from the database 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[] = $consultantdetailsarray; } #forloop to iterate through array of consultants foreach ($consultantarray as $value){ $cid = $consultantdetailsarray[0]; $firstname = $consultantdetailsarray[1]; $lastname = $consultantdetailsarray[2]; $city = $consultantdetailsarray[3]; $stateprovince = $consultantdetailsarray[4]; $country = $consultantdetailsarray[5]; $category = $consultantdetailsarray[6]; $yearsexp = $consultantdetailsarray[7]; 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; } print /tablebrbr; print The count of the consultant array elements is : . count($consultantdetailsarray) . BR; print The record count of returned consultants according to category selected is : . sizeof($consultantarray) . BR; // close the connection odbc_close($connectionToDB); ? -- 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] Form Question
Hi there, how do I keep values in a form if the user has to go back and fill in some missing fields? 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] Display Problemo
I have a small php app that I'm building to display, insert, edit, etc... various types of code snipits (asp, php, html, etc...) in a db. I also have a download option that creates a text file with the code that they've selected. I have 2 problems...the first is that when I go to view the text file I have all sorts of BR tags within the text, this is due to the nl2br function I used prior to the db insertion. How would I get rid of those? The seond problem is when a user goes to view an html code example on the webpage, say with a hyperlink, the hyperlink is made active replacing the code with the actual a href tag. Thx in advance, Lerp -- 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: kill a session...
session_start(); /unset any session variables session_unset(islogged); /kill the session session_destroy(); HTH Joe:) Romeo Manzur [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Somebody know how to kill a session when a user left the page??? -- 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]