Jump to content

aspnetguy

Members
  • Posts

    6,787
  • Joined

  • Last visited

Posts posted by aspnetguy

  1. I am trying to setup up a daatabase object in PHP5 so I don't have to write the mysql_connect and mysql_select_db statements all the time along with the error checking and messages. Here is my object and the 3 related pages and the errors I get. The username and password is correct because I can manually write out the connect and select statements and successfully connect to the database.UPDATE: I updated the code and error messages, I worked through a coupe of the errors but can't figure out why it is not connecting. It is acting like it is not recognizing the username and password.class/Database.php

    <?php	 	 class Database	 {		 private $server;		 private $user;		 private $password;		 private $database;		 private $db;		 		 public function __construct()		 {			 $this->server = "localhost";			 $this->user = "xxxxx";			 $this->password = "xxxxx";			 $this->database = "xxxxx";		 }		 		 public function open()		 {			 $this->db = mysql_connect($this->server,$this->user,$this->password);			 if(!$this->db) die("Unable to connect to database server!");			 			 mysql_select_db($this->database) or die("Unable to select database!");		 }			 		 public function close()		 {			 mysql_close($this->db);		 }	 }	  ?>

    index.php

    <?php  	  require("class/Database.php");	  require("class/Site.php");	  require("class/Page.php");	  	  $page = new Page($_GET["id"]);	  echo "{$page->name}";    ?>

    class/Site.php

    <?php 	 class Site	 {		 private $db;		 public $template;		 public $description;		 public $keywords;		 public $name;		 public $homepage;		 public $notes;		 		 public function __construct()		 {			 $this->init();		 }		 		 private function init()		 {			 $this->db = new Database();			 $this->db->open();			 $result = mysql_query("select * from site");			 while($row = mysql_fetch_array($result))			 {					 $this->template = $row["default_template"];				 $this->description = $row["description"];				 $this->keywords = $row["keywords"];				 $this->name = $row["name"];				 $this->homepage = $row["homepage"];				 $this->notes = $row["notes"];			 }			 $this->db->close();			 			 if(strlen($this->homepage) < 1)				 die("Homepage is not set!");		 }	 }  ?>

    class/Page.php

    <?php 	 class Page	 {		 private $id;		 private $db;		 public $name;		 public $description;		 public $keywords;		 public $notes;		 public $secure;		 public $template;		 		 public function __construct($id) 		 {			 $this->id = $id;			 $this->init();		 }		 		 private function init()		 {			 $this->db = new Database();			 $this->db->open();			 $site = new Site();			 if(strlen($this->id) < 1)				 $this->id = $site->homepage;				 			 $result = mysql_query("select * from pages where id={$this->id}");			 while($row = mysql_fetch_array($result))			 {				 $this->name = $row["name"];					 $this->description = (strlen($row["description"]) < 1) ? $site->description : $row["description"];				 $this->keywords = (strlen($row["keywords"]) < 1) ? $site->keywords : $row["keywords"];				 $this->notes = $row["notes"];				 $this->secure = ($row["secure"] == "1") ? true : false;				 $this->template = ($row["template"] == "default") ? $site->template : $row["template"];			 }			 $this->db->close();		 }	 }  ?>

    errors

    Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Inetpub\wwwroot\dev\xengine\class\Page.php on line 28Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\Inetpub\wwwroot\dev\xengine\class\Page.php on line 28Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Inetpub\wwwroot\dev\xengine\class\Page.php on line 29
  2. HTML

    <form id="theForm" action="mailto:person1@domain.com" method="post"><input type="radio" name="email" value="person1@domain.com" selected="selected" onclick="changeEmail(this)"/> person1<br/><input type="radio" name="email" value="person2@domain.com" onclick="changeEmail(this)"/> person2</form>

    JS

    function changeEmail(radio){  document.getElementById("theForm").action = radio.value;}

  3. first off Firefox is not Netscape. Firefox is created by Mozilla, Netscape is not. Infact Netscape abandoned their own engine and switched to Gecko (the engine Firefox uses) when they released Netscape 8.If you just want the user to go to another page with they click a button you coudl do this.

    <input type="buton" value="Click Me" onclick="window.location='url to to other page'"/>

  4. place the dll file in your projects bin folder. Then in vs right click on references from the solution explorer and choose Add. Browse to your bin folder and select the dll. It should now be in your selection list. Press OK.Then at the top of every page you want to se it on you use this statement (C#)using dllNamespace; //replace with correct namespace[.sub namespace] declarations.

  5. looks like they stupidly let it expire and it got snatched up. I did a search to see if anyone has been saying anything about this. The only related topic I could find was a reference to them letting there name expire back in 2005 also. They will probably try and buy it back but will pay a huge amount for it. that is why these companies buy expired domains.

  6. put a hidden <asp:textbox> in your page "txtSource" then place the following script just before </body>

    <script type="text/javascript">  document.getElementById("txtSource").value = "<html>" + document.getElementsByTagName("html")[0].innerHTML + "</html>";</script>

    Then when you press the email send button you can use txtSource.Text to get the full html code to paste into the message body

  7. I dont get any radiobutton with this script... are you sure this is well written???
    I didn't use a radiobutton I used a check box. You asked how to change the form action using a check box.
    a checkbox to choose between 2 persons (person 1 or person 2) to contact with the same form
  8. it works fine. You have to click away from the box (that is what onblur means) to get the event to fire. You could use onchange instead of on blur. It would check everytime the value change (every keypress).

  9. oh sorry. As far as I know there is no way to detect or override this. The browser buttons are not part of the webpage. Unless the browser gives access through COM or ActiveX (which I don't think they do) there is no way to do this.Browser history is a known drawback for AJAX applications.

×
×
  • Create New...