Jump to content

RussellReal

Members
  • Posts

    1,773
  • Joined

  • Last visited

Everything posted by RussellReal

  1. inserting into a database.. you should always make sure to use mysql_real_escape_string.. ' and " are used by malicious users for an attack known as SQL Injection.. to remove the slashes later.. stripslashes() will do the trick
  2. you've used == in the WHERE, instead of the single =.. <?php //start inital query with a listing of years -> songs played for($i=2009; $i<1959; $i--){ $result = mysql_query("SELECT * FROM `songs` WHERE `artist` = 'Ryan Adams'"); //debug if(!$result){ echo "No Result!"; } else{ echo "Result!"; } if (mysql_num_rows($result) > 0) { echo "Success! <br>"; } else{ echo "Failure! <br>"; } while($row = mysql_fetch_array($result)){ echo "<ol class=\"results-primary\">"; echo "<li>" . $i . "</li>"; echo "<li class=\"date\">" . $row['date'] . "</li>"; echo "<li class=\"song\" onmouseover=\"this.style.backgroundColor='yellow';\" onmouseout=\"this.style.backgroundColor='lightblue';\">" . $row['name'] . "</li>"; }//end while echo "</ol>"; }//end for ?>
  3. you sure the field is called 'total'?
  4. .= is shorthand it is like: $var .= "lol"; $var = $var."lol"; ^^ both of those do exactly the same thing
  5. you could actually turn those two selects into 1 query, but thats for later lol SET usually comes before WHERE although I really don't know if that is really important lol I really don't see much wrong with your code =\
  6. first of all that doesn't belong here.. lol but here is information about your solution http://w3schools.com/js/js_cookies.asp
  7. ?? huh lol can you like.. show a whole php block of code or something coz you lost me lol
  8. if you have msn you could add me and ask me questions and stuff.. I'm available like 20/7 I'm a freelancer but I prefer helping people lol
  9. OOPS, nevermind.. didn't notice it was 3 pages alrdy.. lol I wrote like an essay for you.. but I took it away
  10. okay, you see how you said /files/ instead of /mysite/files/ what akitchin is saying is.. you can access /files/ with php from /mysite/login/view.php and I'd assume probably with chdir I havn't practiced this method much, so don't quote me I'm just Mr. Clarification lol
  11. also note, I've only EVER worked with VDS/DS and currently own 2 VDS hosting plans, 1 with jumpline (which i really wouldn't recommend expensive and SHIT) and 1 with WestHost I got it at the $10 a month deal, and imo its really worth it lol
  12. `id` LIKE '%$q'% theres a problem.. idk if its THE problem `id` LIKE '%{$q}%' is more like it but I guess the { } are not so manditory.. thats just how I code oh and right after the <? try $q = $_REQUEST['q'];
  13. it doesn't actually COMPILE it.. what it does is EXECUTE the PHP, then sends whatever PHP says to send, to the client like <? echo "hi"; ?> php will evaluate the PHP tag <? ... ?> php will then go over the commands it encounters echo "hi"; echo "hi"; just basically means "output: hi" so thats the end, then php sends the OUTPUT to the client then the client gets the data, lables it HTML (in most cases, unless specified otherwise) then renders it.. it is only run once, and you cannot run it again after php has finished executing for that request
  14. ORDER BY `price` will just order by price, it won't select 1 or the other, use the LIMIT clause to specify how many results you want
  15. what I used for php was another beginner php guy, and we just worked on things together.. php.net will explain ANYTHING better than ANY tutorial.. also.. with tutorials.. you end up WOW COOL! and then at the end of the lesson.. copy/pasting the finished code and using it and modifying it.. but you hardly ever think about the functions you use thats why you want to know how to "split a string apart by a character" you'd ask sum1.. how would I do that?! "explode()" OH COOL! *goes to php.net/explode* *reads everything it has to say + UNDERSTANDS IT* tutorials just make you keep going back to it.. reading manuals teaches you.. thats my opinion anyway.. still to this day I go to php.net regularly just to find a new function.. you'll NEVER run out of functions to discover with php.. there is literally thousands
  16. php.net there is a WHOLE LIST of array functions, such as array_sum() and each() its always alot easier to check php.net before posting on sites like these, coz then you waste 20 mins waiting for a reply lol
  17. do not use more than 1 connection? reuse the same connection, that way you will eliminate the error.. there is no reason to have more than 1 database.. maybe more than 1 table for 1 purpose, but more than 1 database for 1 purpose, is excessive, and pointless.. so.. using only 1 mysql connection = actually more effective also. I used to open connections whenever I needed 1, instead of reusing already open ones.. also, this error isn't you opening and not closing.. because @ the very end of php, resources, variables, and any other created data is destroyed, unless you're in some older php version or something. so mysql_close() was really intended for mid-execution resource disposal.. shorten your amount of mysql_connect() to a lower number of calls, if not to 1.. heres an idea: just have a connect.php and inside do your mysql_connect() whatever then at the very top of each page, do include("connect.php"); then every other include below it has access to the connection resource.. thus completely eliminating the need for more than 1 mysql_connect()
  18. lets say the numbers are all <? $array = array("giants" => 25,"packers" => 32,"cowboys" => 77,"vikings" => 82,"jets" => 92); $sum = array_sum($array); $i = 0; foreach ($array as $k => $v) { $i++; $a[$i][] = (($v / $sum) * 100); $a[$i][] = $k; } ?> biw after the for each loop, your $a array should hold [ 0 ] => percent [ 1 ] => name percent would be between 0 and 100 and then.. you just make 1 bar per $a index and give it the width of $a[index][0]px viola
  19. IN THE A TAG target="_BLANK"
  20. yeah, what hes saying is put them in lets say a hidden folder, (atleast thats what I'm grasping) ~~ EDIT~~~ I understand what he means by "above your root" or whatever, you're in /var/www/htdocs or / and then your site goes in like /yoursite/index.php or whatever so you'd go 1 step back from /htdocs/ or /yoursite/ into the /www/ or / folder, which will be inaccessible through your url, but it IS accessible to your php code ~~~~~~~~~ so lets say its in mysite.com/login/ you'd put it in mysite.com/login/userfiles/ in /login/ put a php file files.php then do mysite.com/login/files.php?file=mypdf.pdf in files.php you'd check for the user's credentials, if he is logged in.. readfile("userfiles/{$_GET['file']}"); otherwise die("You do not have access to this file");
  21. Yeah, I really don't think theres a file, I'd have to pull something like eval("\$var = \"{$actualVar}\";"); to evaluate the \n \r you know the escaped characters, I just set up a str replace $image[] = str_replace(array('\x3c','\x3e','\x3d','\x26'),array('<','>','=','&'),substr($data,$q1 + 1,$start - ($q1 + 1)));
  22. html.. css.. javascript.. flash.. photoshop lol
  23. htaccess you're going to want to move all MEMBERS only files into a folder maybe called MEMBERS and then make HTACCESS redirect the user to a php page where you can see if the cookie / session is set, if it is, then use REQUEST_URI to get the file requested and then just echo the contents and set the content type, and it should replicate the file download / browser viewed pdf if you want, add me on msn RussellonMSN@hotmail.com or sex.meNOW@yahoo.com (Yahoo IM) I can help you out better that way
  24. if you didn't set .html files as a php extension in your php ini or htaccess, then html is just what it is.. an HTML file, in order to use PHP in these files, just change your extensions to .php and they'll work fine add this to your .htaccess file if you're shared hosting or don't understand php ini AddType application/x-httpd-php .html .htm that should fix your "php in html" problem
  25. lol... I KNOW what the difference in QUOTES are.. nvm forget I asked.. lol
×
×
  • 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.