Jump to content

mikesta707

Staff Alumni
  • Posts

    2,965
  • Joined

  • Last visited

Everything posted by mikesta707

  1. I took the liberty of pasting the relevant code here, so its a little bit easier to reference the problem <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <meta property="og:title" content="[TEXT]"> <meta property="og:url" content="http://[YOURURL].blogspot.com/"> <meta property="og:image" content="[FB IMAGE]"> <meta property="og:site_name" content=""> <meta property="og:description" content="[TEXT 2]"> The error is here:<script type="text/javascript"> <!-- You never close this tag. There isn't even any javascript here. I'm not sure why you even have this opening javascript tag, since you aren't including any separate source code files here. Two seperate fixes below --> <style type="text/css">body{font-family:"Lucida Grande", Tahwitoma;font-size:11px;}p{margin:0;padding:0;}a{color:#3b5998; cursor:pointer;}a:hover{text-decoration:underline;}a.viewmore{display:block;height:29px;border:1px solid #d8dfea;background-color:#edeff4;text-align:center;line-height:29px;}a.viewmore:hover{background-color:#d8dfea;}</style><link rel="openid.server" href="http://www.blogger.com/openid-server.g" /> <!-- --><style type="text/css">@import url(http://www.blogger.com/static/v1/v-css/navbar/697174003-classic.css); div.b-mobile {display:none;} </style> </head> ... rest of code the error is highlighted and explained. Two fixes below <script type="text/javascript"></script> That adds the closing tag after the opening tag. Kind of dumb though because there is no javascript code, so you might as well just take out that script tag entirely.
  2. You can call a parent classes method from a base class by using the scope resolution operator in combination with the parent keyword. using your example class triangle extends rectangle { ... public function area(){ //i can call parent by doing this parent::area(); //i should probably return the value returned by parent though return parent::area(); } ... }//end class EDIT: actually that would probably call Rectangle's area() method since rectangle is the parent of triangle, not the base class they are both derived from. Let me do a little research and get back to you. The basic idea described above is solid Edit2: After a bit of research, I am unsure if you can access things at the parent's parent's class scope without some ugly hackish type code. One suggestion would be to add a boolean parameter to rectangle's area method which indicates that it would call the parent method instead of doing it normally. for example class rectangle extends Shape { public function area($callBase = false) { if ($callBase) return parent::area(); return round(($this->length)*($this->height),2); } public function perimeter() { return round(2*(($this->a)+($this->b)),2); } public function display() { echo "area is :". rectangle::area() . "<br>"; echo "perimeter is : ". rectangle::perimeter() ."<br>"; } } final class triangle extends rectangle { function __call($method_name, $arguments) { $accepted_methods = array("getCoordinates","perimeter"); } public function area() { return parent::area(true); } ... } ... ... While something like this may work, it may be beneficial to review your class structure. Perhaps triangle should inherit from shape. A triangle isn't really a rectangle. Something like Square would be a bitter fit for a child of rectangle. Its about the number of sides, and making triangle a child of rectangle is like making rectangle a child of a 5 or more sided shape, like a pentagon or hexagon. The areas/circumferences/volume/etc. are all calculated differently for shapes of different number of sides.
  3. Oh I missread your code, and the stupid timer won't let me modify my first post anymore. You return the socket variable that you want to use. What is strange is that you have a socket data member that you never assign a value to. It seems you intend to assign ur socket data member a value, but didn't because you didnt know or realize my point in my first post. There are a couple ways you could fix your code, and both ways are really based on what style you want to code with. Either is valid of course. I recommend this way <?PHP class objSocket { public $socket; //whenever you refer to this variable, it must be quantified with $this-> function Server($host, $port) { //echo "created a socket: $host:$port<br>"; $this->socket = fsockopen("udp://" . $host, $port); //return $socket; no need to return since our class now has access to this socket } } class objTemp extends objSocket { function sendMsg($string) { //echo "sending: $string"; fwrite($this->socket, $string); } } $tClient = new objTemp; $tClient->Server("127.0.0.1", 23000); $tClient->sendMsg("Hello World"); ?> But you could also do <?PHP class objSocket { //public $socket; this becomes kind of useless since we dont assign it anything function Server($host, $port) { //echo "created a socket: $host:$port<br>"; $socket = fsockopen("udp://" . $host, $port); return $socket; } } class objTemp extends objSocket { function sendMsg($string, $socket) {//since we no longer keep track of the socket within the class, we need to pass it in //echo "sending: $string"; fwrite($socket, $string); } } $tClient = new objTemp; $socket = $tClient->Server("127.0.0.1", 23000);//we need to catch the return value $tClient->sendMsg("Hello World", $socket);//we need to pass our socket in since its no longer part of the class ?> One fix versus the other is a debate that can get rather lengthy and really depends on your coding style
  4. try using $this->socket instead of $socket. When trying to use class scope data members, you need to quantify them with $this-> so PHP knows which scope the variable you are looking for is. In your example, $socket would try to refer to a variable defined or available in the local scope.
  5. because the key its being stored as in the associative array is 'SUM( ROUND(Price,2) )' I believe. You could use the as operator to make it store in your own defined key name, so $query1=mysql_query("SELECT SUM( ROUND(Price,2) ) as PriceSum FROM bellProducts WHERE ID IN ($joinIDs)"); then you could access it like $result1['PriceSum']
  6. The easiest way in my opinion would be to just save the data in the $_SESSION super global. You could then unset that data once the form has been successfully completed.
  7. if you dont have a database setup then of course your mysql_connect is going to fail. I don't know what you are using to host php on your local computer, but you should try to google a tutorial on how to set up a database.
  8. The reason you only get two output is because you overwrite the value of $this->username and $this->password in every iteration of the loop. I'm unsure of what exactly you want the links to be. Can you explain that a little better?
  9. thats because you have a for loop that does the same thing for every column regardless or which column it is. //assuming we just want to echo the id, resource ID and then a link, we can do echo "<td>" . $row['id'] . "</td>"; echo "<td>" . $row['resourceID'] . "</td>"; echo "<td><a href='" . $row['URL'] . "'>Link or Script</a></td>"; obviously you will need to change the keys I used to the correct column names you are grabbing with your select statement. This would replace your for loop. EDIT: I wouldnt use mysql_result, since its easier and faster to just grab the whoel row in 1 go. If you wanted to replace the link text (in this case, Link or Script) with the value (i'm not sure what value you are referring to) then whatever column has the value, use that column as a key in the $row array. Hope this helps
  10. Tutorial explaining hidden fields: http://www.echoecho.com/htmlforms07.htm
  11. It would depend heavily on how your email client separates the actual replies from reply chains. Do you have an example email or at least the format at which they are read.
  12. if you want to make the opacity normal, change the opacity style.. not the background-color style. normal opacity is at 100 percent. function mouseOver() { document.getElementById('wrap').style.filter = "alpha(opacity=100)"; document.getElementById('wrap').style.opacity = "1"; } In the future, please be patient when waiting for an answer, and refrain from PMing users.
  13. Ok. if you echo time() also, what do you get? that date seems pretty close to the current time (about an hour behind) but thats because I'm on the east coast.
  14. You don't need to master a language to be able to use it effectively. You can easily learn both languages side by side if you put in enough effort. Anyways, back to your topic. You say you want to create websites and perhaps web applications based on that website. A few things I should mention. One, web applications does not necessarily mean you use Java. Web apps is a very broad term, and can encompass programs written in many different languages (PHP, Javascript, Java, Python, RoR, Perl, etc..). What you want to examine is what kind of web apps you want to focus on (as certain languages are better suited for certain jobs.. in a general sense) As far as simple web development (I dont mention design because that includes CSS, which isn't really part of this discussion) PHP is one of the (if not THE) most popular languages for web dev, so I would suggest definitely learning PHP. I would at the very least start learning PHP exclusively, unless you have a clear plan of what you want to accomplish. However, once you have a good basis in PHP, you can decide what kind of project you want to do, and decide what else you need to learn from there. For example, want to make a chat site? Well there are many possible ways to do this (You can do this with PHP, Javascript/AJAX, java, etc.) If you are interested in having persistant user accounts on your site (IE login/registration type websites) then you probably want to look into learning some type of Database, like Mysql(i), msql, etc. to put it simply, what you decide to learn really does depend on what you want to do, but if you want to get into web development, PHP is a great place to start EDIT: Agreed. However, I have yet to encounter anything programmed in Java that didn't require me to install Java on the client. That is what I was referring to. Not sure I follow. why would you need to install on the client.. thought as a web application it will be server side, and any client side applications ran on java runtime already installed on the clients machine (well hopefully unless they just came out from a rock) When he says you need to install java on the client, I believe he is referring to the JVM which must be installed on the client, as you mention. In most cases, yes it will already be installed. He is talking more about the fact that while the java code is stored server side, when the applet is run, it is processed by the jvm on the client side. Or at least thats how I interpreted it.
  15. In addition to this, also remember that people can use onXxx attributes (like onClick, onFocus, etc.) to insert javascript into your page. OnClick events may not seem very dangerous, but an event like onLoad with some javascript that did some bad stuff could potentially be devastating. However, this assumes that you do not trust the user inputting data. Simply stripping the tags that xyph suggested may very well suffice since you mentioned you trust the user input to a point
  16. Firstly, when posting code, please post the relevant code. No one wants to search through lines and lines of code just to find the code you are talking about. Secondly, I assume the conditional you are having trouble with is the following if (($lockDate != "0000-00-00 00:00:00") && strtotime($lockDate) < time()) { Have you tried echoing $lockDate to see what it contains? Try echoing the actual value of $lockDate, and the value returned from the strtotime($lockDate) function call to make sure they have what you expect. then we can try debugging from there
  17. If you aren't worried about your users injecting harmful HTML into the news articles, than sanitizing isn't really a problem. html entities/decode might be good so you don't have to deal with quotes when inserting into the database (it turns quotes into entities also), but either way would be ok. One could argue that if you trust your users enough not to put harmful html into the news articles, you could trust them enough not to attempt to insert SQL injections. Personally, I would strip all HTML tags and use a BBC code type system, but I don't trust anyone
  18. if you only want the player or coach allowed just take whoever isn't allowed out of the $people_allowed array.
  19. Using an array with a foreach or similar style loop would certainly make this code alot shorter, which would probably make it alot more manageable and easier to update (IE instead of copying that whole block again to add a section, you just add an entry onto the array.)
  20. In case you were wondering, the $var = (condition) ? val1 : val2; syntax webstyles used is the ternary operator. Going to mark your topic as solved.
  21. I'm assuming you entered the text for that description in a textarea? text areas use newline characters to denote when you go to the next line (the character: \n) luckily, php has a function, nl2br which converts newlines to their html equivalent (line breaks, or the <br /> tag)
  22. Not really sure what you mean by labels, and since you decided to just post code and completely leave out an explanation of what you want, all I can really do is ask for more info. What do you want to be output, and what is currently being output?
  23. Well first thing first, you have to use session_start() when using sessions on a page: http://php.net/manual/en/function.session-start.php I also suggest you read a bit on how session variables work
×
×
  • 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.