
ratcateme
Members-
Posts
1,216 -
Joined
-
Last visited
Never
Everything posted by ratcateme
-
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.
-
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.
-
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.
-
sorry i can't be more help i just can't work out what is missing
-
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.
-
that is the print_r($_POST) it is all the data being sent to the page are you sure you are updating the results page because the output i get just could not come from the code i see Scott.
-
what are the permissions on the destination directory? they need to be writable by php Scott.
-
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.
-
what error does it return? Scott.
-
worked it out shift this line <form method="post" action="results.php"> to above where it prints out all the checkboxes and it should be fine Scott.
-
for config file writing have a look at fopen and this page shows how to run a sql file http://www.phptoys.com/e107_plugins/content/content.php?content.80 Scott.
-
when you tested it did you select some breads/shelters? i can't really see anything wrong but can you post the html that that php generates for the form. Scott.
-
can you post the html code generated for the form please Scott.
-
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.
-
And SQL is also fairly simple for basic projects check out tizag.com for some tutorials it also covers basic injection protection normally all u need is mysql_real_escape_string it works wounders with most applications Scott.
-
there is a php function for searching arrays array should be listed there but i would go with mysql no questions are you sure you don't want the ability to add more pages? and a array with 10000 strings 10 characters long would be 97kb alone in the file it would slow do the page a hog memory a mysql database would be far better Scott.
-
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.
-
Thanks looks cool now Scott.
-
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.
-
<td>" . substr($buffer, $pos2 + 1, $pos) . "</td>" maybe i dont know
-
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.
-
[SOLVED] replacing a certain number of chars with stars
ratcateme replied to dennismonsewicz's topic in PHP Coding Help
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. -
i think you will need to mysql_real_escape_string $field and $value separately other wise the ' will get escaped Scott.
-
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.