Jump to content

Canman2005

Members
  • Posts

    669
  • Joined

  • Last visited

    Never

Posts posted by Canman2005

  1. Yep, tried it with new data, doesnt seem to work

     

    I was told to declare mysql_real_escape_string to all variables when I insert them, to avoid any hacking of the database, so now I have tons of data with slashes in it.

     

    If it's common practise to use declare mysql_real_escape_string when dealing with INSERTS & UPDATES, then how do people normally remove the slashes when viewing the data through a PHP page

  2. Hi all

     

    I'm doing some insert queries in PHP and I am using the followng to make the data being inserted SAFE

     

    $full_nane = mysql_real_escape_string($_POST['full_name']);

     

    I asume this is correct.

     

    But in the database it's outputting for example

     

    David\\\'s

     

    So it's added 3 slashes, which I believe is right.

     

    The problem comes when I output it, the 3 slashes remain, I have tried

     

    stripslashes

     

    but it just removes 2 of the 3 slashes

     

    Any ideas?

  3. Hi all

     

    I have a date stored in my db, example would be

     

    2008-11-32

     

    I output it as

     

    print $row['expdate']

     

    How can I add 3 months to that date and out put it as YYYY-MM-DD.

     

    Everything I try doesnt seem to have any effect.

     

    Thanks

     

    Ed

  4. if (get_magic_quotes_gpc()) {

          $value = stripslashes($value);

      }

     

      // Quote if not integer

     

      if (!is_numeric($value) || $value[0] == '0') {

          $value = "'" . mysql_real_escape_string($value) . "'";

      }

      return $value;

    }

     

    didnt seem to work, ill do it with the

     

    mysql_real_escape_string

     

    funtion

     

    Thanks

  5. Thanks, but how can I order these rules, I tried, but the rows returned from the first QUERY appear at the top and the rows returned from the second QUERY appear at the bottom.

     

    Is there a way to sort all the rows returned?

  6. Hi all

     

    I have done website development for almost 10 years now, I want to put up a website showcasing some of the clients work I have done over the past 10 years, I wanted to include clients names and work I have done for them even if I worked with them whilst working for a company rather than freelancing.

     

    If I work at a web development company, as a freelancer, am I allowed to publish the clients I did work for through those companies or do I have to keep quiet about that?

     

    Cheers

  7. Hi all

     

    I have the following database tables

     

    one table called "items1"

     

    id    name

    1    iPod Nano

    2    iPod Touch

    3    iMac

     

    and another table called "items2"

     

    id    main_id  name

    1    2            iPod Classic

    2    1            iPhone

    3    2            MacBook

     

    Now as you can see I have 2 tables and the second table "items2" contains a field called "main_id" that ID number relates to the ID number on "items1".

     

    My question is, how can I run a query to get all rows which have the number 2 in either the ID field of the "items1" table or a number 2 in the "items2" table. So the results would look like

     

    2                  iPod Touch

    1    2            iPod Classic

    3    2            MacBook

     

    Any ideas?

     

    Thanks

     

    Dave

  8. Hi all

     

    This code is really bugging me and ive been cracking at it for hours now and cannot seem to figure out the issue.

     

    The rules for the code are that it must be a flv file under 4MB, but for some reason it doesnt bring any error up if I upload a 38MB RAR file, but brings up an error for example if I upload a 20KB FLV file for example.

     

    It's totally random on the error front.

     

    Can anyone help? I should be able to fix it as I coded it :(

     

    if(isset($_POST['save']))
    {
    $dir = file_exists('membersvideos/'.$_SESSION['member_id_number'].'');
    if($dir != 1)
    {
    mkdir('membersvideos/'.$_SESSION['member_id_number'].'');
    }
    
    $timedatecode = date('YmdHis');
    $timedate = date('Y-m-d H:i:s');
    
    $upload_folder = 'membersvideos/'.$_SESSION['member_id_number'].'/';
    if($_FILES['videofile']['name'])
    {
    $rand1 = rand(111111111,999999999);
    $rand2 = rand(111111111,999999999);
    $ext1 = explode('.',basename($_FILES['videofile']['name']));
    $filesize1 = $_FILES['videofile']['size'];
    $file_extension1 = strtolower(substr(strrchr($_FILES['videofile']['name'],"."),1));
    if($filesize1 <= 400000)
    {
    if($file_extension1 == 'flv')
    {
    $upload_file1 = str_replace("'", "", $upload_folder.$timedatecode.$rand1.$rand2.'.'.strtolower($ext1[1]));
    $upload_file1_db1 = str_replace("'", "", $timedatecode.$rand1.$rand2.'.'.strtolower($ext1[1]));
    if (move_uploaded_file($_FILES['videofile']['tmp_name'], $upload_file1))
    {
    $sql = "INSERT INTO `members_videos` SET `memberid`='".$_SESSION['member_id_number']."', `filename`='".$upload_file1_db1."', `album_id`='".$_POST['album_id']."', `live`=1, `timedate`='".$timedate."'";
    $query = mysql_query($sql);
    }
    else
    {
    print"<script>alert ('There was a error - please try again');</script>";
    print "<meta http-equiv=\"refresh\" content=\"0;URL=done.php\">";
    exit;
    }
    }
    else
    {
    print"<script>alert ('There was a error - please only add FLV videos');</script>";
    print "<meta http-equiv=\"refresh\" content=\"0;URL=done.php\">";
    exit;
    }
    }
    else
    {
    print"<script>alert ('There was a error - your video must be under 4MB in size');</script>";
    print "<meta http-equiv=\"refresh\" content=\"0;URL=done.php\">";
    exit;
    }
    }
    print "<meta http-equiv=\"refresh\" content=\"0;URL=done.php\">";
    exit;
    }

     

    Much thanks in advance

  9. wicked, thanks guys, helped loads.

     

    If anyone is interested, to do this

     

     

    1: create a .htaccess file with the contents as

     

    RewriteEngine on

    RewriteRule ^(.*).php$ content.php?url=$1&%{QUERY_STRING}

     

     

     

    2: Then create a php page called "content.php" and add the following

     

    <?php

    $db_name ="dbname";

    $server = "localhost";

    $dbusername = "usr";

    $dbpassword = "pwd";

     

    $connection = mysql_connect($server, $dbusername, $dbpassword) or die(mysql_error());

    $db = mysql_select_db($db_name,$connection)or die(mysql_error());

     

    $sql = "SELECT * FROM `table` WHERE `url` = '".$_GET['url']."'";

    $show = @mysql_query($sql,$connection) or die(mysql_error());

    while ($row = mysql_fetch_array($show))

    {

    print $row['title'];

    }

    ?>

     

     

     

    3: Now create a table using the following

     

    CREATE TABLE `table` (

      `id` int(100) NOT NULL auto_increment,

      `title` varchar(255) NOT NULL,

      `url` varchar(255) NOT NULL,

      PRIMARY KEY  (`id`)

    ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

     

    INSERT INTO `table` (`id`, `title`, `url`) VALUES

    (1, 'About Us', 'aboutus');

     

     

     

    4: Navigate to the same URL that you have stored your "content.php" and rather than typing "content.php", try typing "aboutus.php" and it should pull through the title of the row in the database which has the same URL as you have entered.

     

     

    If you're running WAMP, to enable mod_rewrite, you need to open the "httpd.conf" file and uncomment

     

    LoadModule rewrite_module modules/mod_rewrite.so

     

    so

     

    #LoadModule rewrite_module modules/mod_rewrite.so

     

    becomes

     

    LoadModule rewrite_module modules/mod_rewrite.so

     

    you can find the "httpd.conf" file if you click on the WAMP icon and go to config files

     

     

    Any probs, get in touch

  10. Hi all

     

    Im building a little shopping cart and wondered what everyones thoughts were.

     

    Is it better to have my URL as

     

    http://www.website.com/shop?productid=12

     

    or is it better to have

     

    http://www.website.com/chocolate_biscuits.html

     

    For search engines, is it better to use the name of the page or a product ID.

     

    If you think using the name, such as "chocolate_biscuits.html" then is there a way to dynamically create "chocolate_biscuits.html" on the fly using a template and pulling product information from a database?

     

    The reason I ask is that I have seen a site which manages to create a HTML page on the fly which has the same filename as the product they are displaying, so in the database they have

     

    Large Chocolate Biscuits

     

    as a product title, and somehow its managing to create a page such as

     

    large_chocolate_biscuits.html

     

    on the fly using a the templated PHP page and pulling the required data from the database that relates to that product.

     

    I did notice at the end of each URL they have something like

     

    p-435.html

     

    I can only asume that is the ID number of the product.

     

    Can someone shed some lights on this?

     

    Thanks so much

     

    Ed

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