Jump to content

matthew9090

Members
  • Posts

    135
  • Joined

  • Last visited

    Never

Posts posted by matthew9090

  1. <?php

        error_reporting(E_ALL);

     

        $name = $_POST['name'];

        $file = $_POST['file'];

     

    $moved = move_uploaded_file($_POST['file']['tmp_name'], "upload/");

    if ($moved) {

    echo "moved!";

    }

    else {

    echo "did not move!";

        }

        echo $name . "<br />" . $file . "<p>";

     

    if (strlen($name)>10)

    {

      echo "name too long";

    }

    else

    {

     

    //private stuff

  2. I have got a flash file that is stored in the database. So I fetch it and put it in a variable then put the variable in the flash embed code where the src is but the flash comes up blank.

     

    $file = "SELECT * FROM table WHERE column='$name'";
    $file2 = mysql_query($sqlfile);
            $file3 = @mysql_fetch_assoc($file2);
    $file4 = $file3['gamefile'];
      //skip some code to html embed section
    <object width='550' height='400'>
    <param name='movie' value='valuename'>
    <embed src='$file4' width='550' height='400'>
    </embed>
    </object>
    
        
    

     

    then the page comes up with a white box which when you hover over it says 'file not loaded'.

  3. here is the full code:

     

    <?php
    
    //get data
    $button = $_GET['submit'];
    $search = $_GET['search'];
    
    
    $s = $_GET['s'];
    if (!$s)
    $s = 0;
    
    
    $e = 10;
    
    
    $next = $s + $e;
    $prev = $s - $e;
    
    
    
    
    if (strlen($search)<=2)
      echo "Must be greater then 3 chars";
    else
    {
      echo "<br /><table><tr><td><a href = index.php></a></td><td><form action='search.php' method='GET'><a href ='index.php'><img src='logo.png' align='top' height='28' width='60'></img></a><input type='text' value='' size='50' name='search' value='$search'> <input type='submit' name='submit' value='Search'></form></td></tr></table>";
      
      //connect to database
      mysql_connect("localhost","root","");
      mysql_select_db("test");
       
       //explode out search term
       $search_exploded = explode(" ",$search);
       
       foreach($search_exploded as $search_each)
       {
       
            //construct query
        $x++;
        if ($x==1)
         $construct .= "keywords LIKE '%$search_each%'";
        else
         $construct .= " OR keywords LIKE '%$search_each%'";
       
       }
       
      //echo outconstruct
      $constructx = "SELECT * FROM search WHERE $construct";
      
      $construct = "SELECT * FROM search WHERE $construct LIMIT $s,$e";
      $run = mysql_query($constructx);
      
      $foundnum = mysql_num_rows($run);
       
      $run_two = mysql_query("$construct");
      
      if ($foundnum==0)
       echo "No results found for <b>$search</b>";
      else
      {
       echo "<table bgcolor='#0000FF' width='100%' height='1px'><br /></table><table bgcolor='#f0f7f9' width='100%' height='10px'><tr><td><div align='right'><b>$foundnum</b> result(s) found for <b>$search.</b></div></td></tr></table><p>";
       
       while ($runrows = mysql_fetch_assoc($run_two))
       {
        //get data
       $title = $runrows['title'];
       $desc = $runrows['description'];
       $url = $runrows['url'];
       
       echo "<table width='300px'>
       <h4><a href='http://$url'><b>$title</b></a><br />
       $desc<br>
       <font color='00CC00'>$url</font></table></h4>
       ";
       }
    ?>
    
    <table width='100%'>
    <tr>
    <td>
    <div align="center">
    
    <?php
    if (!$s<=0)
    echo "<a href='search.php?search=$search&s=$prev'>Prev</a>";
    
    $i =1; 
    for ($x=0;$x<$foundnum;$x=$x+$e)
    {
    
    echo " <a href='search.php?search=$search&s=$x'>$i</a> ";
    
    
    $i++;
    
    
    }
    
    if ($s<$foundnum-$e)
      echo "<a href='search.php?search=$search&s=$next'>Next</a>";
    
      
    }
    }  
    
    ?>
    </div>
    </td>
    </tr>
    </table>
    

  4. you could use the implode function to turn it into string then str_replace then explode into array again.

     

    e.g

     

    <?php
    
    $array = //array
    implode(" " . $array);
    str_replace($replace, $array);
    explode(" " . $array);
    
    ?>
    
    

     

    it should work, just wrote it of the top of my head.

     

  5. in my site search some of the results come out still with html. i have used the strip tags function but how would i use the preg_match function to get rid of the "> still left over?

  6. i have made my own website suggestion box but when i start typing in on my websites search box google chrome automatically suggests other words and you can't see underneath. I don't want this to happen to other people viewing my website. Is there any sort of code i an put on my website to stop this?

  7. code so far

    <?php include('simple_html_dom.php'); ?>
    <script type="text/javascript">
    function redirect(){
    window.location.href = "index.html";
    }
    </script>
    <?php 
    $s = $_GET["s"];
    if ($s == null) 
        echo "you have not searched for anything" . '<script type="text/javascript">window.onload = setTimeout("redirect()", 3000);</script>';
    else
        echo "you searched for $s<hr>";
    
    
    $urls[1] = 'http://url.com/';
    $urls[2] = 'http://url2.com';
    
    
    foreach ($urls as $url)
    {
       $html = file_get_html($url);
       strip_tags($html);
       preg_match("/<body>(.*)<\/body>/s", $html, $body);
       preg_match('@^(?:http://)?([^/]+)@i', $html, $matches);
       $htmls_split = split('<', $body[1]);
       
       foreach ($htmls_split as $line)
       {
          if (preg_match("/$s.*/", $line, $matches))
          {
        if (strlen($s) == 0)
    	    die();
    	else
    	    str_replace($s, "<b>$s</b>", $matches[0]);
                echo "<p>$matches[0]";		
          }
       }
    }
    
    ?>
    

     

    the str_replace doesn't do anything at the moment.  :'(

     

    please help!

  8. i am making a search engine to search my site and the code is going well but i don't know how to find your search within the results and put it in bold (like google does). I use a thing called http://simplehtmldom.sourceforge.net/ for getting the html of my website.

     

    <?php include('simple_html_dom.php'); ?>
    <?php 
    
    $s = $_GET["s"];
    if ($s == null) 
        echo "you have not searched for anything";
    else
        echo "you searched for $s<hr>";
    
    $urls[0] = 'http://url.com/';
    $urls[1] = 'http://url2.com';
    
    foreach ($urls as $url)
    {
       $html = file_get_html($url);
       strip_tags($html);
       preg_match("/<body>(.*)<\/body>/s", $html, $body);
       $htmls_split = split('<', $body[1]);
       
       foreach ($htmls_split as $line)
       {
          if (preg_match("/$s.*/", $line, $matches))
          {
             echo "<p>$matches[0]";
          }
       }
    }
    
    ?>
    

  9. i am making a search engine and i need help because i need it so you submit your url then it automatically scrolls it for the description and keywords then puts it in the database. my html code:

     

    <form action="submit_url.php" method="get">
    <input type="text" name="url" value="url" />
    <input type="submit" name="submit" value="submit" />
    </form>

     

    php code so far:

     

    <html>
    <head>
    <title>submitting url: <?php $url = $_GET['url']; echo $url; ?></title>
    <link href="style.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    
    <?php
    echo "Submitting <b>$url</b>";
    
    $url = fopen("http://knexideas.co.cc", "r") or exit("Unable to open");
    while (!feof($url))
      {
      fgetc($url);
      }
    fclose($url);
    
    
    ?>
    </body>
    </html> 

     

    all it does is reads the website if you put 'echo $url' at the bottom it just reads and prints the web page.

  10. it comes up with this in the database:

     

     

    id name       file_name                         type_of_file

    1 file               [bLOB - 11 Bytes]         Array[type]

    2 another file [bLOB - 11 Bytes]         Array[type]

     

    the insert script:

    <?php
    //connection stuff
    $sql="INSERT INTO upload (name, file_name, type_of_file, size)
    VALUES
    ('$_POST[name]','$_FILES[file][name]','$_FILES[file][type]')";
    
    if (!mysql_query($sql,$con))
      {
      die('Error: ' . mysql_error());
      }
    echo "Idea name: " . $_POST["name"] . "<br />";  
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "<b>Upload sucessful!</b>";
    
    mysql_close($con)
    ?>
    

     

     

  11. im not a proffesional but if you want to transfer it over i think you have to create a seperate page called calender and a page with the form on the the data goes to the calender.

     

    e.g:

     

    form.html

     

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

     

     

    myform.php

     

    //code here

     

    but i think there is another way to do it on the same page:

     

    <form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post"  ENCTYPE="multipart/form-data">

     

    //code down here

     

    or something like that

     

     

  12. i've found a pagination script of the internet but the image comes up blank. I've stored it in a largeblob. When i check the html it says 'array[name]' as the image pz help me heres the code:

    <?php
    
    //connection stuff here
    
    $page = 1;
    if ( isset( $_GET['page'] ) ) {
    $page = (int) $_GET['page'];
    }
    
    $query = mysql_query("SELECT COUNT(*) FROM `upload`",$link);
    list( $total ) = mysql_fetch_row( $query );
    $total = ceil( $total / $perPage );
    $start = ( $perPage * ( $page - 1 ) );
    $limit = '';
    $show = true;
    if ( $total > 1 ) {
    $limit = " LIMIT {$start}, {$perPage}";
    }
    else {
    $show = false;
    }
    
    $query = mysql_query("SELECT * FROM `upload` ORDER BY `id`{$limit}");
    while( $row = mysql_fetch_assoc( $query ) ) {
    echo "<img src=\"{$row['file_name']}\" alt=\"{$row['name']}\" title=\"{$row['name']}\" />";
    }
    
    if ( $show ) {
    $prev = $page - 1;
    $next = $page + 1;
    if ( $prev > 0 ) {
    	echo "<a href=\"{$thispage}?page={$prev}\">[PREV]</a>";
    }
    if ( $next < $total ) {
    	echo "<a href=\"{$thispage}?page={$next}\">[NEXT]</a>";
    }
    }
    
    ?>
    

     

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