minbak
New Members-
Posts
8 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
minbak's Achievements
Newbie (1/5)
0
Reputation
-
Could I restore the following file in my database the file name is db_mysql.inc [code]<?php /* * Session Management for PHP3 * * * $Id: db_mysql.inc,v 1.2 2000/07/12 18:22:34 kk Exp $ * */ class DB_Sql { /* public: connection parameters */ var $Host = ""; var $Database = ""; var $User = ""; var $Password = ""; /* public: configuration parameters */ var $Auto_Free = 0; ## Set to 1 for automatic mysql_free_result() var $Debug = 0; ## Set to 1 for debugging messages. var $Halt_On_Error = "yes"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore errror, but spit a warning) var $Seq_Table = "db_sequence"; /* public: result array and current row number */ var $Record = array(); var $Row; /* public: current error number and error text */ var $Errno = 0; var $Error = ""; /* public: this is an api revision, not a CVS revision. */ var $type = "mysql"; var $revision = "1.2"; /* private: link and query handles */ var $Link_ID = 0; var $Query_ID = 0; /* public: constructor */ function DB_Sql($query = "") { $this->query($query); } /* public: some trivial reporting */ function link_id() { return $this->Link_ID; } function query_id() { return $this->Query_ID; } /* public: connection management */ function connect($Database = "", $Host = "", $User = "", $Password = "") { /* Handle defaults */ if ("" == $Database) $Database = $this->Database; if ("" == $Host) $Host = $this->Host; if ("" == $User) $User = $this->User; if ("" == $Password) $Password = $this->Password; /* establish connection, select database */ if ( 0 == $this->Link_ID ) { $this->Link_ID=mysql_connect($Host, $User, $Password); if (!$this->Link_ID) { $this->halt("connect($Host, $User, \$Password) failed."); return 0; } if (!@mysql_select_db($Database,$this->Link_ID)) { $this->halt("cannot use database ".$this->Database); return 0; } } return $this->Link_ID; } /* public: discard the query result */ function free() { @mysql_free_result($this->Query_ID); $this->Query_ID = 0; } /* public: perform a query */ function query($Query_String) { /* No empty queries, please, since PHP4 chokes on them. */ if ($Query_String == "") /* The empty query string is passed on from the constructor, * when calling the class without a query, e.g. in situations * like these: '$db = new DB_Sql_Subclass;' */ return 0; if (!$this->connect()) { return 0; /* we already complained in connect() about that. */ }; # New query, discard previous result. if ($this->Query_ID) { $this->free(); } if ($this->Debug) printf("Debug: query = %s<br>\n", $Query_String); $this->Query_ID = @mysql_query($Query_String,$this->Link_ID); $this->Row = 0; $this->Errno = mysql_errno(); $this->Error = mysql_error(); if (!$this->Query_ID) { $this->halt("Invalid SQL: ".$Query_String); } # Will return nada if it fails. That's fine. return $this->Query_ID; } /* public: walk result set */ function next_record() { if (!$this->Query_ID) { $this->halt("next_record called with no query pending."); return 0; } $this->Record = @mysql_fetch_array($this->Query_ID); $this->Row += 1; $this->Errno = mysql_errno(); $this->Error = mysql_error(); $stat = is_array($this->Record); if (!$stat && $this->Auto_Free) { $this->free(); } return $stat; } /* public: position in result set */ function seek($pos = 0) { $status = @mysql_data_seek($this->Query_ID, $pos); if ($status) $this->Row = $pos; else { $this->halt("seek($pos) failed: result has ".$this->num_rows()." rows"); /* half assed attempt to save the day, * but do not consider this documented or even * desireable behaviour. */ @mysql_data_seek($this->Query_ID, $this->num_rows()); $this->Row = $this->num_rows; return 0; } return 1; } /* public: table locking */ function lock($table, $mode="write") { $this->connect(); $query="lock tables "; if (is_array($table)) { while (list($key,$value)=each($table)) { if ($key=="read" && $key!=0) { $query.="$value read, "; } else { $query.="$value $mode, "; } } $query=substr($query,0,-2); } else { $query.="$table $mode"; } $res = @mysql_query($query, $this->Link_ID); if (!$res) { $this->halt("lock($table, $mode) failed."); return 0; } return $res; } function unlock() { $this->connect(); $res = @mysql_query("unlock tables"); if (!$res) { $this->halt("unlock() failed."); return 0; } return $res; } /* public: evaluate the result (size, width) */ function affected_rows() { return @mysql_affected_rows($this->Link_ID); } function num_rows() { return @mysql_num_rows($this->Query_ID); } function num_fields() { return @mysql_num_fields($this->Query_ID); } /* public: shorthand notation */ function nf() { return $this->num_rows(); } function np() { print $this->num_rows(); } function f($Name) { if(isset($this->Record[$Name])) return $this->Record[$Name]; else return ""; } function p($Name) { print $this->Record[$Name]; } /* public: sequence numbers */ function nextid($seq_name) { $this->connect(); if ($this->lock($this->Seq_Table)) { /* get sequence number (locked) and increment */ $q = sprintf("select nextid from %s where seq_name = '%s'", $this->Seq_Table, $seq_name); $id = @mysql_query($q, $this->Link_ID); $res = @mysql_fetch_array($id); /* No current value, make one */ if (!is_array($res)) { $currentid = 0; $q = sprintf("insert into %s values('%s', %s)", $this->Seq_Table, $seq_name, $currentid); $id = @mysql_query($q, $this->Link_ID); } else { $currentid = $res["nextid"]; } $nextid = $currentid + 1; $q = sprintf("update %s set nextid = '%s' where seq_name = '%s'", $this->Seq_Table, $nextid, $seq_name); $id = @mysql_query($q, $this->Link_ID); $this->unlock(); } else { $this->halt("cannot lock ".$this->Seq_Table." - has it been created?"); return 0; } return $nextid; } /* public: return table metadata */ function metadata($table='',$full=false) { $count = 0; $id = 0; $res = array(); /* * Due to compatibility problems with Table we changed the behavior * of metadata(); * depending on $full, metadata returns the following values: * * - full is false (default): * $result[]: * [0]["table"] table name * [0]["name"] field name * [0]["type"] field type * [0]["len"] field length * [0]["flags"] field flags * * - full is true * $result[]: * ["num_fields"] number of metadata records * [0]["table"] table name * [0]["name"] field name * [0]["type"] field type * [0]["len"] field length * [0]["flags"] field flags * ["meta"][field name] index of field named "field name" * The last one is used, if you have a field name, but no index. * Test: if (isset($result['meta']['myfield'])) { ... */ // if no $table specified, assume that we are working with a query // result if ($table) { $this->connect(); $id = @mysql_list_fields($this->Database, $table); if (!$id) $this->halt("Metadata query failed."); } else { $id = $this->Query_ID; if (!$id) $this->halt("No query specified."); } $count = @mysql_num_fields($id); // made this IF due to performance (one if is faster than $count if's) if (!$full) { for ($i=0; $i<$count; $i++) { $res[$i]["table"] = @mysql_field_table ($id, $i); $res[$i]["name"] = @mysql_field_name ($id, $i); $res[$i]["type"] = @mysql_field_type ($id, $i); $res[$i]["len"] = @mysql_field_len ($id, $i); $res[$i]["flags"] = @mysql_field_flags ($id, $i); } } else { // full $res["num_fields"]= $count; for ($i=0; $i<$count; $i++) { $res[$i]["table"] = @mysql_field_table ($id, $i); $res[$i]["name"] = @mysql_field_name ($id, $i); $res[$i]["type"] = @mysql_field_type ($id, $i); $res[$i]["len"] = @mysql_field_len ($id, $i); $res[$i]["flags"] = @mysql_field_flags ($id, $i); $res["meta"][$res[$i]["name"]] = $i; } } // free the result only if we were called on a table if ($table) @mysql_free_result($id); return $res; } /* private: error handling */ function halt($msg) { $this->Error = @mysql_error($this->Link_ID); $this->Errno = @mysql_errno($this->Link_ID); if ($this->Halt_On_Error == "no") return; $this->haltmsg($msg); if ($this->Halt_On_Error != "report") die("Session halted."); } function haltmsg($msg) { printf("</td></tr></table><b>Database error:</b> %s<br>\n", $msg); printf("<b>MySQL Error</b>: %s (%s)<br>\n", $this->Errno, $this->Error); } function table_names() { $this->query("SHOW TABLES"); $i=0; while ($info=mysql_fetch_row($this->Query_ID)) { $return[$i]["table_name"]= $info[0]; $return[$i]["tablespace_name"]=$this->Database; $return[$i]["database"]=$this->Database; $i++; } return $return; } } ?>[/code]
-
Code for header template [code] <html> <head> <title><?=$aset[SiteTitle]?></title><meta dcb license OBJ04PS7Q > <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <META NAME="DESCRIPTION" CONTENT="<?=$aset[SiteDescription]?>"> <META NAME="KEYWORDS" CONTENT="<?=$aset[SiteKeywords]?>"> <style> .BlackLink {font-family:verdana; font-size:11; color:black; font-weight:bold; text-decoration:none} a.BlackLink:hover {text-decoration: underline} .BlueLink {font-family:verdana; font-size:11; color:blue; font-weight:bold; text-decoration:underline} a.BlueLink:hover {text-decoration: underline} .RedLink {font-family:verdana; font-size:11; color:red; font-weight:bold; text-decoration:none} a.RedLink:hover {text-decoration: underline} a.CatLinks {font-family:verdana; font-size:11; color:black; font-weight:bold; text-decoration:none} a.CatLinks:hover {text-decoration:underline} a.SubCatLinks {font-family:verdana; font-size:11; color:blue; font-weight:bold; text-decoration:none} a.SubCatLinks:hover {text-decoration:underline} a.TitleLinks {font-family:verdana; font-size:12; color:black; font-weight:bold; text-decoration:none} a.TitleLinks:hover {text-decoration:underline} .ItemText {font-family:verdana; font-size:11; color:black; font-weight:regular; text-decoration:none} body {background-color:white; font-family:verdana; font-size:11; color:black; font-weight:regular; text-align:left} td {font-family:verdana; font-size:11; font-weight:regular; text-decoration:none} .sm {font-family:verdana; font-size:11} input, select, textarea {font-family:verdana; font-size:11; color:black; border-width:1; border-color:black} .style2 {font-family: "Courier New", Courier, mono} .style3 {font-family: Geneva, Arial, Helvetica, sans-serif} .style4 {font-weight: bold} .style5 { font-family: Geneva, Arial, Helvetica, sans-serif; font-weight: bold; font-size: 14px; } .style6 {font-size: 9px} .style7 {font-size: 10px} .style8 {font-size: 14px} .style9 {color: #00CC00} .style10 {font-family: Geneva, Arial, Helvetica, sans-serif; font-weight: bold; font-size: 14px; color: #00CC00; } </style> <script language="JavaScript"> function CheckSearch() { if(document.f1.what.value=="") { window.alert('Enter the search criteria, please!'); document.f1.what.focus(); return false; } } function CheckFriend() { if(document.sfriend.f1.value=="") { window.alert('Enter your email address!'); document.sfriend.f1.focus(); return false; } if(document.sfriend.f2.value=="") { window.alert('Enter your friend email address!'); document.sfriend.f2.focus(); return false; } } function CheckLogin() { if(document.lform.us.value=="") { window.alert('Enter your username, please!'); document.lform.us.focus(); return false; } if(document.lform.ps.value=="") { window.alert('Enter your password, please!'); document.lform.ps.focus(); return false; } } function CheckForgot() { if(document.ForgotForm.u2.value=="") { window.alert('Enter your username, please!'); document.ForgotForm.u2.focus(); return false; } } function CheckRegister() { if(document.RegForm.NewUsername.value=="") { window.alert('Enter your username, please!'); document.RegForm.NewUsername.focus(); return false; } if(document.RegForm.p1.value=="") { window.alert('Enter your password, please!'); document.RegForm.p1.focus(); return false; } if(document.RegForm.p2.value=="") { window.alert('Confirm your password, please!'); document.RegForm.p2.focus(); return false; } if(document.RegForm.p1.value != "" && document.RegForm.p2.value != "" && document.RegForm.p1.value != document.RegForm.p2.value) { window.alert('Enter and confirm your password again!'); document.RegForm.p1.value=""; document.RegForm.p2.value=""; document.RegForm.p1.focus(); return false; } if(document.RegForm.FirstName.value=="") { window.alert('Enter your First Name, please!'); document.RegForm.FirstName.focus(); return false; } if(document.RegForm.LastName.value=="") { window.alert('Enter your Last Name, please!'); document.RegForm.LastName.focus(); return false; } if(document.RegForm.address.value=="") { alert('Enter your address, please!'); document.RegForm.address.focus(); return false; } if(document.RegForm.city.value=="") { alert('Enter your city, please!'); document.RegForm.city.focus(); return false; } if(document.RegForm.state.value=="") { alert('Enter your state, please!'); document.RegForm.state.focus(); return false; } if(document.RegForm.country.value=="") { alert('Select your country, please!'); document.RegForm.country.focus(); return false; } if(document.RegForm.phone.value=="") { window.alert('Enter your Phone, please!'); document.RegForm.phone.focus(); return false; } if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.RegForm.email.value)) { return true; } alert("Invalid E-mail Address! Please re-enter."); document.RegForm.email.focus(); return false; } function CheckProfile() { if(document.RegForm.p1.value=="") { window.alert('Enter your password, please!'); document.RegForm.p1.focus(); return false; } if(document.RegForm.p2.value=="") { window.alert('Confirm your password, please!'); document.RegForm.p2.focus(); return false; } if(document.RegForm.p1.value != "" && document.RegForm.p2.value != "" && document.RegForm.p1.value != document.RegForm.p2.value) { window.alert('Enter and confirm your password again!'); document.RegForm.p1.value=""; document.RegForm.p2.value=""; document.RegForm.p1.focus(); return false; } if(document.RegForm.FirstName.value=="") { window.alert('Enter your First Name, please!'); document.RegForm.FirstName.focus(); return false; } if(document.RegForm.LastName.value=="") { window.alert('Enter your Last Name, please!'); document.RegForm.LastName.focus(); return false; } if(document.RegForm.address.value=="") { alert('Enter your address, please!'); document.RegForm.address.focus(); return false; } if(document.RegForm.city.value=="") { alert('Enter your city, please!'); document.RegForm.city.focus(); return false; } if(document.RegForm.state.value=="") { alert('Enter your state, please!'); document.RegForm.state.focus(); return false; } if(document.RegForm.country.value=="") { alert('Select your country, please!'); document.RegForm.country.focus(); return false; } if(document.RegForm.phone.value=="") { window.alert('Enter your Phone, please!'); document.RegForm.phone.focus(); return false; } if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.RegForm.email.value)) { return true; } alert("Invalid E-mail Address! Please re-enter."); document.RegForm.email.focus(); return false; } function CheckOffer() { if(document.PostForm.CategoryID.value=="") { alert('Select the category in which your offer will appear!'); document.PostForm.CategoryID.focus(); return false; } if(document.PostForm.year.value=="") { alert('Select the vehicle year, please!'); document.PostForm.year.focus(); return false; } if(document.PostForm.SelectMake.value=="") { alert('Select the vehicle make, please!'); document.PostForm.SelectMake.focus(); return false; } if(document.PostForm.VehicleModel.value=="") { alert('Enter the vehicle model, please!'); document.PostForm.VehicleModel.focus(); return false; } if(document.PostForm.VehicleColor.value=="") { alert('Enter the vehicle color, please!'); document.PostForm.VehicleColor.focus(); return false; } if(document.PostForm.mileage.value=="") { alert('Enter the vehicle mileage, please!'); document.PostForm.mileage.focus(); return false; } if(document.PostForm.DetailedDesc.value=="") { alert('Describe your vehicle in details, please!'); document.PostForm.DetailedDesc.focus(); return false; } if(document.PostForm.Price.value=="") { alert('Enter the price, please!'); document.PostForm.Price.focus(); return false; } } </script> <script language="JavaScript"> <!-- function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_findObj(n, d) { //v4.0 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && document.getElementById) x=document.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //--> </script> </HEAD> <BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 onLoad="MM_preloadImages('images/img_on_03.gif','images/img_on_04.gif','images/img_on_05.gif','images/img_on_06.gif','images/img_on_07.gif')"> <table width="770" border="0" cellspacing="0" cellpadding="0" align="center" background="images/index_22.gif" bordercolor="#000000"> <tr> <td background="images/index_22.gif" align="left" valign="top"> <table width=770 border=0 cellpadding=0 cellspacing=0 align="center"> <tr> <td colspan=4 rowspan=2 background="images/index_01.gif" valign="bottom" align="left"> <table width="100%" border="0" cellspacing="0" cellpadding="6"> <tr> <td><font face="Arial, Helvetica, sans-serif" size="4"><b><font color="#FFFFFF">Motortradermalaysia.com - Your ultimate guide to buy and sell your motor in Malaysia </font></b></font></td> </tr> <tr> <td> </td> </tr> </table> </td> <td colspan=7> <img src="images/index_02.gif" width=347 height=51 alt=""></td> <td> <img src="images/spacer.gif" width=1 height=51 alt=""></td> </tr> <tr> <td> <a href="http://www.Motortradermalaysia.com" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image32','','images/img_on_03.gif',1)"><img name="Image32" border="0" src="images/index_03.gif" width="66" height="46"></a></td> <td> <a href="http://www.Motortradermalaysia.com/register.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image33','','images/img_on_04.gif',1)"><img name="Image33" border="0" src="images/index_04.gif" width="70" height="46"></a></td> <td colspan=2> <a href="http://www.Motortradermalaysia.com/login.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image34','','images/img_on_05.gif',1)"><img name="Image34" border="0" src="images/index_05.gif" width="66" height="46"></a></td> <td> <a href="http://www.Motortradermalaysia.com/advanced.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image35','','images/img_on_06.gif',1)"><img name="Image35" border="0" src="images/index_06.gif" width="68" height="46"></a></td> <td colspan=2> <a href="mailto:kstan1122@yahoo.com" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image36','','images/img_on_07.gif',1)"><img name="Image36" border="0" src="images/index_07.gif" width="77" height="46"></a></td> <td> <img src="images/spacer.gif" width=1 height=46 alt=""></td> </tr> <tr> <td colspan=11 background="images/flash.gif"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://active.macromedia.com/flash4/cabs/swflash.cab#version=4,0,0,0" id="Movie1" width="770" height="105"> <param name="movie" value="Movie1.swf"> <param name="quality" value="high"> <param name="bgcolor" value="#FFFFFF"> <embed name="Movie1" src="Movie1.swf" quality="high" bgcolor="#FFFFFF" width="770" height="105" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"> </embed> </object></td> <td> <img src="images/spacer.gif" width=1 height=105 alt=""></td> </tr> <tr> <td> <img src="images/spacer.gif" width=166 height=1 alt=""></td> <td> <img src="images/spacer.gif" width=9 height=1 alt=""></td> <td> <img src="images/spacer.gif" width=178 height=1 alt=""></td> <td> <img src="images/spacer.gif" width=70 height=1 alt=""></td> <td> <img src="images/spacer.gif" width=66 height=1 alt=""></td> <td> <img src="images/spacer.gif" width=70 height=1 alt=""></td> <td> <img src="images/spacer.gif" width=12 height=1 alt=""></td> <td> <img src="images/spacer.gif" width=54 height=1 alt=""></td> <td> <img src="images/spacer.gif" width=68 height=1 alt=""></td> <td> <img src="images/spacer.gif" width=55 height=1 alt=""></td> <td> <img src="images/spacer.gif" width=22 height=1 alt=""></td> <td></td> </tr> </table> </td> </tr> </table> <span class="style1"> <table width=770 border=0 cellpadding=0 cellspacing=0 align="center"> <p><span class="style2"><span class="style3"><span class="style4"><span class="style6"><span class="style7"><span class="style8"><span class="style9"><a href="../mainpage.php">Read about Our Story so far......</a></span></span></span></span></span></span></span><span class="style10"></span></span></p> <p class="style5"><span class="style9"><a href="/forum">or Join our <em>Talk-Talk</em> forum</a></span> </p> <div align="center"></div> <tr> <td rowspan=6 background="images/index_22.gif" align="left" valign="top"> <p><img src="images/index_10.gif" width=166 alt=""></p> <!-- main web site content goes here --> <?=$Categories?> <br> <?=$RandomProperty?> <br> <center> <? include_once("ShowBanner.php"); ?> </center> </td> <td valign=top style="padding-top:5" width=600> <div align="center"> <? include_once("ShowBanner.php"); ?> </div> [/code]
-
I have been looking at the code for the past two days but couldn't figure out how to make it right. [url=http://www.motortradermalaysia.com]www.motortradermalaysia.com[/url] First, I would like to make the footer appear at the very bottom of the page and not in the middle of the page. Second, I want to add in 'forum' and 'about us' link within the grey navigation box. My index code: [code] <? require_once("conn.php"); require_once("includes.php"); require_once("templates/HeaderTemplate.php"); // ADVANCED SEARCH require_once("advanced.php"); require_once("templates/AdvancedSearchTemplate.php"); echo "<br><br>"; // TOP 10 $q1 = "select * from cars_listings, cars_agents, cars_priority, cars_vehicle where cars_listings.AgentID = cars_agents.AgentID and cars_agents.PriorityLevel = cars_priority.PriorityLevel and cars_agents.AccountStatus = 'active' and cars_listings.VehicleMake = cars_vehicle.VehicleID order by visits desc limit 0,9 "; $r1 = mysql_query($q1) or die(mysql_error()); $lrows = mysql_num_rows($r1); if($lrows > '0') { $ListingTable .= "<table align=center width=590 cellspacing=0>\n"; $ListingTable .= "<tr>\n<td width=75> </td>\n\t"; $ListingTable .= "<td width=200 align=center><a class=BlackLink href=\"search.php?c=$_GET[c]&AgentID=$_GET[AgentID]&search_city=$_GET[search_city]&search_state=$_GET[search_state]&search_country=$_GET[search_country]&min=$_GET[min]&max=$_GET[max]&year1=$_GET[year1]&year2=$_GET[year2]&before=$_GET[before]&vehicle=1\">vehicle</a></td>\n\t"; $ListingTable .= "<td width=125 align=center><a class=BlackLink href=\"search.php?c=$_GET[c]&AgentID=$_GET[AgentID]&search_city=$_GET[search_city]&search_state=$_GET[search_state]&search_country=$_GET[search_country]&min=$_GET[min]&max=$_GET[max]&year1=$_GET[year1]&year2=$_GET[year2]&before=$_GET[before]&r=1\">mileage</a></td>\n\t"; $ListingTable .= "<td align=center width=100><a class=BlackLink href=\"search.php?c=$_GET[c]&AgentID=$_GET[AgentID]&search_city=$_GET[search_city]&search_state=$_GET[search_state]&search_country=$_GET[search_country]&min=$_GET[min]&max=$_GET[max]&year1=$_GET[year1]&year2=$_GET[year2]&before=$_GET[before]&p=1\">price</a></td>\n"; $ListingTable .= "</tr>\n</table>\n\n"; $ListingTable .= "<table align=center width=590 border=1 bordercolor=#336699 rules=rows cellspacing=0>\n"; while($a1 = mysql_fetch_array($r1)) { $ListingTable .= "<tr style=\"border-width:1; border-color:blue\" onMouseOver=\"this.style.background='#FFFFCC'; this.style.cursor='hand'\" onMouseOut=\"this.style.background='white'\" onClick=\"window.open('info.php?id=$a1[ListingID]', '_top')\">\n\t"; $ListingTable .= "<td height=60>"; $ListingTable .= "<table align=center width=\"100%\">\n"; $ListingTable .= "<caption align=center>"; if($a1[PriorityLevel] > '1') { $ListingTable .= "<span class=RedLink>$a1[PriorityName] listing</span></caption>\n"; } $ListingTable .= "<tr>\n\t<td width=75>"; if(!empty($a1[image])) { $images = explode("|", $a1[image]); $MyImage = $images[0]; $ListingTable .= "<img src=\"cars_images/$MyImage\" width=75 height=60 border=1>"; } else { $ListingTable .= "<img src=\"no_image.gif\" border=1>"; } $ListingTable .= "</td>\n\t"; $MyMiles = number_format($a1[mileage], 0, "", "'"); $ListingTable .= "<td width=225 valign=top><b>$a1[VehicleName] $a1[VehicleModel]</b><br>Offer ID: $a1[ListingID]</td>\n\t"; $ListingTable .= "<td width=100 valign=top align=center>$MyMiles miles<br>$a1[VehicleYear] year</td>\n\t"; $MyPrice = number_format($a1[Price], 2, ".", "'"); $ListingTable .= "<td align=center width=100 valign=top><b>RM$MyPrice</td>\n"; $ListingTable .= "</tr>\n"; $ShortDesc = substr($a1[DetailedDesc], 0, 200); $ListingTable .= "<tr>\n\t<td colspan=4>$ShortDesc</td>\n</tr>\n"; $ListingTable .= "</table>\n\n</td>\n</tr>\n\n"; } $ListingTable .= "</table>"; } require_once("templates/SearchTemplate.php"); echo "<br>"; ?> <? require_once("templates/FooterTemplate.php"); ?> [/code]
-
When I tried to restore the following file in my database, it didn't work. The file name is db_mysql.inc <?php /* * Session Management for PHP3 * * * $Id: db_mysql.inc,v 1.2 2000/07/12 18:22:34 kk Exp $ * */ class DB_Sql { /* public: connection parameters */ var $Host = ""; var $Database = ""; var $User = ""; var $Password = ""; /* public: configuration parameters */ var $Auto_Free = 0; ## Set to 1 for automatic mysql_free_result() var $Debug = 0; ## Set to 1 for debugging messages. var $Halt_On_Error = "yes"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore errror, but spit a warning) var $Seq_Table = "db_sequence"; /* public: result array and current row number */ var $Record = array(); var $Row; /* public: current error number and error text */ var $Errno = 0; var $Error = ""; /* public: this is an api revision, not a CVS revision. */ var $type = "mysql"; var $revision = "1.2"; /* private: link and query handles */ var $Link_ID = 0; var $Query_ID = 0; /* public: constructor */ function DB_Sql($query = "") { $this->query($query); } /* public: some trivial reporting */ function link_id() { return $this->Link_ID; } function query_id() { return $this->Query_ID; } /* public: connection management */ function connect($Database = "", $Host = "", $User = "", $Password = "") { /* Handle defaults */ if ("" == $Database) $Database = $this->Database; if ("" == $Host) $Host = $this->Host; if ("" == $User) $User = $this->User; if ("" == $Password) $Password = $this->Password; /* establish connection, select database */ if ( 0 == $this->Link_ID ) { $this->Link_ID=mysql_connect($Host, $User, $Password); if (!$this->Link_ID) { $this->halt("connect($Host, $User, \$Password) failed."); return 0; } if (!@mysql_select_db($Database,$this->Link_ID)) { $this->halt("cannot use database ".$this->Database); return 0; } } return $this->Link_ID; } /* public: discard the query result */ function free() { @mysql_free_result($this->Query_ID); $this->Query_ID = 0; } /* public: perform a query */ function query($Query_String) { /* No empty queries, please, since PHP4 chokes on them. */ if ($Query_String == "") /* The empty query string is passed on from the constructor, * when calling the class without a query, e.g. in situations * like these: '$db = new DB_Sql_Subclass;' */ return 0; if (!$this->connect()) { return 0; /* we already complained in connect() about that. */ }; # New query, discard previous result. if ($this->Query_ID) { $this->free(); } if ($this->Debug) printf("Debug: query = %s<br>\n", $Query_String); $this->Query_ID = @mysql_query($Query_String,$this->Link_ID); $this->Row = 0; $this->Errno = mysql_errno(); $this->Error = mysql_error(); if (!$this->Query_ID) { $this->halt("Invalid SQL: ".$Query_String); } # Will return nada if it fails. That's fine. return $this->Query_ID; } /* public: walk result set */ function next_record() { if (!$this->Query_ID) { $this->halt("next_record called with no query pending."); return 0; } $this->Record = @mysql_fetch_array($this->Query_ID); $this->Row += 1; $this->Errno = mysql_errno(); $this->Error = mysql_error(); $stat = is_array($this->Record); if (!$stat && $this->Auto_Free) { $this->free(); } return $stat; } /* public: position in result set */ function seek($pos = 0) { $status = @mysql_data_seek($this->Query_ID, $pos); if ($status) $this->Row = $pos; else { $this->halt("seek($pos) failed: result has ".$this->num_rows()." rows"); /* half assed attempt to save the day, * but do not consider this documented or even * desireable behaviour. */ @mysql_data_seek($this->Query_ID, $this->num_rows()); $this->Row = $this->num_rows; return 0; } return 1; } /* public: table locking */ function lock($table, $mode="write") { $this->connect(); $query="lock tables "; if (is_array($table)) { while (list($key,$value)=each($table)) { if ($key=="read" && $key!=0) { $query.="$value read, "; } else { $query.="$value $mode, "; } } $query=substr($query,0,-2); } else { $query.="$table $mode"; } $res = @mysql_query($query, $this->Link_ID); if (!$res) { $this->halt("lock($table, $mode) failed."); return 0; } return $res; } function unlock() { $this->connect(); $res = @mysql_query("unlock tables"); if (!$res) { $this->halt("unlock() failed."); return 0; } return $res; } /* public: evaluate the result (size, width) */ function affected_rows() { return @mysql_affected_rows($this->Link_ID); } function num_rows() { return @mysql_num_rows($this->Query_ID); } function num_fields() { return @mysql_num_fields($this->Query_ID); } /* public: shorthand notation */ function nf() { return $this->num_rows(); } function np() { print $this->num_rows(); } function f($Name) { if(isset($this->Record[$Name])) return $this->Record[$Name]; else return ""; } function p($Name) { print $this->Record[$Name]; } /* public: sequence numbers */ function nextid($seq_name) { $this->connect(); if ($this->lock($this->Seq_Table)) { /* get sequence number (locked) and increment */ $q = sprintf("select nextid from %s where seq_name = '%s'", $this->Seq_Table, $seq_name); $id = @mysql_query($q, $this->Link_ID); $res = @mysql_fetch_array($id); /* No current value, make one */ if (!is_array($res)) { $currentid = 0; $q = sprintf("insert into %s values('%s', %s)", $this->Seq_Table, $seq_name, $currentid); $id = @mysql_query($q, $this->Link_ID); } else { $currentid = $res["nextid"]; } $nextid = $currentid + 1; $q = sprintf("update %s set nextid = '%s' where seq_name = '%s'", $this->Seq_Table, $nextid, $seq_name); $id = @mysql_query($q, $this->Link_ID); $this->unlock(); } else { $this->halt("cannot lock ".$this->Seq_Table." - has it been created?"); return 0; } return $nextid; } /* public: return table metadata */ function metadata($table='',$full=false) { $count = 0; $id = 0; $res = array(); /* * Due to compatibility problems with Table we changed the behavior * of metadata(); * depending on $full, metadata returns the following values: * * - full is false (default): * $result[]: * [0]["table"] table name * [0]["name"] field name * [0]["type"] field type * [0]["len"] field length * [0]["flags"] field flags * * - full is true * $result[]: * ["num_fields"] number of metadata records * [0]["table"] table name * [0]["name"] field name * [0]["type"] field type * [0]["len"] field length * [0]["flags"] field flags * ["meta"][field name] index of field named "field name" * The last one is used, if you have a field name, but no index. * Test: if (isset($result['meta']['myfield'])) { ... */ // if no $table specified, assume that we are working with a query // result if ($table) { $this->connect(); $id = @mysql_list_fields($this->Database, $table); if (!$id) $this->halt("Metadata query failed."); } else { $id = $this->Query_ID; if (!$id) $this->halt("No query specified."); } $count = @mysql_num_fields($id); // made this IF due to performance (one if is faster than $count if's) if (!$full) { for ($i=0; $i<$count; $i++) { $res[$i]["table"] = @mysql_field_table ($id, $i); $res[$i]["name"] = @mysql_field_name ($id, $i); $res[$i]["type"] = @mysql_field_type ($id, $i); $res[$i]["len"] = @mysql_field_len ($id, $i); $res[$i]["flags"] = @mysql_field_flags ($id, $i); } } else { // full $res["num_fields"]= $count; for ($i=0; $i<$count; $i++) { $res[$i]["table"] = @mysql_field_table ($id, $i); $res[$i]["name"] = @mysql_field_name ($id, $i); $res[$i]["type"] = @mysql_field_type ($id, $i); $res[$i]["len"] = @mysql_field_len ($id, $i); $res[$i]["flags"] = @mysql_field_flags ($id, $i); $res["meta"][$res[$i]["name"]] = $i; } } // free the result only if we were called on a table if ($table) @mysql_free_result($id); return $res; } /* private: error handling */ function halt($msg) { $this->Error = @mysql_error($this->Link_ID); $this->Errno = @mysql_errno($this->Link_ID); if ($this->Halt_On_Error == "no") return; $this->haltmsg($msg); if ($this->Halt_On_Error != "report") die("Session halted."); } function haltmsg($msg) { printf("</td></tr></table><b>Database error:</b> %s<br>\n", $msg); printf("<b>MySQL Error</b>: %s (%s)<br>\n", $this->Errno, $this->Error); } function table_names() { $this->query("SHOW TABLES"); $i=0; while ($info=mysql_fetch_row($this->Query_ID)) { $return[$i]["table_name"]= $info[0]; $return[$i]["tablespace_name"]=$this->Database; $return[$i]["database"]=$this->Database; $i++; } return $return; } } ?>
-
Database error: Invalid SQL: update sponsors set status=-1 where end_date<='2006-07-22' MySQL Error: 1146 (Table 'chinese.sponsors' doesn't exist) Session halted. What does this mean ?
-
Database error: Invalid SQL: update sponsors set status=-1 where end_date<='2006-07-22' MySQL Error: 1146 (Table 'chinese.sponsors' doesn't exist) Session halted. What is the problem here?
-
The original code is <? include_once($BannerPath."/ShowBanner.php?BannerType=120x60"); [color=red][font=Verdana][b]?> </center> </td> <td valign=top style="padding-top:5" width=600> <div align="center"> <? include_once($BannerPath."/ShowBanner.php?BannerType=468x60"); ?> </div>[/b][/font][/color] What is the correct code to avoid using Fopen ?
-
I have encountered a little bit problem here when I transferred my site to new host. My new host doesn't allow FOPEN in the PHP code to access a URL. So someone suggested me to change from the Original code http://www.Motortradermalaysia.com/ShowBan...ype=468x60' to suggested code ShowBanner.php?BannerType=468x60 Am I right? My problem is I could see the file of ShowBanner.php but not ShowBanner.php?BannerType=468x60. ?BannerType=468x60 Where could I find this file? This is the uploaded banner by the user. What is the correct code?