Jump to content

Jagand

Members
  • Posts

    39
  • Joined

  • Last visited

Posts posted by Jagand

  1. Hi,

     

    I see that when I am applying crypt function on the text 'samurai.ciscorouter1', output is same as it is for 'samurai.ciscorouter2'. Is the code I am giving how it must be?

    print "<hr/>" .crypt(crypt(crypt('samurai.ciscorouter1',CRYPT_SHA512), CRYPT_SHA512), 
    CRYPT_SHA512); 
    
    print "<hr/>" .crypt(crypt(crypt('samurai.ciscorouter2',CRYPT_SHA512), CRYPT_SHA512), 
    CRYPT_SHA512); 
  2. Thank you. That worked. So, the script that worked is below, for other's reference.

     

    INSERT
      INTO table        (
             primary_id
            ,sequence_number
            ,text

            ,text2

            ,text3
          )
    select
              30
             ,(SELECT ifnull ((MAX(sequence_number) + 1), 1)
          FROM table
         WHERE primary_id = 30)
             ,'text'

             ,'text2'

             ,'text3

  3. I am trying to write a MySQL INSERT statement which has a SELECT query. Select query can result in NULL. If result is NULL, I want to 1 to be the value for the field. If result is not NULL, I want retrieved value. Below is the MySQL I have coded but it seems wrong. What would be the right statement

     

    INSERT  
    INTO table        
    (         
    primary_id        
    ,sequence_number        
    ,text        
    ,text2        
    ,text3      
    )select          
    30         
    ,((SELECT 
    MAX(sequence_number) + 1 FROM table     
    WHERE primary_id = 30) 
    AS seq_num 
    IF (seq_num 
    = NULL,1,seq_num))         
    ,'text'         
    ,'text2'
    ,'text3
     

     

  4. I have a code that uses simpleXML library to generate an XML from input. I then want to insert the data into MySQL using PDO->exec(); But Insert of query doesn't happen. Can you please let me know how do I escape the query so that insert is successful.

     

    PDO::query(), PDO::prepare() haven't helped me much so looking for PHP solution to this problem. Below is the INSERT code generated

     

     

    INSERTINTO dbname.table(input_xml)VALUES ('<?xml 
    version="1.0" encoding="UTF-8" standalone="yes" 
    ?><ip_Input><ip_xml>17:01:27Qaiku.com – What Can We 
    Learn From Failure?By Guest Blogger, September 11, 2012, Leave a 
    CommentEditor's note: I think we in the tech press have the tendency to 
    focus on the positive stories and forget about the startups that didn't live up 
    their expectations. Our Sofanatics coverage this past week has been one of the 
    few times we've covered abandoned projects, which is a pitty because there are a 
    lot to learn from "failures." Below we have a long read from Eero Holmila which 
    is one part eulogy, and another part what he's learned from the now-announced 
    shutdown of Qaiku.com.Qaiku.com might be a familiar name for some of the 
    readers of Arctic Startup. However, I am quite sure that the background and the 
    rough road from high hopes to a bitter decline probably is not. I am the CEO of 
    Rohea, a company behind a handful of quite successful Finnish websites like 
    Kotikokki.net, Kuvake.net, Mikseri.net and of course a less successful 
    Qaiku.com.I am going to share some lessons learned through the trip. I hope 
    some of it might be of use, spark up ideas or if nothing else, be at least a bit 
    entertaining. One last important disclaimer: all the opinions are my own.Now 
    without further delay, this is the story of 
    Qaiku.</ip_xml></ip_Input>');
     

     

  5. I have some data in MySQL table. When user searches for certain keywords, I must search MySQL table for those keywords and provide results to users. When I am providing those results, I want to display few additional columns so that user can get an idea of how data looks like. My requirement is something common in today's webpages - for example in GMail where data is fetched from database and is parsed into multiple columns such as author, subject, date written etc. What is the most efficient way to code such requests. Below were what I could think but felt that they are not very efficient

    1. Fetch each row from MySQL table and construct a HTML/CSS based table with the results. This solution is lacky in sense that there will be multiple requests and responses going between MySQL and webpage
       
    2. Get each row from database and construct an XML. Pass all this to Javascript and write a javascript code to parse the XML before displaying it as HTML/CSS based table. This again seems lacky in sense that code is once creating XML (through MySQL + PHP) and then parsing it in Javascript

    Given these, I would like to know how would a good programmer address the problem of displaying data from MySQL into front end with minimal requests and yet without lot of constructing and parsing information.

     

    Thank you in advance for any suggestions you can offer

  6. To the extent I understood your point, if you intend that the code should perform certain action using PHP alone, you must use a form with input type='button' option. You can google/bing 'HTML FORM' for more details. Sample syntax for a form is

     

    <form action='a_page_that_performs_either_approve_action.php' method='POST'>

    <?php print $firstname $lastname<br>$address<br>$city $state<br>$phone<br>$email<br>$typeofneed<br> ?>

    <input type='submit' name='approve'>Approve</button>

    <input type='button' name='deny'>Deny</button>

    <br>---------------------------<br>

    </form>

  7. Is there a way I can know number of characters per line and number of lines that can fit into a page. My specific need is for page format 'Times New Roman' with A4 page format but I would like to know if there is a function in general that can help me with these details.

     

    My requirement is like this - write data into a document and when the number of characters written is large enough to fit a page, I must give a page break and write rest of characters to a new page and so on. I can write a custom function for this but the term "formatted printing" associated with function printf, sprintf tempted me to think that PHP might already have a function that does this task and that a new custom function would be unnecessary.

     

    One of the complexities with creating a custom function is that non Monospaced fonts such as 'Times New Roman' take different lengths for different characters

  8. Hi,

     

    I have a word document in a non-root folder and I wrote a code that allows users to download the file. Code is

     

    rename ("../cgifolder/docxfile.docx","docx/docxfile.docx");
    
    header("Content-disposition: attachment; filename=docxfile.docx");
    header('Content-type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
    readfile("docx/docxfile.docx");
    

     

    I have two questions ...

     

    1. I am seeing that downloaded content a corrupt file while file on server is MS2010 readable. What is wrong with my code?

    2. Can I place files in cgi without renaming it to move to root folder and still allow users to download the file

     

    Thank you

  9. I tried copying and pasting content at http://www.arcticsta...u-shutdown-stor with various options such as

    html_entity_decode, mysql_real_escape_string, htmlspecialchars, addslashes but nothing was working. I tried other option too ....

     

    <?php

    mb_language('uni');

    mb_internal_encoding('UTF-8');

     

    print html_entity_decode('input_content');

     

    ?>

     

    Also, given below options in form but did not work. Am I missing something?

     

    accept-charset

    ='utf-8' enctype="multipart/form-data"

  10. Hi,

     

    I am trying to insert data into MySQL. Input data is sometimes not very neat. For example "com – What". When I added addslashes, mysql_real_escape_string, I expected that these non standards characters be inserted as-is or with escape sequences. When I perform inserts, data in MySQL DB looks strange. For example, above example (com – What) transformed into "com – What". "didn’t stop" is not being escaped as "didn\nt stop". How do I make sure that data in MySQL database is proper and as expected?

  11. I have a webpage that has hundreds of links. Clicking on any of these links should drive a customer to same destination page but the content that is loaded on destination page should differ based on the link that customer has clicked. For example, on main page, if user clicks A, destination page should redirect user to destination.php and then load data related to A by fetching it from MySQL. So, with B where data loaded is specific to B and so with C.

     

    In order to do this, in the destination page, PHP should know if user clicked on A, B, C ... How can I code the program to detect which link the customer clicked? In Javascript, I can do this using onClick but in PHP, I am sure there must be a solution though such a solution might involve couple of data exchanges between server and client. Please help.

×
×
  • 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.