Jump to content

ylkien

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ylkien's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi guys, I'm trying to get data from DB2 (which has the table "test2"), which will be used in DB1 (which has the table "test1"). I tried the command below, but it doesn't work. Do I need a script? If so, where can I learn it? Select * from test1 where id in ( select id from test2) Thanks!
  2. I did a walk-around, by manually searching the array (instead of using array_search), and it works nicely... Anyone knows the solution for this problem? Is my initialisation incorrect?
  3. Hi, I have added it in already. The main part of the code that creates this problem is : else { echo "<BR>Array has " . count( $_SESSION['Uploaded_Files']) . " values. File to be deleted is " . $_REQUEST['File'] . "<BR>"; reset( $_SESSION['Uploaded_Files']) ; print "<pre>";var_dump($_SESSION['Uploaded_Files']);print"</pre>"; /* echo "<BR>Array Before array_search and array_slice<BR><BR>"; $i = 0; //to be removed later foreach( $_SESSION['Uploaded_Files'] as $Temp_Array ) { echo $Temp_Array . $i . " has been uploaded <FONT>[<A HREF=\"" . $_SERVER['PHP_SELF'] . "?Action=Delete&File=" . $Temp_Array . "\">delete</A>]</FONT><BR>" ; $i++; } */ echo "<BR>Array_Search returned value : " . array_search( $_REQUEST['File'], $_SESSION['Uploaded_Files'] ); echo "<BR>Array Search found <B>" . $_REQUEST['File'] . "</B> at location <B>" . array_search( $_REQUEST['File'], $_SESSION['Uploaded_Files'] ) . "</B>"; array_splice( $_SESSION['Uploaded_Files'], array_search( $_REQUEST['File'], $_SESSION['Uploaded_Files'] ), 1 ); //echo array_search( $_REQUEST['File'], $_SESSION['Uploaded_Files'] ); //array_splice( $_SESSION['Uploaded_Files'], array_search( $_REQUEST['File'], $_SESSION['Uploaded_Files'] ), 1 ); unlink( $UPLOAD_TEMP . "/" . $_REQUEST['File'] ); <?php error_reporting(E_ALL); //remove later session_start(); //include 'Protected/Functions.php'; //This is where all of the functions are stored! //include 'Protected/Database.php'; //This is where the database connections and variables are stored $UPLOAD_TEMP = "Upload_Temp"; $UPLOAD_PERMANENT = "Files"; /* if( !empty( $_REQUEST($FILE_UPLOAD_DISPLAY_HTML) ) ) $FILE_UPLOAD_DISPLAY_HTML = $_REQUEST($FILE_UPLOAD_DISPLAY_HTML); else $FILE_UPLOAD_DISPLAY_HTML = array(); */ if( isset( $_SESSION['Uploaded_Files'] ) || !session_is_registered('Uploaded_Files') ) { $Uploaded_Files = array(); session_register("Uploaded_Files"); } if( isset( $_SESSION['Uploaded_Files_Number'] ) || !session_is_registered('Uploaded_Files_Number') ) { $Uploaded_Files = 0; session_register("Uploaded_Files_Number"); } if( isset( $_SESSION['Error'] ) || !session_is_registered('Error') ) { $Error = 0; session_register("Error"); } /* if( !$_SESSION['Auth'] || !$_SESSION['User'] ) { echo "This is a private site. Please login to proceed...<BR>"; //header("Location: http://$_SERVER[sERVER_ADDR]/$LOGIN_PAGE"); session_destroy(); echo "<meta http-equiv=\"refresh\" content=\"3;URL=http://" . $_SERVER['SERVER_ADDR'] . "/" . $LOGIN_PAGE . "\">"; exit; } */ // Upload files ******************************************************************************************************** //This function does the actual work of saving the file into the $Target_Path function Save_Uploaded_File( $UPLOAD_TEMP ) { $File_Upload_Error = array( "There is no error, the file uploaded with success", "The uploaded file exceeds the upload_max_filesize directive in php.ini", "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form", "The uploaded file was only partially uploaded", "No file was uploaded", "Missing a temporary folder" ); $Target_Path = $_SERVER['DOCUMENT_ROOT'] . "/" . $UPLOAD_TEMP . "/"; $Target_Path = $Target_Path . basename( $_FILES['Picture']['name']); if( move_uploaded_file($_FILES['Picture']['tmp_name'], $Target_Path) ) { //echo "<BR>The file ". basename( $_FILES['Picture']['name']). " has been uploaded"; //to be removed $_SESSION['Uploaded_Files'][$_SESSION['Uploaded_Files_Number']] = basename( $_FILES['Picture']['name'] ); } else { $_SESSION['Error'] .= "There was an error uploading the file!" . $File_Upload_Error[$_FILES['Picture']['error']] . ". Please try again<BR>"; } $_SESSION['Uploaded_Files_Number']++; } //Checks whether the 'file submit' button is selected if( empty($_SESSION['Error']) && isset($_REQUEST['_submit_check']) ) { if( empty($_FILES['Picture']['name'] ) ) $_SESSION['Error'] = "No file was selected to be uploaded"; //check if file has already been uploaded into the drive, and if so, will write to the $_SESSION['Error'] if( !empty($_FILES['Picture']['name']) && !empty($_SESSION['Uploaded_Files']) && empty($_SESSION['Error']) ) { foreach( $_SESSION['Uploaded_Files'] as $Temp_Array ) { if( $Temp_Array == basename( $_FILES['Picture']['name'] ) ) { $_SESSION['Error'] .= "This file, <i>" . $Temp_Array . "</i>, has already been uploaded, and can't be uploaded again. <BR>"; break; } } } //Does the actual action of uploading the file. Calls the function "$Save_Uploaded_File" if( empty($_SESSION['Error']) ) // && ($_FILES['Picture']['name'] == $_SESSION['Uploaded_Files'][$_SESSION['Uploaded_Files_Number']]) ) { Save_Uploaded_File( $UPLOAD_TEMP ); } } //This deletes the file in the upload temp folder, if the user chooses so. else if( empty($_SESSION['Error']) && isset( $_REQUEST['Action']) ) { if( empty($_REQUEST['File'] ) || $_REQUEST['Action'] != "Delete" ) $_SESSION['Error'] = "No file selected to be deleted"; else if( !file_exists( $UPLOAD_TEMP . "/" . $_REQUEST['File'] ) ) { echo "<BR>Array_Search value when 'file not found' is : " . array_search( $_REQUEST['File'], $_SESSION['Uploaded_Files'] ); $_SESSION['Error'] = "File not found."; array_splice( $_SESSION['Uploaded_Files'], array_search( $_REQUEST['File'], $_SESSION['Uploaded_Files'] ), 1 ); } else { echo "<BR>Array has " . count( $_SESSION['Uploaded_Files']) . " values. File to be deleted is " . $_REQUEST['File'] . "<BR>"; reset( $_SESSION['Uploaded_Files']) ; print "<pre>";var_dump($_SESSION['Uploaded_Files']);print"</pre>"; /* echo "<BR>Array Before array_search and array_slice<BR><BR>"; $i = 0; //to be removed later foreach( $_SESSION['Uploaded_Files'] as $Temp_Array ) { echo $Temp_Array . $i . " has been uploaded <FONT>[<A HREF=\"" . $_SERVER['PHP_SELF'] . "?Action=Delete&File=" . $Temp_Array . "\">delete</A>]</FONT><BR>" ; $i++; } */ echo "<BR>Array_Search returned value : " . array_search( $_REQUEST['File'], $_SESSION['Uploaded_Files'] ); echo "<BR>Array Search found <B>" . $_REQUEST['File'] . "</B> at location <B>" . array_search( $_REQUEST['File'], $_SESSION['Uploaded_Files'] ) . "</B>"; array_splice( $_SESSION['Uploaded_Files'], array_search( $_REQUEST['File'], $_SESSION['Uploaded_Files'] ), 1 ); //echo array_search( $_REQUEST['File'], $_SESSION['Uploaded_Files'] ); //array_splice( $_SESSION['Uploaded_Files'], array_search( $_REQUEST['File'], $_SESSION['Uploaded_Files'] ), 1 ); unlink( $UPLOAD_TEMP . "/" . $_REQUEST['File'] ); } } $main_table = " <FORM ENCTYPE=\"multipart/form-data\" ACTION=\"" . $_SERVER['PHP_SELF'] . "\" METHOD=POST > <TABLE ALIGN=LEFT BORDER=0 CELLPADDING=2> <INPUT TYPE=hidden NAME=\"MAX_FILE_SIZE\" VALUE=\"10000000\"> <TR><TD>Upload your files here (jpeg, doc, zip, etc) </TD><TD>: <INPUT NAME=\"Picture\" SIZE=50 TYPE=file><br></TD></TR> <input type=hidden name=\"_submit_check\" value=\"UPLOAD1\"/> <TR><TD><INPUT TYPE=submit VALUE=\"Upload File\"></TD></TR> </FORM> </TABLE> "; ?> <HTML> <TITLE>File Upload</TITLE> <BODY> <P> <?php if( $_SESSION['Error'] ) echo "<FONT COLOR=RED><B>" . $_SESSION['Error'] . "</B></FONT>"; $_SESSION['Error'] = NULL; echo $main_table; //To display the files uploaded. Will add "delete" function in future! echo "<BR CLEAR=LEFT><BR>"; //this is to display the files that has been uploaded previously In future, will add a 'delete' link here if( !empty($_SESSION['Uploaded_Files']) ) { $i = 0; //to be removed later foreach( $_SESSION['Uploaded_Files'] as $Temp_Array ) { echo $Temp_Array . $i . " has been uploaded <FONT>[<A HREF=\"" . $_SERVER['PHP_SELF'] . "?Action=Delete&File=" . $Temp_Array . "\">delete</A>]</FONT><BR>" ; $i++; } } ?> </P> </BODY> </HTML>
  4. Hi guys, I'm trying to create a normal site to upload stuff, and delete the file (which is up to the user). The code below is just a snippet of the code. The problem that I encounter, is that, if I click the "delete" hyperlink more than once, the "array_search" goes crazy, and returns a value which is more than the array size. Thanks! <?php error_reporting(E_ALL); //remove later session_start(); //include 'Protected/Functions.php'; //This is where all of the functions are stored! //include 'Protected/Database.php'; //This is where the database connections and variables are stored $UPLOAD_TEMP = "Upload_Temp"; $UPLOAD_PERMANENT = "Files"; /* if( !empty( $_REQUEST($FILE_UPLOAD_DISPLAY_HTML) ) ) $FILE_UPLOAD_DISPLAY_HTML = $_REQUEST($FILE_UPLOAD_DISPLAY_HTML); else $FILE_UPLOAD_DISPLAY_HTML = array(); */ if( isset( $_SESSION['Uploaded_Files'] ) || !session_is_registered('Uploaded_Files') ) { $Uploaded_Files = array(); session_register("Uploaded_Files"); } if( isset( $_SESSION['Uploaded_Files_Number'] ) || !session_is_registered('Uploaded_Files_Number') ) { $Uploaded_Files = 0; session_register("Uploaded_Files_Number"); } if( isset( $_SESSION['Error'] ) || !session_is_registered('Error') ) { $Error = 0; session_register("Error"); } /* if( !$_SESSION['Auth'] || !$_SESSION['User'] ) { echo "This is a private site. Please login to proceed...<BR>"; //header("Location: http://$_SERVER[sERVER_ADDR]/$LOGIN_PAGE"); session_destroy(); echo "<meta http-equiv=\"refresh\" content=\"3;URL=http://" . $_SERVER['SERVER_ADDR'] . "/" . $LOGIN_PAGE . "\">"; exit; } */ // Upload files ******************************************************************************************************** //This function does the actual work of saving the file into the $Target_Path function Save_Uploaded_File( $UPLOAD_TEMP ) { $File_Upload_Error = array( "There is no error, the file uploaded with success", "The uploaded file exceeds the upload_max_filesize directive in php.ini", "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form", "The uploaded file was only partially uploaded", "No file was uploaded", "Missing a temporary folder" ); $Target_Path = $_SERVER['DOCUMENT_ROOT'] . "/" . $UPLOAD_TEMP . "/"; $Target_Path = $Target_Path . basename( $_FILES['Picture']['name']); if( move_uploaded_file($_FILES['Picture']['tmp_name'], $Target_Path) ) { //echo "<BR>The file ". basename( $_FILES['Picture']['name']). " has been uploaded"; //to be removed $_SESSION['Uploaded_Files'][$_SESSION['Uploaded_Files_Number']] = basename( $_FILES['Picture']['name'] ); } else { $_SESSION['Error'] .= "There was an error uploading the file!" . $File_Upload_Error[$_FILES['Picture']['error']] . ". Please try again<BR>"; } $_SESSION['Uploaded_Files_Number']++; } //Checks whether the 'file submit' button is selected if( empty($_SESSION['Error']) && isset($_REQUEST['_submit_check']) ) { if( empty($_FILES['Picture']['name'] ) ) $_SESSION['Error'] = "No file was selected to be uploaded"; //check if file has already been uploaded into the drive, and if so, will write to the $_SESSION['Error'] if( !empty($_FILES['Picture']['name']) && !empty($_SESSION['Uploaded_Files']) && empty($_SESSION['Error']) ) { foreach( $_SESSION['Uploaded_Files'] as $Temp_Array ) { if( $Temp_Array == basename( $_FILES['Picture']['name'] ) ) { $_SESSION['Error'] .= "This file, <i>" . $Temp_Array . "</i>, has already been uploaded, and can't be uploaded again. <BR>"; break; } } } //Does the actual action of uploading the file. Calls the function "$Save_Uploaded_File" if( empty($_SESSION['Error']) ) // && ($_FILES['Picture']['name'] == $_SESSION['Uploaded_Files'][$_SESSION['Uploaded_Files_Number']]) ) { Save_Uploaded_File( $UPLOAD_TEMP ); } } //This deletes the file in the upload temp folder, if the user chooses so. else if( empty($_SESSION['Error']) && isset( $_REQUEST['Action']) ) { if( empty($_REQUEST['File'] ) || $_REQUEST['Action'] != "Delete" ) $_SESSION['Error'] = "No file selected to be deleted"; else if( !file_exists( $UPLOAD_TEMP . "/" . $_REQUEST['File'] ) ) { echo array_search( $_REQUEST['File'], $_SESSION['Uploaded_Files'] ); $_SESSION['Error'] = "File not found."; array_splice( $_SESSION['Uploaded_Files'], array_search( $_REQUEST['File'], $_SESSION['Uploaded_Files'] ), 1 ); } else { echo "<BR>" . count( $_SESSION['Uploaded_Files']) . " - " . $_REQUEST['File'] . "<BR>"; reset( $_SESSION['Uploaded_Files']) ; echo "<BR>Array Before array_search and array_slice<BR><BR>"; $i = 0; //to be removed later foreach( $_SESSION['Uploaded_Files'] as $Temp_Array ) { echo $Temp_Array . $i . " has been uploaded <FONT>[<A HREF=\"" . $_SERVER['PHP_SELF'] . "?Action=Delete&File=" . $Temp_Array . "\">delete</A>]</FONT><BR>" ; $i++; } echo "Array Search found <B>" . $_REQUEST['File'] . "</B> at location <B>" . array_search( $_REQUEST['File'], $_SESSION['Uploaded_Files'] ) . "</B>"; array_splice( $_SESSION['Uploaded_Files'], array_search( $_REQUEST['File'], $_SESSION['Uploaded_Files'] ), 1 ); //echo array_search( $_REQUEST['File'], $_SESSION['Uploaded_Files'] ); //array_splice( $_SESSION['Uploaded_Files'], array_search( $_REQUEST['File'], $_SESSION['Uploaded_Files'] ), 1 ); unlink( $UPLOAD_TEMP . "/" . $_REQUEST['File'] ); } } $main_table = " <FORM ENCTYPE=\"multipart/form-data\" ACTION=\"" . $_SERVER['PHP_SELF'] . "\" METHOD=POST > <TABLE ALIGN=LEFT BORDER=0 CELLPADDING=2> <INPUT TYPE=hidden NAME=\"MAX_FILE_SIZE\" VALUE=\"10000000\"> <TR><TD>Upload your files here (jpeg, doc, zip, etc) </TD><TD>: <INPUT NAME=\"Picture\" SIZE=50 TYPE=file><br></TD></TR> <input type=hidden name=\"_submit_check\" value=\"UPLOAD1\"/> <TR><TD><INPUT TYPE=submit VALUE=\"Upload File\"></TD></TR> </FORM> </TABLE> "; ?> <HTML> <TITLE>File Upload</TITLE> <BODY> <P> <?php if( $_SESSION['Error'] ) echo "<FONT COLOR=RED><B>" . $_SESSION['Error'] . "</B></FONT>"; $_SESSION['Error'] = NULL; echo $main_table; //To display the files uploaded. Will add "delete" function in future! echo "<BR CLEAR=LEFT><BR>"; //this is to display the files that has been uploaded previously In future, will add a 'delete' link here if( !empty($_SESSION['Uploaded_Files']) ) { $i = 0; //to be removed later foreach( $_SESSION['Uploaded_Files'] as $Temp_Array ) { echo $Temp_Array . $i . " has been uploaded <FONT>[<A HREF=\"" . $_SERVER['PHP_SELF'] . "?Action=Delete&File=" . $Temp_Array . "\">delete</A>]</FONT><BR>" ; $i++; } } ?> </P> </BODY> </HTML>
  5. I see 2 says of doing this 1) Modify MYSQL table taken from this site http://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html. If you want a column always to be treated in case-sensitive fashion, declare it with a case sensitive or binary collation. See Section 13.1.5, “CREATE TABLE Syntax”. 2) Extract data from database, then use PHP to compare
  6. Hi, I am trying to get some data from a MS SQL database. The problem is that there are duplicate 'productid' exist. I would like to get the first 'id' from the 'productid' that occurs (based on first occurance). For example, 'productid=22255805' occurs 2 times, with the 'id's 171866567 & 171868977. But, based on the time, i would only like to select 'id=171866567' cause it occurs first. Thanks! Here is a sample of the data. id productid startedtime 171866567 22255805 2/15/2007 18:57:52 171868977 22255805 2/15/2007 19:23:38 171865835 22255809 2/15/2007 18:41:04 171866604 22255809 2/15/2007 19:04:15 171867946 22255809 2/15/2007 19:17:46 171867078 22255811 2/15/2007 19:11:34 171867659 22255844 2/15/2007 19:15:45 171866565 22255845 2/15/2007 18:56:24 171868611 22255845 2/15/2007 19:21:43 171867380 22255846 2/15/2007 19:13:50 171866554 22261980 2/15/2007 18:54:12 171868291 22261980 2/15/2007 19:19:49 171866578 22261995 2/15/2007 19:01:07 171869743 22261995 2/15/2007 19:27:27 171869333 22261998 2/15/2007 19:25:32 171870202 22261999 2/15/2007 19:29:23
  7. Hi, I am having problems with checking this. It returns TRUE all the time. My code is below. Does anyone know how to NULL the $_FILES['filename']['name'] ? That means making it to NULL (empty). I tried "$_FILES['filename']['name'] = NULL" but no effect. [code] if( is_uploaded_file($_FILES['Picture']['tmp_name']) ) { $Target_Path = $_SERVER['DOCUMENT_ROOT'] . "/"; $Target_Path = $Target_Path . basename( $_FILES['Picture']['name']); if(move_uploaded_file($_FILES['Picture']['tmp_name'], $Target_Path)) { echo "The file ".  basename( $_FILES['Picture']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } } [/code] Thanks
  8. hi guys, I am trying to create a double array. While inserting the values into the array, it doesn't increment properly. For example : $Array1[][] = 1; $Array1[][] = 2; //Output will be $Array1[0][0] = 1, [b]$Array1[1][0] = 2[/b] How do i configure it, so that it will increment the second array, so the output will be "[b]$Array1[0][1] = 2[/b]" ? Thanks!
  9. Hi all, I created this simple code to list everything in a folder. Your feedback is utmost appreciated! [code] function Get_Directory_Listing( $dir ) { if( is_dir( $dir ) ) { //This is added so that it can enter & list the sub-directories nicely if( (substr( $dir, -1) !== "/") || (substr( $dir, -1) !== "\\") ) $dir .= "\\"; //This is the main function, whereby it enters the folders and list their contents if( $dir_open = opendir( $dir ) ) { while( ( $file = readdir( $dir_open ) ) !== false ) { if( $file == "." || $file == ".." ) continue; if( filetype( $dir . $file ) == "dir") { echo "<BR><BR><b>Directory found : $dir$file </b>"; //if( substr( Get_Directory_Listing( $dir . $file  ); } echo "<BR>Filename : $file,  filetype : " . filetype( $dir . $file ); } } closedir( $dir_open ); } else { //This is incase the user forgets to put the semicolon after the drive letter $dir .= ":"; echo "<BR>Drive to be listed : $dir"; Get_Directory_Listing( $dir ); } } [/code]
  10. Hi guys, I am trying to create a simple script to display some messages, wait, then forwarding it to another page. The problem I have is that it won't display anything if I use the function "sleep". This means, it will straightway goto the redirected page w/o displaying any message... It will display the message if I use "ob_flush" & "flush", but when trying to redirect it, the error "...headers already sent by..." comes out. Below is a snipper of the code : [code]function Transfer_Back( $Sleep_Time ) {         echo "Hello"; ob_flush(); flush(); Sleep( $Sleep_Time ); Header("Location:http://localhost"); } [/code]
  11. if flush() doesn't work, try ob_flush(); flush();
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.