Jump to content

SharkBait

Members
  • Posts

    845
  • Joined

  • Last visited

    Never

Everything posted by SharkBait

  1. I have this: [code] <?php class MySQL {   var $rows;   var $length;   function doQuery($string) {       $query = mysql_query($string) or die("MySQL Error: <br /> {$strqry}<br />". mysql_error());       $this->$rows = mysql_fetch_array($query, MYSQL_ASSOC);       $this->$length = mysql_num_rows($query);     } } // then to use it would I: $myQuery = &new MySQL; $strqry = "SELECT * FROM BLAH"; $myRows = $myQuery->doQuery($strqry); if($myRows->length < 0) { // Nothing found } else { // Found something } ?> [/code] Would that be the similar thing as [code] <?php $strqry = "SELECT * FROM Blah"; $query = mysql_query($strqry) or die("MySQL Error: <br /> {$strqry} <br />". mysql_error()); $result= mysql_fetch_array($query, MYSQL_ASSOC); $num = mysql_num_rows($query); if($num <0) {   // Nothing returned } else {   // Found something } ?> [/code]    
  2. So you have it look like this? [code] <h3> My header</h3> <br /> <p>This is some text</p> <?php include ("menu.php");?> <p>Now some more code here</p> [/code] Or if not, can you post what you have ?
  3. I use move_uploaded_file() when I ever try to upload something to one of my webservers. so [code] <?php $filelocation = $_GET['loc']; $newName = "MyNewFile"; if(move_uploaded_file($_FILES['file']['tmp_name'], 'uploads/{$_FILES[$filelocation][$newname]'}) {   // File moved } else {   // Error with moving file } ?> [/code] Check to make sure your fileupload.php script also has the permission to execute and write to the directory you want to move the temp file into :) $_FILE[] is from a submitted form that had a file linked to it from a users machine. 
  4. You want a WYSIWYG (what you see is what you get) editor?  I believe it has to do with Javascript. I don't know for sure but I've always wanted to look into it myself.
  5. Yes this has been hit around billions of times but this is my question.. I use this bit of code lots: [code] <?php $strqry = "SELECT * FROM blah WHERE blah1 = blah2"; $query = mysql_query($strqry) or die("MySQL Error: <br />{$strqry}<br />". mysql_error()); $result = mysql_fetch_array($query, MYSQL_ASSOC); ?> [/code] Now other things I might also do with my queries is like mysql_num_rows() or mysql_affected_rows, might Delete an entry or three or update a row etc. Would it be best to come up with my own class that I could use and manipulate the arguments. Like $strqry or something? I use classes with my VB.Net projects but I want to get into using them more with PHP.  That and I think it will also allow me to clean up my code since alot of my sql queries are just repeated over and over and over.  Why type if all out again? So.. my question(s): 1) Is my logic with this correct? 2) How hard is it to create a class I can use and learn from that will do the above 3) How's the weather where you are? =-)  I just want to get more into the OOP part of PHP like I did with VB.NET because it makes things soo much easier if they are repeative bits of coding I need to use. Thanks
  6. [code] <?php $image = "<a href=\"test.php\"><img src=\"images/standards/{$row['lam_number']}-{$row['lam_name']}_40.gif\" alt=\"{$row['1am_name']}\" /></a>"; ?> [/code] So pretty much what Jenk said, was that $row['lam_number'] is looking for the field name called lam_number If you want to see the array of $row[]  then use [code=php:0] print_f($row); [/code] and it will show you the names and their values :)
  7. I didnt look over your entire code but what you want to try and do when someone tries to delete something.. try something like: pseudo: [code] <?php $user_id = $MEMBERID;    // The ID of the poster who posted the... post :P $post_id = $POSTID;      // The ID of the actual post itself. $strqry = "DELETE FROM posts WHERE post_id = '{$post_id}' AND poster_id = '{$user_id}' LIMIT 1"; $query = mysql_query($strqry) or die("MySQL Error: <br />{$strqry}<br />". mysql_error()); $num = mysql_affected_rows($query); if($num > 0) {   // Post was deleted successfully;   echo "You have deleted the post"; } else {   echo "The post was not delete succesfully"; } ?> [/code] Now I would put in slightly better check to see if the user is even allowed to delete the post in the first place. I would have  a check when you show the posts that if the user looking at the post, is their own post, then I would display them a 'delete' link.  Otherwise they wont get one at all.  Then the SQL query would check to make sure that if the person trying to delete the post, was indeed the person who originally posted it and if so, delete it from the database. Whew.. Hope that helps a little bit :)
  8. Gingerroot means something like this: [code] <?php echo '<div style="color: #fff;"> My Section </div>'; // Whereas with " you need to escape them echo "<div style=\"color: #fff;\"> My Section </div>"; ?> [/code]
  9. I use echo as well. [code] <?php $name = "SharkBait"; echo "This is my text line, my name is {$name}"; ?> [/code] I use curley braces around my varibles when I use an echo. Helps me seperate my variables from the actual text.  If I need a function within the echo I then have to do this: [code] <?php echo "My function will return ". myFunction(19) .""; ?> [/code] Hope that helps a bit.
  10. I agree with Jenk, creating a CMS is not something that can be done within a day. Like Jenk also said take a look at mysql.com (depending on the version of SQL you're runniong if its sql at all) You'll need to know SELECT, INSERT, UPDATE, and probally DELETE queries at least.  Of course being able to do all that within PHP. The CMS's that I work on rely on those SQL Commands as well as HTML forms with maybe a bit of javascrpt.    As for a website for a tutorial on making a CMS?  Not sure if there are any.  The books I used to start myself in PHP had at the end of each book a chapter or two on making a really simple CMS.  Books where Visual Quickstart Guide to PHP and Visual Quickpro (?) for Dynamic Websites in PHP and MySQL
  11. I use $_SERVER['PHP_SELF'] when referencing itself. So a file I call guestbook.php in a form I would make it look like [code] <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> [/code] That the type of thing you want to do?
  12. Too bad we couldnt get access to the MAC address associated to the IP ;) People don't change their network cards as much......
  13. If you are writing directly to a file, you will need the file to be at least a chmod level of 755? even 777 on some setups which means that script (your php file) needs to be fully executable by anyone who writes it as does the file you are editing. Please someone correct me if I am wrong about the permissions though. As for storing your passwords in a text file, if you are not using some sort of encryption and storing them in plain text, that's a no no :).  Also keeping the file in a location not accessible via the URL. Say your website is served via this path on the webserver [code] /var/html/www/index.html [/code] The webserver would be able to display anything in the /www/ directory.  You would need to put your password file lower in the heriarchy(sp)  [code] <?php //PHP for locating password file (semi-pseudo) require("../myPasswords.php"); ?> [/code] The file would be stored in [code] /var/ [/code] So, if a user points their browser to http://www.myplace.com/  they can only get any file that is served out of that /var/html/www directory.  Anything prior to that (like /var or /var/html) will not be able to served by the webserver as easily. Whew.. hope this makes somewhat sense, my spelling can be horrible at times.
  14. I put the filenames and information about the images into the database and then link them with the actual image itself in another folder. But thats me.
  15. 'chown' changes who owns the file and what group has rights to that file. 'chmod' changes permission for the file, like the above mentioned.   chmod ing a file can be good and/or bad.  It gives owner rights, user rights and guest rights.  Kinda like global read/write access to your files. I went on vacation one week and when I got back someone change my employeer's webfiles to be owned by a non-existant group. Apache didnt like that and freaked out and the website.. well didnt work like it should of ;) The someones were two coworkers who were trying to 'test' something on a live server :)
  16. My site uses simple 2 column CSS layout www.tingram.ca Should be able to see the source code to see how the floats are done. I dont use the css sheet much because I was playing with the div tags individually. This site: http://css.maxdesign.com.au/floatutorial/  I've used a few times to help me figure out layouts and such. As for tables using <div> I can't remember where I saw an example of it.  I'm sure google can find something about it though.
  17. You can 'float' the <div> tables to make tables. It can get hectic but it is doable :)
  18. Depends. Layout should be done in <div> tabular data should be done in tables :) <div> load faster than <table> do. Or thats my experience.  Though <div>s need more tricks to employ to get them to look the same across different browsers. Its why I used tables for so long.  I didnt really have to worry about them not working properly in other browsers.  Now that I am using <div> its a bit more work, but the pages look nicer, are easier to manage and load faster :)
  19. With <a href=""> tags you will need to have http:// if they don't do it else it does exactly what you see. [code] <?php echo "<tr><td><a href=\"http://{$url}\">{$event}</a></td>"; ?> [/code]
  20. You could also change your [code=php:0] if ($months ==1) [/code]to [code] <?php switch ($months) {   case 1:       // Do stuff here       break;   case 2:       // Do other stuff here       break; } ?> [/code]
  21. Shouldnt be any problems with adding multiple ANDs in a query statement. Though you are making the result more exact when you keep adding ANDs.  How many entries is it returning to you? How many items to you display on each page?
  22. Are you storing the image along with an entry for it in a database? If so then you could tie the filename with an entry in the database, query the database for the name, filesize, etc and then display the corrisponding image.
  23. I use mail() here at work for a couple of my scripts and yes hotmail blocked them.  Though the webserver I am using for these particular scripts are in house are not out actual mail server so they are being relayed. Hotmail seems to notice this relay and junk them.  In hotmail live (yes not everyone has live) you have the ability to add hosts to receive email from.  I had to add the domain name and then Hotmail was redirecting the mail properly. Though if you're not relaying the mail, then I am unsure.  It could be the wording of the email that makes it look like spam? I found that Yahoo and GMail were fine with out modifying any of the emails though. Hotmail seems to be either a) picker or b) less intellegent ;)
×
×
  • 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.