Jump to content

ratcateme

Members
  • Posts

    1,216
  • Joined

  • Last visited

    Never

Posts posted by ratcateme

  1. i use wireshark i have done a lot of network programming in java and found it use full for debugging  that it is also use full for finding http headers and also in case like that one you can use it to get all the html that is sent even though you cannot see it because quick time loads

     

    Scott.

  2. i have been coding in php/mysql for a while but stayed with very basic SELECT INSERT UPDATE DELETE

    basically at the moment i want to do this

    i have two tables

    leaves(ID,
    branchID,
    type,
    typeTableID)
    and
    types(ID,
    table)

    each has some more fields but they are dont matter here

    leaves.type corresponds to a ID in types

    basically i have a ID for leaves and i want to use it to get leaves.branchID, leaves.typeTableID and types.table

    i tried

    SELECT `leaves.branchID`, `types.table`, `leaves.typeID` FROM `types`, `leaves` WHERE `leaves.ID` = $id AND `leaves.type` = `types.ID`  LIMIT 1

    and got

    Failed. Error: Unknown column 'leaves.branchID' in 'field list'

    is this possible and if so how?

     

    Scott.

  3. a quick packet sniff reveals

    HTTP/1.1 200 OK
    Date: Sun, 15 Feb 2009 03:59:17 GMT
    Server: Apache/2.2.9 (Ubuntu) PHP/5.2.6-2ubuntu4.1 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.0
    X-Powered-By: PHP/5.2.6-2ubuntu4.1
    Content-Length: 125
    Keep-Alive: timeout=10, max=100
    Connection: Keep-Alive
    Content-Type: video/mp4
    Content-Language: en-US
    
    <br />
    <b>Fatal error</b>:  Call to undefined function file_size() in <b>/var/www/watchvideo.php</b> on line <b>32</b><br />

    not sure but looks like you host has disabled file_size()

     

    Scott.

     

  4. i have no clue what is going wrong because if you number this code lines starting from 1

    foreach($_POST['shelters'] as $shelter){
           $shelter = mysql_fetch_assoc(mydsql_query("SELECT `sheltername` FROM `shelters` WHERE `id` = {$shelter}")or die(mysql_error()),0);
           $shelter = $shelter['sheltername'];
          echo "<h2>$shelter</h2><br />";
          $shelter = mysql_real_escape_string($shelter);
          $query = "SELECT * FROM `dogs` WHERE `shelters_id` = $shelter AND $common_where";
          $result = mysql_query($query) or die(mysql_error() . "<br>" . $query);
          if(mysql_num_rows($result) == 0){
             echo "No matching dogs<br />";
             continue;
          }
          while($row = mysql_fetch_assoc($result)){
             $breed = mysql_fetch_assoc(mydsql_query("SELECT `breedname` FROM `breeds` WHERE `id` = {$row['breed_id']}")or die(mysql_error()),0);
             $breed = $breed['breedname'];
             echo "<h3>$breed </h3><br/>";
             echo ($row['male'] == 1?"Male":"Female"). "<br />";
             echo ($row['child'] == 1?"Good For Children":"Not so good with Children"). "<br />";
             echo ($row['other_dogs'] == 1?"Good with other dogs":"Not so good with other dogs"). "<br />";
          }
    
    
       }

    you should get

    <h2>shelter</h2><br /><h3>breed name</h3><br/>

    at the very least it should have information about the dong on the end i am totally confused as to how you could get the <h3></h3> part without the <h2> part and how you could get a number not a breed name

     

    Scott.

  5. i am a bit confused by the results it is outputting but try this

    <!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">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    
    <?php
    
    
    mysql_connect($host,$username,$pass);
    mysql_select_db($username);
    
    print_r($_POST);
    
    if(isset($_POST['shelters'])){
    
       $breeds_where = "";
       if(isset($_POST['breeds'])){
          foreach($_POST['breeds'] as $breed){
             $breed = mysql_real_escape_string($breed);
             if($breeds_where != ""){
                $breeds_where .= " OR ";
             }
             $breeds_where .= "`breed_id` = $breed";
          }
      echo "<h3>$breed </h3><br/>";
       }
       $common_where = "";
       if(isset($_POST['sex'])){
          if($_POST['sex'] == "male"){
             if($common_where != ""){
                $common_where .= " AND ";
             }
             $common_where = "`male` = 1";
          }elseif($_POST['sex'] == "female"){
             if($common_where != ""){
                $common_where .= " AND ";
             }
             $common_where = "`male` = 0";
          }
       }
       if(isset($_POST['child'])){
          if($_POST['child'] == "yes"){
             if($common_where != ""){
                $common_where .= " AND ";
             }
             $common_where = "`child` = 1";
          }
       }
       if(isset($_POST['dogs'])){
    
          if($_POST['dogs'] == "yes"){
             if($common_where != ""){
                $common_where .= " AND ";
             }
             $common_where = "`other_dogs` = 1";
          }elseif($_POST['dogs'] == "no"){
             if($common_where != ""){
                $common_where .= " AND ";
             }
             $common_where = "`other_dogs` = 0";
          }
       }
       if($breeds_where != ""){
          if($common_where != ""){
             $common_where .= " AND ";
          }
          $common_where .= "($breeds_where)";
       }
       foreach($_POST['shelters'] as $shelter){
           $shelter = mysql_fetch_assoc(mydsql_query("SELECT `sheltername` FROM `shelters` WHERE `id` = {$shelter}")or die(mysql_error()),0);
           $shelter = $shelter['sheltername'];
          echo "<h2>$shelter</h2><br />";
          $shelter = mysql_real_escape_string($shelter);
          $query = "SELECT * FROM `dogs` WHERE `shelters_id` = $shelter AND $common_where";
          $result = mysql_query($query) or die(mysql_error() . "<br>" . $query);
          if(mysql_num_rows($result) == 0){
             echo "No matching dogs<br />";
             continue;
          }
          while($row = mysql_fetch_assoc($result)){
             $breed = mysql_fetch_assoc(mydsql_query("SELECT `breedname` FROM `breeds` WHERE `id` = {$row['breed_id']}")or die(mysql_error()),0);
             $breed = $breed['breedname'];
             echo "<h3>$breed </h3><br/>";
             echo ($row['male'] == 1?"Male":"Female"). "<br />";
             echo ($row['child'] == 1?"Good For Children":"Not so good with Children"). "<br />";
             echo ($row['other_dogs'] == 1?"Good with other dogs":"Not so good with other dogs"). "<br />";
          }
    
    
       }
    
    }
    ?>
    
    </body>
    </html>

     

    Scott.

     

  6. i modified the main code a little bit but i don't see why it shouldn't be working.

    and also i changed the {$row['id']} in the last query to {$row['breed_id']}

    <?php
    if(isset($_POST['shelters'])){
    
    $breeds_where = "";
    if(isset($_POST['breeds'])){
    	foreach($_POST['breeds'] as $breed){
    		$breed = mysql_real_escape_string($breed);
    		if($breeds_where != ""){
    			$breeds_where .= " OR ";
    		}
    		$breeds_where .= "`breed_id` = $breed";
    	}
    }
    $common_where = "";
    if(isset($_POST['sex'])){
    	if($_POST['sex'] == "male"){
    		if($common_where != ""){
    			$common_where .= " AND ";
    		}
    		$common_where = "`male` = 1";
    	}elseif($_POST['sex'] == "female"){
    		if($common_where != ""){
    			$common_where .= " AND ";
    		}
    		$common_where = "`male` = 0";
    	}
    }
    if(isset($_POST['child'])){
    	if($_POST['child'] == "yes"){
    		if($common_where != ""){
    			$common_where .= " AND ";
    		}
    		$common_where = "`child` = 1";
    	}
    }
    if(isset($_POST['dogs'])){
    
    	if($_POST['dogs'] == "yes"){
    		if($common_where != ""){
    			$common_where .= " AND ";
    		}
    		$common_where = "`other_dogs` = 1";
    	}elseif($_POST['dogs'] == "no"){
    		if($common_where != ""){
    			$common_where .= " AND ";
    		}
    		$common_where = "`other_dogs` = 0";
    	}
    }
    if($breeds_where != ""){
    	if($common_where != ""){
    		$common_where .= " AND ";
    	}
    	$common_where .= "($breeds_where)";
    }
    foreach($_POST['shelters'] as $shelter){
    	echo "<h2>$shelter</h2><br />";
    	$shelter = mysql_real_escape_string($shelter);
    	$query = "SELECT * FROM `dogs` WHERE `shelters_id` = $shelter AND $common_where";
    	$result = mysql_query($query) or die(mysql_error() . "<br>" . $query);
    	if(mysql_num_rows($result) == 0){
    		echo "No matching dogs<br />";
    		continue;
    	}
    	while($row = mysql_fetch_assoc($result)){
    		$breed = mysql_result(mydsql_query("SELECT `breedname` FROM `breeds` WHERE `id` = {$row['breed_id']}")or die(mysql_error()),0);
    		echo "<h3>$breed </h3><br/>";
    		echo ($row['male'] == 1?"Male":"Female"). "<br />";
    		echo ($row['child'] == 1?"Good For Children":"Not so good with Children"). "<br />";
    		echo ($row['other_dogs'] == 1?"Good with other dogs":"Not so good with other dogs"). "<br />";
    	}
    
    
    }
    
    }
    ?>

    if it is still not working try adding some debug like echo "at stage..."

    so you know what the script is doing and can see where it is failing

    also try print_r($_POST); to see if that is all good

     

    Scott.

  7. you need a http server

    checkout xampp

    also if you want to run it at your house you will want a dynamic DNS checkout dyndns.org

    it turns you ip into a web address for free

    and if you are on a computer behind a router you will need to add port fowarding on port 80 check out you routers hand book for that

     

    Scott.

     

     

  8. i don't know if you guys are bother with this but since you last CSS upgrade Google Chrome now displays the code super small

    i have found the zoom function but just letting you guys know if you care about the small about of us out there using chrome

    because we can't read any code boxes

    but it looks fine in FF3 and IE7

     

    Scott.

  9. id have to say i have never really used netbeans from PHP development until i download the new 6.5 edition it is free and contains a live error checker and has a built in function dictionary although it is slow to load it often

    the two main problems with it is the initial start up time is REALLY long and also i think i needs some more work on the FTP side

     

    Scott.

  10. for first 4:

    echo "****" + @substr($password,4);

    the @ will suppress any errors caused if the password is less than 4 chars long

     echo @substr($password,0,4)."****";

    will start the last 4

    but as many users on this forum will tell you stroing passwords in plain text (or even encrypted with reversible encryption) is EXTREMELY bad practice and output putting them (or part of them) is even WORSE

    you should be using MD5 encryption with a salt for password storing

    and never output passwords or even the MD5 encryptions

     

    Scott.

  11. well i would recommend getting something like xampp and installing on a PC around your development environment so you can test on localhost

    also most if not all hosts running mysql/php now days use phpMyAdmin for setting up mysql tables and database it is very easy to learn and also use full for debugging SQL statements if you are at a loss to explain as to why no results are returned.

    there are lots of hosts out there with mysql/php and i know there have been a few lists of them compiled on these forums if you do a search

     

    Scott.

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