#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Sweden
    Posts
    32
    Rep Power
    14
    There's a few basic questions I need answered, I hope anyone can help.

    First, is there a difference when you're using a MySQL database if you use one or more tables?

    I would guess it's faster but if it is, can someone tell me how to get info from two tables. I need this for forms and a search thing since it will be looking for ids.

    When sending login info (usernames/passwords) through forms on MySQL databases, how secure is it and should HTTP Header auth. be used or are there other options?

    If you have 3 select options (aka pull-down menus) and first contain months, second days and last years. When the user select his options, is it then possible for all these 3 selection to be put in one colum in a table in the database or can it be converted to MySQL date year-day-month?

    I doubt this is possible but can you detect if a visitor has a printer installed and is there a way to automatically print a page through PHP or must the visitor do this manually?

    If you have a form with textarea code, how do you make it so it will automatically add the line break code for each line but if they enter multiple line breaks, it will only break it to one or two lines.

    One last question, it may not be possible but if you have a form with a textbox, can you then only allow the first charater they type to be captial but the rest must be lower case?

    I hope someone can answer any of these questions, haven't really found any info about it.

    Thanks for your time
    Toby
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    <<
    First, is there a difference when you're using a MySQL database if you use one or more tables?
    >>

    No ,it won't make any difference..


    <<
    I would guess it's faster but if it is, can someone tell me how to get info from two tables. I need this for forms and a search thing since it will be looking for ids.
    >>


    you can issue a sql command like this.
    "SELECT t1.field1,t1.field2,t2.field1,t2.field2 FROM tablename1 as t1,tablename2 as t2 WHERE someconditions".

    -----------


    <<
    When sending login info (usernames/passwords) through forms on MySQL databases, how secure is it and should HTTP Header auth. be used or are there other options?
    >>


    See,If we are handling some confidential datas then only we need to worry about the security problems.
    probably you can post a question on "security" disussion forum here in devshed for getting more idea about the security issues.


    <<
    When the user select his options, is it then possible for all these 3 selection to be put in one colum in a table in the database or can it be converted to MySQL date year-day-month?
    >>

    yea,You can put it in one column.

    $date_value=$year."-".$day.":".$month;

    //concatenate all three values(ie,year,day and month).

    Then simply insert this on mysql table.See mysql manual for the details about mysql DATE column type..


    <<
    I doubt this is possible but can you detect if a visitor has a printer installed and is there a way to automatically print a page through PHP or must the visitor do this manually?
    >>


    Since it is a client side issue.I think you have to find a solution in JavaScript or some client side scriptings.


    <<
    If you have a form with textarea code, how do you make it so it will automatically add the line break code for each line but if they enter multiple line breaks, it will only break it to one or two lines.
    >>

    you can do that.Probably you may use ereg_replace() function for this..Check it out the manual.(This question i have seen many times here.so give a search here for this topic.)


    <<
    One last question, it may not be possible but if you have a form with a textbox, can you then only allow the first charater they type to be captial but the rest must be lower case?
    >>


    yea ,it is possible...

    Try the ucfirst()function..

    eg:
    <?
    $text_value = "JESUS IS LoVE!!";
    $text_value = ucfirst($text_value);

    // Now $text_value is "Jesus is love!!".
    ?>



    Good Luck!!




    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."


    [This message has been edited by Shiju Rajan (edited August 07, 2000).]
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Sweden
    Posts
    32
    Rep Power
    14
    I tried that ucfirst function but it only works to replace it in the textbox, if a user for example submit "this is my name", it won't change it to: "This is my name".

    This is what I use:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    if ($submit) {

    $sql = "UPDATE coder SET firstname='$firstname', lastname='$lastname', email='$email', country='$country', history='$history', quote='$quote', bday='$bday', nickname='$nickname', date=curdate() where user_id='$id'";
    $result = mysql_query($sql);

    echo "html header text";
    } else{

    $result2=mysql_query("SELECT * FROM coder where user_id='$id'",$con);
    $row = mysql_fetch_array($result2);
    {
    $title = $row[title];
    $coder_id = $row[coder_id];
    $user_id = $row[user_id];
    $email = $row[email];
    $age = $row[age];
    $bday = $row[bday];
    $country = $row[country];
    $nickname = $row[nickname];
    $quote = $row[quote];
    $history = $row[history];
    $firstname = $row[firstname];
    $lastname = $row[lastname];
    $text_value = "$firstname";
    $text_value = ucfirst($text_value);
    }

    echo "html footer text";
    }
    [/code]

    Regular expression maybe should be used instead of the ucfirst function for this, I haven't tested that yet.

    One more thing, about the date. I don't really understand how you mean i'm going to use this. To get the current date of submittion I use:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    $result=mysql_query("SELECT *, date_format(date,'%W %M %D, %Y') as date FROM coder where user_id='$id'",$con);
    [/code]

    Should it be something simular to this?

    Thanks for your time,
    Toby
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    London/UK
    Posts
    91
    Rep Power
    14
    >>>>>>>>>
    If you have a form with textarea code, how do you make it so it will automatically add the line break code for each line but if they enter multiple line breaks, it will only break it to one or two lines.

    do a ereg_replace() search for n if there are more than 3 in a row, the change this for nn

    >>>>>>>>>>>
    First, is there a difference when you're using a MySQL database if you use one or more tables?

    Yes, it's *much* more efficient to use relations between your tables, check out the recent article on phpbuilder.com for more reasons why you should do this

    RE: getting the data out, you'll need to read up on joins

    a quick example

    SELECT a.name AS author ,b.title AS booktitle FROM author a LEFT OUTER JOIN book b ON a.authorID = b.authorID

    I can't understand why Shiju's recommendation to use ucfirst() didn't work, that's exactly what that function is for??
    Are you using GET maybe for your form and the the url encoding is screwing up?

    regs

    bealers


    ------------------
    http://back-end.org
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Sweden
    Posts
    32
    Rep Power
    14
    When i'm using the ucfirst function then i'm using POST, not GET. I have no problems with the URLs either, should I set this somewhere in the if ($submit) { ... code? I haven't tried that but didn't think it would work that way either.

    I'll try the ereg_replace function and see how it works, but I only want it to break 2 lines. If the user try to break it more than that then it will still only break to 2 lines, how do I do that?
    Can it be done with ereg_replace function?

    Toby

Similar Threads

  1. Check MySQL Version thru PHP
    By wolftrap1 in forum PHP Development
    Replies: 2
    Last Post: February 11th, 2004, 08:51 PM
  2. Replies: 0
    Last Post: February 10th, 2004, 11:44 PM
  3. Replies: 0
    Last Post: January 30th, 2004, 01:22 PM
  4. PHP 5 (MYSQL vs. SQLite)
    By ignition in forum PHP Development
    Replies: 1
    Last Post: January 23rd, 2004, 12:13 PM
  5. PHP Reconfig with mysql...
    By Legendary Fox in forum PHP Development
    Replies: 3
    Last Post: January 22nd, 2004, 11:46 PM

IMN logo majestic logo threadwatch logo seochat tools logo