Jump to content

Prismatic

Members
  • Posts

    503
  • Joined

  • Last visited

Posts posted by Prismatic

  1. Here try this, I cleaned up your code.

     

    Make sure you close any function parentheses

    function("blahblah";
    
    vs
    
    function("blahblah");
    

     

    Also make sure you properly end your lines

    $var = $somevar
    
    vs
    
    $var = $somevar;
    

     

    and close any open brackets.

     

    Try running this

     

    <?php
    /* Program: postit.php
    * Desc: puts entered data in database
    */
    
    Session_start();
    
    if (@$_session['auth'] != "yes")
    {
        header("Location: login.php");
        exit();
    }
    
    include("caneck.inc");
    switch ($_POST['do'])
    {
        case "post":
        
    
        /*check title, description, and location for blanks*/
    
        if ($_POST['title'] == "")
        {
            $blanks[] = "title";
        }
        if ($_POST['description'] == "")
        {
            $blanks[] = "description";
        }
        if ($_POST['location'] == "")
        {
            $blanks[] = "location";
        }
        
        if(isset($blanks))
        {
            $message = "Please fill out:  ";
            foreach($blanks as $value)
            {
                $message .= $value .", ";
            }
            
            extract($_POST);
            include("postform.inc");
            exit();
          
    
            /*clean data and set new variables to insert into table*/
            $cnx = mysqli_connect($host,$user,$passwd,$dbname);
    
            $title = strip_tags(trim($_POST['title']));
    
            $description = strip_tags(trim($_POST['description']));
    
            $location = strip_tags(trim($_POST['location']));
    
            /*check whether title already exists*/
            $sql = "SELECT title FROM Post WHERE title = '$title'";
            $result = mysqli_query($cnx,$sql) or die("Couldn't execute select query.");
           
            $num = mysqli_num_rows($result);
            if ($num > 0)
            {
                $message_new = "The title, $title, is already in use. Please choose another title.";
                include("postform.inc");
                exit();
            }
    
            /*add new event to database*/
    
            else
            {
                if($_POST['sampm'] == "pm")
                {
                    $_POST['shour'] = $_POST['shour'] + 12;
                }
    
                $startDT = $_POST['syear']."-".$_POST['smonth']."-".$_POST['sday']."- ".$_POST['shour'].":".$_POST['sminute'].":00";
    
                $endDT = $_POST['eyear']."-".$_POST['emonth']."-".$_POST['eday']."- ".$_POST['ehour'].":".$_POST['eminute'].":00";
    
                $today= date("Y-m-d h:i:s");
             
                $_SESSION['logname'] = $logname;
           
                $_POST['eventType'] = $eventType;
    
                $sql = "INSERT INTO Post (loginName, createDate, title, description, Location, eventType, startDT, endDT)
                VALUES ('$logname', '$today', '$title', '$description', '$location', '$eventType', '$startDT', '$endDT')";
    
                $result = mysqli_query($cnx,$sql) or die("Can't execute insert query.");
                
                header("Location: login.php");
            }
        }
    }
    
    ?>
    [/code

  2. $this-> is used to access methods and properties of current object.

     

    http://www.php.net/manual/en/language.oop5.basic.php

     

    But why in the line $result = mysql_query($q, $this->connection); also $q isn't wrote in the same way as connection. Isn't also q a method?

     

    $q is the query

     

    <?php
    class MySQLDB
    {
    function usernameTaken($username){
          if(!get_magic_quotes_gpc()){
             $username = addslashes($username);
          }
          $q = "SELECT username FROM ".TBL_USERS." WHERE username = '$username'"; // <--- $q
          $result = mysql_query($q, $this->connection);
          return (mysql_numrows($result) > 0);
    ?>
    

     

    $this->connection refers to a connection variable inside the current class

     

     

    edit - sorry meant variable not method

  3. <?php
      $query = mysql_query("SELECT * FROM favorites WHERE user_name = 'username'");
      while($row = mysql_fetch_row($query))
      {
          $songInfo = mysql_query("SELECT * FROM songs WHERE song_id = '{$row['song_id']}'");
          $songInfo = mysql_fetch_row($songInfo);
          
          echo $songInfo["song_title"] ." / ". $songInfo["artist"] ." / ". $songInfo["year"] ."\n";
      }
      
    ?>
    

  4. Please give me the code to convert USD to INR for may project

     

     

    Regards

    Vinod

     

    Currency exchange rates change constantly, there's no one formula you can run. What you need to do is find a site that lists the current currency exchange rates and parse out the current going rate of INR in dollars.

  5. in your e-mailsbody you would simply have something like this...

     

    <a href="http://www.yourdomain.com/optout.php?emailid=1">CLICK HERE TO OPT-OUT</a>

     

    optout.php would have a script that would search your database for emailid when it quals 1 if your database is set up like that....not the best example but hope it helps...

     

     

    This means that instead of sending the message (in my case newsletter), we will send a link to the message which resides in our server.

    And the email receiver (in my case newsletter subscriber) will have to click that link to see the message. Am I right?

     

    No. You append to the end of your newsletter the code for the link.

  6. Have somebody an idea about Opt-out link while sending email?

    How can I send email which includes Opt-out link through php mail function?

     

    You simply include it as part of the mail body. The link would point to a file on your server that removes their email from the mailing list.

  7. 
    <?php
    
    function topic($input)
    {
        $pattern[0] = "";
        $pattern[1] = "/\&/i";
        $pattern[2] = "/\</i";
        $pattern[3] = "/\>/i";
        $pattern[4] = "/\[b\](.*?)\[\/b\]/i";
        $pattern[5] = "/\[u\](.*?)\[\/u\]/i";
        $pattern[6] = "/\[i\](.*?)\[\/i\]/i";
        $pattern[7] = "/\[code\](.*?)\[\/code\]/i";
        $pattern[8] = "/\[url\](.*?)\[\/url\]/i";
        $pattern[9] = "/\[img\](.*?)\[\/img\]/i";
        $pattern[10] = "/\[url\=(.*)\](.*)\[\/url\]/i";
        
        $replace[0] = "<img src='/images/smiley1.gif'/>";
        $replace[1] = "&";
        $replace[2] = "<";
        $replace[3] = ">";
        $replace[4] = "<b>$1</b>";
        $replace[5] = "<u>$1</u>";
        $replace[6] = "<i>$1</i>";
        $replace[7] = "Code:<br><div id=\"code\"><tt>$1</tt></div>\n";
        $replace[8] = "<a href=$1>$1</a>";
        $replace[9] = "<img src = $1 />";
        $replace[10] = "<a href=$1>$2</a>";
        
        $bbcoded = preg_replace($pattern, $replace, $input);
        //return nl2br($bbcoded && $some2);
    
        return nl2br(strip_tags(stripslashes(htmlspecialchars($bbcoded))));
    
    }
    
    ?>
    

  8. My idea is to use some tools to extract a frame from the stream it's self. Then compare that frame with the default non-streaming image.

     

    If the frame is different the stream is most likely active, if it's not the stream is most likely not active.

  9. Sorry but there no way to see if the tv program is live, The only way is to cheek to see if the url exists.

     

    this is what the current database let you see what going on.

     

    But the database does not tell you if the tv program is currently live.

     

    The only way you can rely cheek this, is to alter the database and use a cron, and update

    a database field each time a user press the watch button.

     

    But that wont even help rely, Only tell you at that time, The tv stream was working.

     

    Your have to rely on the url exists i think sorry.

     

    But that does not tell you the stream is live only the url is there.

     

    Even if you ping the streaming url your still only cheeking the url exists.

    
    [{"type": "video_archive", "broadcaster": "ggjeffy", "id": 28144, "title": "Cat doing cat stuffs", "start_time": 1186542932, "duration": 180}, {"type": "video_archive", "broadcaster": "nekomimi_lisa", "id": 39175, "title": "Nekomimi Cat Doing The Cat Dance", "start_time": 1191805139, "duration": 108}, {"type": "video_archive", "broadcaster": "nekomimi_lisa2", "id": 9832, "title": "CAT FIGHT!!", "start_time": 1185954224, "duration": 180}, {"type": "video_archive", "broadcaster": "nekomimi_lisa2", "id": 9818, "title": "cat trying to hump blanket", "start_time": 1185939617, "duration": 180}, {"type": "video_archive", "broadcaster": "ashleymarie", "id": 36553, "title": "Sister Cat Fight Part 1", "start_time": 1190060150, "duration": 80}, {"type": "video_archive", "broadcaster": "ibrbigottopee", "id": 34698, "title": "I thought i saw a putty cat", "start_time": 1189149636, "duration": 66}, {"type": "video_archive", "broadcaster": "ashleymarie", "id": 36555, "title": "Sister Cat Fight Part 2", "start_time": 1190060349, "duration": 66}, {"type": "video_archive", "broadcaster": "audratv", "id": 39679, "title": "Attack of the Fuzzy Cat Part 2", "start_time": 1191985459, "duration": 180}, {"type": "video_archive", "broadcaster": "audratv", "id": 39656, "title": "Cat Attack", "start_time": 1191980666, "duration": 180}, {"type": "video_archive", "broadcaster": "xk3ll3yx", "id": 40879, "title": "Cat on Head!", "start_time": 1192431728, "duration": 71}]
    

     

     

     

    There is a way. I should have a solution soon.

  10. Which one of these method is the better way? (IE, more efficient)

     

    // Method one
    $str = '1|2|3|4|5|6';
    
    foreach (explode('|', $str) as $key=>$val)
    {
    //Do something here
    }
    
    
    // Method 2
    $str = '1|2|3|4|5|6';
    $arr = explode('|', $str);
    
    foreach ($arr as $key=>$val)
    {
    //Do something here
    }
    

     

    Normally, I just use method 1. Will PHP run that function every alliteration, or will it run it once, and cache the array? I would think it would just cache the array...

     

    Thanks,

    Chris

     

     

     

    Method 2. In method 1 you're calling explode each iteration

  11. USE CODE TAGS please

     

    i did not get what you are asking me to do

     

    i posted the same code which i am using for making the posting into the discussion forum

     

    can you explain me in details what might be the error

     

    Code tags, when you post code on these forums it's polite to encase them within [code][/code] to preserve proper code formatting and/or code highlighting.

     

    Example:

    <?php

      function myFunction($str)

      {

          return $str;

      }

     

      echo myFunction("Hello world!");

    ?>

     

    vs

     

    <?php
      function myFunction($str)
      {
          return $str;
      }
      
      echo myFunction("Hello world!");
    ?>
    

  12. How would one go about matching the following in a string?

     

    (xxxx/yyyy)

     

    basically find anything inside a pair of quotes ( ) with a / in the middle

     

    so in this example:

     

    dfasdf asfasd : dsfasd asdfasd -.-- fhfg (40.34342/5.023424) asdf

     

    40.34342 and 5.023424 would be matched?

     

    Solved

     

    (\s\((.*?)/(.*?)\)\s)

     

  13. And I connect them with a straight line, 1 pixel wide.

     

    How would I go about tracing that line, starting at point A, and going to B?

     

    I'm working on an application and will need to check certain values at each point along a line.. I'm not actually drawing a line, but if a line were there, i would need to be able to follow it.

     

    See my graphic for an example,

     

    ideas?

     

    Edit - Basically im asking how to find the coordinates of each pixel along a line between 2 coordinates

     

     

    [attachment deleted by admin]

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