Jump to content

postbil.com

Members
  • Posts

    32
  • Joined

  • Last visited

    Never

Posts posted by postbil.com

  1. Hello Phpfreaks..

    I had a little problem by insetting a timestamp in to a MySQL table. I have two timestamps $ts1 & $ts2 but all the time I get this error:

     

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL

    server version for the right syntax to use near 'header ="test", startTs ="1309680000", ' at line 2

     

    Here is the code where I try to insert the timestamp.

     

    $query = 'insert user_calendar

                        header ="' . mysql_real_escape_string($header, $db) . '",

                        startTs ="' . mysql_real_escape_string($ts1, $db) . '",

                        endTs ="' . mysql_real_escape_string($ts2, $db) . '",

                        subject ="' . mysql_real_escape_string($subject, $db) . '",

                   

                        userCalendarID = "' . mysql_real_escape_string($site_user['userID'], $db) . '"';

                    mysql_query($query, $db) or die(mysql_error($db));

     

    Here is the code where I create the table to database:

     

    $query = 'CREATE TABLE IF NOT EXISTS user_calendar (

                userCalendarID          INTEGER UNSIGNED    NOT NULL AUTO_INCREMENT,

                header                VARCHAR(50)          NOT NULL,

                startTs                DATETIME                NOT NULL,

                endTs                  DATETIME                NOT NULL,

                subject                VARCHAR(255)        NOT NULL,

               

                PRIMARY KEY(userCalendarID)

            )

            ENGINE=MyISAM';

           

        mysql_query($query, $db) or die (mysql_error($db));

     

    Can someone please tell me what I do wrong!!

    Postbil.com

  2. Hey Phpfreaks.

     

    I had a littel problem with my calendar script. I want i that way, then I click at the current day it reload the script (But only the calendar function) and remember which day there is selected.

    The problem is then I reload the script it just display ”0”.

    Can somebody please help me..

    Postbil.com

    <?php
    
        function calendar (){
    
    // selecct the current timezone                                                                                                                                      
    
            date_default_timezone_set('Europe/Paris');  
    
    // accept incoming URL parameter
    
            $timestamp = (isset($_GET['t'])) ? $_GET['t'] : time();
    
            $tsDM = (isset($_GET['tsDM'])); // Here I get the infomation about witch day the user had selected
    
    
    
    // determine useful aspects of the requested month
    
            list($month, $day, $year) = explode('/', date('m/d/Y', $timestamp));
    
            $first_day_of_month = date('w', mktime(0, 0, 0, $month, 7, $year));
    
            $total_days = date('t', $timestamp);
    
    
    
    // output table header
    
            echo '<h8>';
    
            echo '<table id="calendar">';
    
                echo '<tr id="calendar_header"><th colspan="7">';
    
                    echo '<a href="' . htmlspecialchars($_SERVER['PHP_SELF']) . '?t=' .
    
                        strtotime('-1 month', $timestamp) . '"><</a>  ';
    
                    echo date('F', $timestamp) . ' ' . $year;
    
                    echo '  <a href="' . htmlspecialchars($_SERVER['PHP_SELF']) . '?t=' .
    
                        strtotime('+1 month', $timestamp) . '">></a>';
    
                echo '</th></tr>';
    
                echo '<tr><th>Man</th><th>Tir</th><th>Ons</th><th>Tor</th><th>Fre</th>' .
    
                    '<th>Lør</th><th>Søn</th></tr>';
    
    
    
    // output date cells
    
    // here the loop started, to show the current day.
    
                $current = 1;
    
                while ($current <= $total_days){
    
                    echo '<tr class="calendar_dates">';
    
                    for ($i = 0; $i < 7; $i++){
    
                        if (($current == 1 && $i < $first_day_of_month) ||
    
                            ($current > $total_days)){
    
                                echo '<td class="empty">&nbsp</td>';
    
                                continue;                  
    
                        }
    
    // find the correct timestamp at day.
    
                        $tsDMY = urlencode(mktime(0, 0, 0, $month, $current, $year)); // Here we save a timestamp with infomation about Month, Day, Year
    
                        $tsDM = urlencode(mktime(0, 0, 0, $month, $current, 0)); // Here we save a timestamp with infomation about Month, Day
    
    // Print the actual date
    
                        echo "<td>";
    
    // here I make a link.
    
    // I use the "' . htmlspecialchars($_SERVER['PHP_SELF']) . '?tsDM=$tsDM" function before i want my page page only to reload the calender function, and remember witch day the user had selected.
    The $tsDM have to be sendt 
                            echo '<centerI><a href="' . htmlspecialchars($_SERVER['PHP_SELF']) . '?tsDM=$tsDM">' . $current . $tsDM . '</a></center>';
    
                        echo "</td>";
    
                        $current++;
    
                    }
    
                    echo '</tr>';
    
                }
    
             echo '</table>';
    
             echo '</h8>';
    
             echo $tsDM; // Here I print the selected timestamp. 
    
    }

  3. Hello Phpfreaks.

    I had created a calender, but I tryed to send a timestamp, in a link and print the timestamp under the calendar. But it dosent work..

    can somebody please help me !!

     

    <?php

     

        function calendar (){

     

    // selecct the current timezone

     

            date_default_timezone_set('Europe/Paris'); 

     

    // accept incoming URL parameter

     

            $timestamp = (isset($_GET['t'])) ? $_GET['t'] : time();

     

            $tsDM = (isset($_GET['tsDM']));

     

            echo $tsDM;  //test

     

    // determine useful aspects of the requested month

     

            list($month, $day, $year) = explode('/', date('m/d/Y', $timestamp));

     

            $first_day_of_month = date('w', mktime(0, 0, 0, $month, 7, $year));

     

            $total_days = date('t', $timestamp);

     

     

     

    // output table header

     

            echo '<h8>';

     

            echo '<table id="calendar">';

     

                echo '<tr id="calendar_header"><th colspan="7">';

     

                    echo '<a href="' . htmlspecialchars($_SERVER['PHP_SELF']) . '?t=' .

     

                        strtotime('-1 month', $timestamp) . '"><</a>  ';

     

                    echo date('F', $timestamp) . ' ' . $year;

     

                    echo '  <a href="' . htmlspecialchars($_SERVER['PHP_SELF']) . '?t=' .

     

                        strtotime('+1 month', $timestamp) . '">></a>';

     

                echo '</th></tr>';

     

                echo '<tr><th>Man</th><th>Tir</th><th>Ons</th><th>Tor</th><th>Fre</th>' .

     

                    '<th>L�r</th><th>S�n</th></tr>';

     

     

     

    // output date cells

     

                $current = 1;

     

                while ($current <= $total_days){

     

                    echo '<tr class="calendar_dates">';

     

                    for ($i = 0; $i < 7; $i++){

     

                        if (($current == 1 && $i < $first_day_of_month) ||

     

                            ($current > $total_days)){

     

                                echo '<td class="empty">&nbsp</td>';

     

                                continue;                 

     

                        }

     

    // find the correct timestamp at day.

     

                        $tsDMY = urlencode(mktime(0, 0, 0, $month, $current, $year));

     

                        $tsDM = urlencode(mktime(0, 0, 0, $month, $current, 0));

     

    // Print the actual date

     

                        echo "<td>";

     

                            echo '<center><a href="' . htmlspecialchars($_SERVER['PHP_SELF']) . '?tsDM=$tsDM">' . $current . '</a></center>';

     

                        echo "</td>";

     

                        $current++;

     

                    }

     

                    echo '</tr>';

     

                }

     

            echo '</table>';

     

            echo '</h8>';

     

            echo $tsDM;

  4. Hello Phofreaks.

    I had a little problem With the include() function.

    1.Example – works fine

      $validate = 'C:\xampp\htdocs\includes\userData.inc.php';

      include $validate;

     

    2.exampel – Get an error

    $validate = '../includes/userData.inc.php';

      include $validate;

     

    I do not understand what the different is, but every time I get the following error.

    include(../includes/userData.inc.php) [function.include]: failed to open stream: No such file or directory

     

    - Postbil.com 

     

  5. I have a little problem with creating a timestamp and display it again with date ()

    Here is a small shript:

    <?php

    $day = 6;

    $month = 7;

    $year = 1985;

    $ts = mktime($month, $day, $year);

    echo date("d-m-Y",$ts);

    ?>

     

    In my world would result in 6-7-1985

    but instead I get 06-11-2010

     

    Why .. what am I doing wrong?

     

    POSTBIL.COM

  6. Hello Phofreaks

    Now I have a new problem. I had created a date validation function after the script has been validated by the day, I will create a timestamp. If I print the time stamp to the screen directly from the function it works fine, but if I print it from my html form, I get nothing. how can it be? And in my role, I have some error messages, but if I make a mistake, do not I get an error. Is there someone who can explain to me what is going wrong??

     

    Thank postbil.com

     

    Here is my function [function.php]

    <?php

        function validateDate($date, $tsDate, $errors){

     

            if(!preg_match('|^\d{2}-\d{2}-\d{4}$|', $date)){

                $errors[] = urlencode('error date. dd-mm-yyy');

            }else{

                list($day, $month, $year) = explode('-', $date);

                if(!checkdate($month, $day, $year)){

                    $errors[] = urlencode('error date. dd-mm-yyy');   

                }else{

                    $tsDate = mktime(0, 0, 0, $month, $day, $year);

                    echo $errors;

                    echo $tsDate;

                }

            }     

        }

    ?>

     

    And here is my html form [send.php]

     

    <?php

        include ('function.php');

     

    ?>

    <html>

        <head>

        </head>

        <body>

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

            <input type="text" name="date" >

            <input type="submit" name="submit" value="send">

    <?php

        if(isset($_POST['submit']) && $_POST['submit'] == 'send' ){

            global $tsDate;

            $date = isset($_POST['date']) ? trim($_POST['date']) : '';

            validateDate($date, $errors, $tsDate);

            echo $tsDate;     

            echo $errors;

        } 

    ?> 

     

  7. Hello phpfreaks ..

    I'm trying to learn php .. and now I've made a small function which looks in the folder, the folder I empty it should write "The folder is empty", and if the folder is not empty, it should write "folder is not empty". But no matter how many Filder are in the folder, get the same result "folder is not empty" ..

    I hope someone can help me and tell what I'm doing wrong.

    Here is my function:

    <?php

    function insertFile ($imageFunction){

    // First make sure the folder is empty

            $dh = opendir($imageFunction['dir']);

     

    // Create a array for all file names in the folder

            $files = array();

            $files[] = readdir($dh);     

           

    // If the count of filenames is more than 0       

            if(count($file) > 0) {

                echo 'The folder is not empty';

            }else{

                echo 'The folder is empty.';

            }

           

            echo count($file);

     

       

        closedir($dh);

       

    }

    ?>

    Postbil.com

     

  8. Hello everybody.

    I had a small problem with a search function on my site. The idea was to create a function there make it possible for the user to search for friends on the site. I had written the code but of some reason it doesn’t work, now I have spend a lot of time to find the error but I have no more ideas.. Somebody please help me, tell me what I do wrong..

    Here is my code:

     

    <?php

        include '../DB/db.connect.inc.php'; 

    ?>

    <html>

        <head>

            <title>WWW.POSTBIL.COM - Projekt arbejde.</title>

            <link rel="stylesheet" type="text/css" href="../style/style.css">

            <style type="text/css">

                th { background-color: #999;}

                .odd_row { background-color: #EEE;}

                .even_row { background-color: #FFF;}

            </style>

        </head>

        <body>

            <h2>Search for frinds</h2>

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

            <table>

                <tr>

                    <td><input type="text" name="search" id="search"></td>

                    <td><input type="submit" name="submit" id="submit" value="search"></td>

                </tr>

            </table>

     

            <table style="width="100%">

                <tr><th>Email</th><th>Fifstnavn</th><th>Lastnavn</th><th>Adresse</th><th>City</th><th>contry</th><th>Phone</th><th>Homepage</th><th>Work</th><th>Company</th><th>Work adress</th><th>Work city</th><th>Work phone</th><th>Direct work phone</th><th>Work homepage</th></tr>

    <?php

        if(isset($_POST['submit']) && $_POST['submit'] == 'search'){ 

            $search = (isset($_POST['search'])) ? trim($_POST['search']) : '';       

    // Here I had my Mysql statement

        $query = 'SELECT firstName, lastName, email, adress, city, contry, phone, homepage, work, workCompany, workAdress, workCity, workPhone, workDirectPhone, workHomepage

            FROM site_user

            WHERE firstName LIKE '%$search%'';

            $result = mysql_query($query, $conn) or die(mysql_error($conn));

                $odd = true;

                while ($row = mysql_fetch_array($result)){

                    echo ($odd == true) ? '<tr class="odd_row">' : '<tr class="even_row">';

                    $odd = !$odd;

                    echo '<td><a href="user.php?id=' . $row['user_id'] . '">' .

                        $row['email'] . '</a></td>';

                    echo '<td><a href="user.php?id=' . $row['user_id'] . '">' .

                        $row['firstName'] . '</a></td>';

                    echo '<td><a href="user.php?id=' . $row['user_id'] . '">' .

                        $row['lastName'] . '</a></td>';

                    echo '<td><a href="user.php?id=' . $row['user_id'] . '">' .

                        $row['adress'] . '</a></td>';

                    echo '<td><a href="user.php?id=' . $row['user_id'] . '">' .

                        $row['city'] . '</a></td>';

                    echo '<td><a href="user.php?id=' . $row['user_id'] . '">' .

                        $row['contry'] . '</a></td>';

                    echo '<td><a href="user.php?id=' . $row['user_id'] . '">' .

                        $row['phone'] . '</a></td>';

                    echo '<td><a href="user.php?id=' . $row['user_id'] . '">' .

                        $row['homepage'] . '</a></td>';

                    echo '<td><a href="user.php?id=' . $row['user_id'] . '">' .

                        $row['work'] . '</a></td>';

                    echo '<td><a href="user.php?id=' . $row['user_id'] . '">' .

                        $row['workCompany'] . '</a></td>';

                    echo '<td><a href="user.php?id=' . $row['user_id'] . '">' .

                        $row['workAdress'] . '</a></td>';

                    echo '<td><a href="user.php?id=' . $row['user_id'] . '">' .

                        $row['workCity'] . '</a></td>';

                    echo '<td><a href="user.php?id=' . $row['user_id'] . '">' .

                        $row['workPhone'] . '</a></td>';

                    echo '<td><a href="user.php?id=' . $row['user_id'] . '">' .

                        $row['workDirectPhone'] . '</a></td>';

                    echo '<td><a href="user.php?id=' . $row['user_id'] . '">' .

                        $row['workHomepage'] . '</a></td>';

                    echo '</tr>';

          }

     

          mysql_free_result($result);

          mysql_close($conn);

        }

    ?>           

            </table>

            </form>

        </body>

    </html>

     

    Postbil.com

     

     

  9.  

    Hi people

     

    I have a little problem with my SQL statement. I am working on a script that makes it posibel the user to search for their friends and add them as contacts. In my database I HAVE fields for first name, last name and e-mail. I have created a field, and the button in my html code, I want to allow users to search by first name, last name and e-mail from the same search box. How can I make it?

     

    Postbil.com

     

    <?php
    // Include the connection to the database
        include ('../DB/db.connect.inc.php');  
    
    // Create the variabels for the text field
        $find_contact = (isset($_POST['find_contact'])) ? trim($_POST['find_contact']) : '';  
    
    // if there are press "Søg" 
        if(isset($_POST['Søg'])) {
            $query = 'SELECT * 
                    FROM 
                         site_user 
                    WHERE
                        * 
                    LIKE
                        " .. " ';
                      
        $result = mysql_query($query, $conn) or die (mysql_error());
                 
        } 
    ?>
    <html>
        <head>
        
        </head>
        <body>
            <form method="post">
                <fieldset>
                    <legend>Søg efter kontaktpersoner</legend>
                        <center>
                            <table>
                                <tr>
                                    <td><input type="text" name="find_contact" id="find_contact"></td>
                                    <td><input type="submit" name="submit" value="Søg"></td>
                                </tr>
                            </table>
                        </center>
                    </fieldset>
    <?php
    // create loop with the result
        while ($row = mysql_fetch_assoc($result)) {
            extract($row);
                echo '<fieldset>';
                echo '<legend>';
                echo $firstName;
                echo ' ';
                echo $lastName;
                echo '</legend>';
                    echo '<table>';
                        echo '<tr>';
                            echo '<td>Fornavn</td>';
                            echo '<td>' . $firstName . '</td>';
                        echo '</tr>';
                        echo '<tr>';
                            echo '<td>Efternavn</td>';
                            echo '<td>' . $lastName . '</td>';
                        echo '</tr>';
                    echo '</table>';
                echo '</table>';
        }
    ?>
                    
            </form>
        </body>
    </html>    
                  

  10. Hello phpfreaks..

     

    I had some problems with a activation script.. But I do not see the problem.. the error come from the mysql_query(), so I will mean it is my sql code there is the problem but I dont see why...

     

    <?php

    // Make the connection to the database

        include ('../DB/db.connect.inc.php');

       

     

          $userid = $_GET['userid'];

          $active = $_GET['actcode'];

         

          $query = "INSERT INTO site_user

                    (active)

                VALUES

                    ($active)

     

            WHERE user_id =" . $userid;

     

                 

          mysql_query($query, $conn) or die ('Error: Der er opstået en database fejl, og det var derfor ikke muligt at gennemføre aktiveringen'); // this is the error I get

    ?>

     

    Someone please help me!!

     

    postbil.com

  11. Hello Phpfreaks

    I had made a site where the user can upload a profile picture then he create a profile to the site. But my problem is then I will give the user opportunity to edit the profile information and  insert another pictue. But I had a problem with delete the old profile picture..

    Can somebody tell me what I do wrong??   

      if(!empty($_FILES['pic'])) {

            $dirname = "User/" . $email . "/Profileimage/";

            $dirhandle = opendir($dirname);

                while($file = readdir($dirhandle)) {

                    if ($file !=  "." && $file != ".."){

                        if (is_file($dirname.$file)){

                            unlink($file, $dirname);

            }

        }

    }

            if( $_FILES["pic"]["type"] == "image/pjpeg" || $_FILES["pic"]["type"] == "image/jpeg" || $_FILES["pic"]["type"] == "image/gif" ) {

                $destination = "User/" . $email . "/Profileimage/" . $_FILES['pic']['name'];

     

                move_uploaded_file($_FILES['pic']['tmp_name'], $destination);

     

                }

        }

    ...

     

     

    Postbil

  12. Hello Phpfreaks.

    I have created a function in a PHP script the user is able to change password but I get always a coward when I try to run the script. I use the function PASSWORD () to encrypt the user password ..

    Here's the error I keep getting ..

      Fatal error: Call to undefined function password ()

     

    Here is my MYSQL code ...

        $ db = mysql_connect ( 'localhost', 'root','') or

            die (error. ');

        mysql_select_db ( 'postbil', $ db) or die (mysql_error ($ db));

     

                          $ query = 'UPDATE site_user SET

                password = " '. mysql_real_escape_string (PASSWORD ($ password), $ db).'"

               

              WHERE

                email = " '. mysql_real_escape_string ($ _SESSION [' loginname '], $ db).'" ';

            mysql_query ($ query, $ db) or die (mysql_error ());

            mysql_close ($ db);

     

    I very much hope there is someone who can help me .. What am I doing wrong?

    In advance thank you very much!

     

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