Jump to content
Larry Ullman's Book Forums

damilola

Members
  • Posts

    18
  • Joined

  • Last visited

Posts posted by damilola

  1. Thank you so much larry. Can u please and I say pls again, tell me why in chapter 14 (making universal sites) script 14.2 and upwards don't seem to be running as u said it would in the book. When I run the codes with my php 5.4.3 I get the result u said one would get if he ws running on php 5.2 or less. I already created a topic on dis (unicode) but did nt really get much understanding from what ppl said.

    Pls help me out have been stuck @ chpter 14 for the past one month now.

    Can wait to see ur reply sire.

    Thanks a lot.

  2. Pls after tring out the locale script in chapter 14. I encountered an error. Note am using wamp 2.2e which has php 5.4.3.

     

    This is the code:

     

    <?php header ('Content-Type: text/html; charset=UTF-8'); ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>Locales</title>

    </head>

    <body style="font-size: 18pt;">

    <?php # Script 14.5 - locales.php

     

    // Set the default timezone:

    date_default_timezone_set('UTC');

     

    // Need a date object:

    $d = new DateTime();

     

    // Create a list of locales:

    $locales = array('en_US', 'fr_FR', 'es_BO', 'zh_Hans_CN', 'ru_RU', 'el_GR', 'is_IS');

     

    // Print the date in each locale:

    foreach ($locales as $locale) {

     

    // Set the locale:

    locale_set_default($locale);

     

    // Print the date:

    echo "<p>$locale: " . strtotitle(date_format_locale($d, 'l, j F Y')) . "</p>\n";

     

    }

     

    ?>

    </body>

    </html>

     

    This is the error encountered:

     

    ( ! ) Fatal error: Call to undefined function locale_set_default() in C:\wamp\www\phpmyql3_scripts\ch14\locales.php on line 25 Call Stack

     

    # Time Memory Function Location 1 0.0021 142912 {main}( ) ..\locales.php:0

     

    Pls help. Thanks.

  3. Thank u §☺ much @hartlySan and StephenM, I really appreciate u all.

    Now going by the book and the authour, on page 423 we can have 2 result of d Script 14.2 based on the version of php u are running(which has been displayed above), which are the following:

     

    U get this when running php6:

     

    joάo has 4 characters

    JOάO in capital letters

     

    ҐѾργζ has 7 characters

    ҐѾργζ in capital letters

     

    Anton has 5 characters

    ANTON in capital letter

    s

    KamilÐ has 5 characters

    KAMILÐ in capital letters

     

    FranĞiška has 6 characters

    FRANĞIšKA in capital letters

     

    愛子 has 2 characters

    愛子 in capital letters

     

    杰西卡 has 3 characters

    杰西卡 in capital letters

     

    U get this when running under Php5.2:

     

    joάo has 5 characters

    JOάO in capital letters

     

    ҐѾργζ has 10 characters

    ҐѾργζ in capital letters

     

    Anton has 5 characters

    ANTON in capital letters

     

    KamilÐ has 7 characters

    KAMILÐ in capital letters

     

    FranĞiška has 11 characters

    FRANĞIšKA in capital letters

     

    愛子 has 6 characters

    愛子 in capital letters

     

    杰西卡 has 9 characters

    杰西卡 in capital letters

     

    Now d issue is that am using php 5.4.3, which according to what have seen and read from the net is that php 5.4 is the latest version of php, php 6 is not yet out there.

    §☺ since am using Php 5.4.3, y am I get a result for php 5.2 or below ?. Pls this is my main problem, am a beignner with php and I have found it hard to move forward, cos ave been stuck witb dis issue for alomst a month now.

    Don't mean to take up ur time, jst need help. Thank you so much people.

  4. This is the code, and someone said it runs fine.

    <?php

    header ('Content-Type: text/html; charset=UTF-8');

    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0

    Transitional//EN" " http://www.w3.org/

    TR...ransitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml"

    xml:lang="en" lang="en">

    <head>

    <meta http-equiv="Content-Type" content="text/

    html; charset=utf-8" />

    <title>Untitled Document</title>

    </head>

    <body>

    <?php

    $names = array('joάo','ҐѾργζ', 'Anton', 'KamilÐ',

    'FranĞiška','愛子', '杰西卡');

    foreach ($names as $name)

    {

    echo "<p>$name has ".strlen($name)." characters

    <br />\n".strtoupper($name)." in capital letters</p>

    \n";

    }

    ?>

    </body>

    </html>

     

     

    This is the result:

    joάo has 5 characters

    JOάO in capital letters

    ҐѾργζ has 10 characters

    ҐѾργζ in capital letters

    Anton has 5 characters

    ANTON in capital letters

    KamilÐ has 7 characters

    KAMILÐ in capital letters

    FranĞiška has 11 characters

    FRANĞIšKA in capital letters

    愛子 has 6 characters

    愛子 in capital letters

    杰西卡 has 9 characters

    杰西卡 in capital letters. (This can be crosschecked on page 444 of the book).

     

    According to the book, the result above will be gotten if am using php 5.2 or less. But am using php5.4.3, which I belive is php6, which according to the book has unicode support.

    Have already defaulted my dreamweaver to utf-8 encoding.

    So pls what could be worng. And one more thing when I call the phpinfo() I can't see section for unicode settings.Pls help out.

  5. This is d code :

     

    <?php

    header ('Content-Type: text/html; charset=UTF-8');

    ?>

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

     

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>Untitled Document</title>

    </head>

     

    <body>

     

    <?php

    $names = array('joάo','ҐѾργζ', 'Anton', 'KamilÐ', 'FranĞiška','愛子', '杰西卡');

     

    foreach ($names as $name)

    {

    echo "<p>$name has ".strlen($name)." characters <br />\n".strtoupper($name)." in capital letters</p>\n";

    }

    ?>

     

    </body>

    </html>

     

     

    The result when i run the code:

    joάo has 5 characters

    JOάO in capital letters

    ҐѾργζ has 10 characters

    ҐѾργζ in capital letters

    Anton has 5 characters

    ANTON in capital letters

    KamilÐ has 7 characters

    KAMILÐ in capital letters

    FranĞiška has 11 characters

    FRANĞIšKA in capital letters

    愛子 has 6 characters

    愛子 in capital letters

    杰西卡 has 9 characters

    杰西卡 in capital letters

     

    My phone browser cannot display the chinesse words.

    Thank u §☺ much.

  6. Yes I ws confusing it all sir. Thanks §☺ much.

    Now having dis new problem. †ђξ login.php is giving me a error, which it says is on line 46 in my function_login.inc.php. This is †ђξ error

     

     Parse error: syntax error, unexpected ';' in C:\wamp\www\PHPPRACTICENEW\includes\login_function.inc.php on line 46 Call Stack#TimeMemoryFunctionLocation10.0016371904{main}( )..\login.php:0

     

    This is †ђξ function_login.inc.php:

    <?php

    //this page defines 2 function used by login/logout process

     

    /*This function determines and returns an absolute URL.

    It takes one argument: the page that concludes the URL.

    The argument defaults to index.php

    */

     

    function absolute_url($page = 'index1.php')

    {

    //URL is http:// plus the host name of the current directory

     

    $url = 'http://'.$_SERVER['HTTP_HOST']. dirname($_SERVER['PHP_SELF']);

     

    //REMOVE any trailling slashes

    $url = rtrim($url, '/\\');

     

    //add the page:

    $url .= '/' .$page;

     

    //return the url

     

    return $url;

    }

     

    /*

    * This function validates the form data (the email address and password).

    * If both are present, the database is queried.

    * The function requires a databaseconnection.

    * The function returns an array of information, including:

    * - a TRUE/FALSE variable indicating success

    * - an array of either errors or the database result

    */

     

    function check_login($dbc, $email = '', $pass = '')

    {

    $errors = array();

     

    //validate the email and password

    if (empty($email))

    {

    $errors[] = 'You forgot to enter your email address.';

    }

     

    else

    {

    $ea = mysqli_real_escape_string($dbc, trim($email));

    }

     

    if (empty($pass))

    {

    $errors[] = 'You forgot to enter your password.';

    }

     

    else

    {

    $p = mysqli_real_escape_string($dbc, trim($pass));

    }

     

    if(empty($errors))

    {

    $q = "SELECT user_id, first_name FROM usera WHERE email = '$ea' AND pass = '$p'";

    $r = @mysqli_query($dbc, $q);

     

    if(mysqli_num_rows($r) == 1)

    {

    $row = mysqli_fetch_array($r, MYSQLI_ASS0C);

     

    return array(true, $row);

    }

    else

    {

    $errors[] = 'The email address and password entered do not match those on file.';

    }

    }

    return array(false, $errors);

    }

    ?>

    Pls help.

  7. After typing †ђξ login_page.inc.php code ãήϑ storing it in †ђξ includes folder alongside †ђξ header.html, footer.html etc. But am still getting errors.

     

    This is †ђξ code

     

    Login_page.inc.php

     

    <?php

    $page_title = 'Login';

    include ('includes/header.html');

     

    //print error messages

     

    if(!empty($errors))

    {

    echo '<h1>Error!</h1>

    <p class = "error">The following error(s) occured:<br />';

     

    foreach($errors as $msg )

    {

    echo " -$msg <br />\n";

    }

    echo '</p><p>Pls try again.</p>';

    }

    //display form

    ?>

    <h1>Login</h1>

    <form action="login.php" method= "post">

    <p>Email Address: <input type= "text" name="email" size="20" maxlength="80" /> </p>

    <p>Password: <input type="password" name="pass" size="20" maxlength="20" /></p>

    <p><input type="submit" name="submit" value="Login" /></p>

    <input type="hidden" name= "submitted" value="TRUE" />

    </form>

    <?php // Include the footer:

    include ('includes/footer.html');

    ?>

     

    Ãήϑ dis are †ђξ errors

     

    ( ! ) Warning: include(includes/header.html) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\PHPPRACTICENEW\includes\login_page.inc.php on line 3

    Call Stack

    #TimeMemoryFunctionLocation

    10.0034370072{main}( )..\login_page.inc.php:0

     

    ( ! ) Warning: include() [function.include]: Failed opening 'includes/header.html' for inclusion (include_path='.;C:\php\pear') in C:\wamp\www\PHPPRACTICENEW\includes\login_page.inc.php on line 3

    Call Stack

    #TimeMemoryFunctionLocation

    10.0034370072{main}( )..\login_page.inc.php:0

     

     

    ( ! ) Warning: include(includes/footer.html) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\PHPPRACTICENEW\includes\login_page.inc.php on line 87

    Call Stack

    #TimeMemoryFunctionLocation

    10.0034370072{main}( )..\login_page.inc.php:0

     

    ( ! ) Warning: include() [function.include]: Failed opening 'includes/footer.html' for inclusion (include_path='.;C:\php\pear') in C:\wamp\www\PHPPRACTICENEW\includes\login_page.inc.php on line 87

    Call Stack

    #TimeMemoryFunctionLocation

    10.0034370072{main}( )..\login_page.inc.php:0

×
×
  • Create New...