-
Posts
3,372 -
Joined
-
Last visited
-
Days Won
18
Everything posted by Muddy_Funster
-
you can fix the Query doesn't match comlumn count by explicitly listing the fields that you want to insert into : INSERT INTO tableName (fieldname1, fieldname3, fieldname46, fieldname47) VALUES ($var1, $var2, $var3, $var4) that little bit of code shouldn't affect the display at all other than to put N/A where the blanks would have been.
-
failed to open stream: No such file or directory
Muddy_Funster replied to Jessica's topic in PHP Coding Help
All I can think of is checking the availability of each directory, as running from shell could have a different root than running from a web script $dir1 = '/'; $files1 = scandir($dir1); var_dump($files1); $dir2 = '/www'; $files2 = scandir($dir2); var_dump($files2); $dir3 = '/www/documents'; $files3 = scandir($dir3); var_dump($files3); probably something you've done already, but it's all I got, sorry. -
you don't need to store the N/A in the database, infact it's probably best that you dont do it. all you need to do is some conditional formating on your display. Something along the lines of: while($row = mysql_fetch_assoc($data)) //------------------------------ //this will check each result and replace any empty fields with 'N/A' foreach($row as $k => $v){ if(trim($v) == ''){ $v = 'N/A'; } } //------------------------------ { echo "{$row['doc_id']}<br />".
-
do you have custom error messages set up?
-
try moving this: $colCount = $colCount++; down a line so it is after that } which is directly under it just now
-
reivewed, I missed a ; <?php echo '<div class="resultados_sub_cat">'; $colCount = 0; echo "<table>"; foreach($this->subcats as $key => $subcat) { if($colCount == 3){ echo "</tr>"; $colCount = 0; } if($colCount == 0){ echo "<tr><td>"; } else { echo "<td>"; } $subcat->link = JRoute::_('index.php?option=classcliff&view=list&catid='.$subcat->id."&Itemid=".$this->Itemid); if ($key != 0){ echo ' - '; echo '<a href="'.$subcat->link.'">'.$subcat->name.'</a></td>'; $colCount = $colCount++; } } echo "</table>";
-
and what do you get if you echo $visitors_online->browser ? how and where are you actualy calling the usersOnline method?
-
untested, but should be close: <?php echo '<div class="resultados_sub_cat">'; $colCount = 0; echo "<table>"; foreach($this->subcats as $key => $subcat) { if($colCount == 3){ echo "</tr>"; $colCount = 0 } if($colCount == 0){echo "<tr><td>";} else {echo "<td>";} $subcat->link = JRoute::_('index.php?option=classcliff&view=list&catid='.$subcat->id."&Itemid=".$this->Itemid); if ($key != 0) echo ' - '; echo '<a href="'.$subcat->link.'">'.$subcat->name.'</a></td>'; $colCount = $colCount++; } echo "</table>";
-
PHP login form verifying username with odbc connect to Access
Muddy_Funster replied to timmykins02's topic in PHP Coding Help
cahnge this line: //echo "<form action='index.php' method='post'> \n" ; <<----change From this echo "<form action='' method='post'> \n" ; //<<----to this -
PHP isn't browser specific, it has no direct interface with the browser (you need javascript for that). If it's working on one browser and not another it's most likely 1. your loading an old version of the page in the other browser 2. CSS is out (some browsers are stricter than others about errors in css) 3. HTML is malformed (some browsers won't render pages if the HTML code is too badly formed, others will just put up with it a bit better) tick off all three of those and you *should* get it working on all browsers.
-
ok, being as I'm the impatient type I went ahead and changed the checks to user the $this array, it's now throwing what I want, but I can't help but feel there has to be a better way to do the comparison. This is what I've ended up with (thanks in no small part to the help I have had here) : <?php //------------------------------------------------ class dbc { public $server; public $host; public $db; public $user; public $pass; public $hasError; public function set($var, $val=0){ $atts = (array) $this; try{ if(is_array($var)){ if(count(array_diff_key($var, $atts)) >= 1){ $eek = implode(', ',array_flip(array_diff_key($var, $atts))); throw new custError(" '$eek' is/are not (a) valid parameter(s)", 1); } else{ foreach ($var as $k => $v) { $this->$k = $v; } } } else{ if (array_key_exists($var, $atts) === false){ throw new custError(" '$var' is not a valid parameter", 1); } else{ $this->$var = $val; } } } catch(custError $e){ $msg = $e->getEreturn(); $level = $msg['0']; $txt = $msg['1']; $eLocation = 'dbo->set()'; $error = new errorCatch; $setError = array($eLocation, $txt); $error->ErrorHandle($setError, $level); $this->hasError = "caught the error"; } } } //------------------------------------------------ class custError extends Exception{ private $eLevel; private $eMessage; public function __construct($message = "", $severity = 0){ parent::__construct($message); $this -> eLevel = $severity; $this -> eMessage = $message; } public function getEreturn(){ $eOut = array($this->eLevel, $this->eMessage); return $eOut; } } //------------------------------------------------ class errorCatch{ public $severity; public $methodCall; public $message; public function ErrorHandle($error,$level){ $this->methodCall = $error['0']; $this->message = $error['1']; $this->severity = $level; if ($this->severity == 1){ die ("<b>Critical</b> : Error in call to $this->methodCall : $this->message"); } die("<b>Warning</b> : Call to $this->methodCall resulted in a non fatal error : $this->message"); } } //------------------------------------------------ //$error = new errorCatch; $con = new dbc; $set = array('host'=>'localhost', 'server'=>'mysql'); //$set = 'server'; $con->set($set, 'mssql'); var_dump($con); ?> I'm still playing with it, so if anyone can suggest a better comparison for the try I'd be happy to hear it.
-
no worries, glad I could help.
-
your query line is wrong: //$ipsql = mysql_query("SELECT * FROM bans WHERE ip='$user_ip'" or die (mysql_error())); should be: $ipsql = mysql_query("SELECT * FROM bans WHERE ip='$user_ip'") or die (mysql_error()); also have you checked the value in $bancheck to make sure it's what you think it should be?
-
1 - not sure what this has to do with MS SQL Server? 2 - more information than "it's not working" is always appreciated 3 - the following three lines should all have an or die statement at the end to display any errors coming back from the database: $db=mysql_connect("2up2downhomes.com.mysql", "userxxx", "passxxx") or die (mysql_error()); mysql_select_db("2up2downhomes_c", $db) or die (mysql_error()); $result = mysql_query("SELECT * FROM properties") or die (mysql_error());
-
yeah, something like that should do it.
-
I've never seen anyone use a foreach like that. try assigning the $k inside the loop instead of using a break. I don't know that you have access to $k / $v outside of the loop as they are defined within it's call.
-
thanks for that Kevin. I'm still not actualy throwing out anything on the comparison check, it's just making new class attributes if the $this->$k / $this->$var doesn't already exist. How do I get it to throw an error if the attribute isn't an existing predefined one? Example - using the code as it is now : <?php //------------------------------------------------ class dbc { public $server; public $host; public $db; public $user; public $pass; public $hasError; public function set($var, $val=0){ $atts = (array) $this; try{ if(is_array($var)){ foreach ($var as $k => $v) { if(!$this->$k = $v){ throw new custError(" '$k' is not a valid parameter"); } } } else{ if(!$this->$var = $val){ throw new custError(" '$var' is not a valid parameter"); } } } catch(custError $e){ $msg = $e->getEreturn(); $level = $msg['0']; $txt = $msg['1']; $eLocation = 'dbo->set()'; $error = new errorCatch; $setError = array($level, $eLocation, $txt); $error->ErrorHandle($setError); $this->hasError = "caught the error"; } } } //------------------------------------------------ class custError extends Exception{ private $eLevel; private $eMessage; public function __construct($message = "", $severity = 0){ parent::__construct($message); $this -> eLevel = $severity; $this -> eMessage = $message; } public function getEreturn(){ $eOut = array($this->eLevel, $this->eMessage); return $eOut; } } //------------------------------------------------ class errorCatch{ public $severity; public $methodCall; public $message; public function ErrorHandle($error){ $this->severity = $error['0']; $this->methodCall = $error['1']; $this->message = $error['2']; if ($this->severity == 1){ die ("Critical error in call to $this->methodCall : $this->message"); } die("Warning Call to $this->methodCall resulted in a non fatal error : $this->message"); } } //------------------------------------------------ //$error = new errorCatch; $con = new dbc; $set = array('host'=>'localhost', 'svr'=>'mysql'); $con->set($set); var_dump($con); ?> I want it to throw an error saying "srv is not a valid property name" instead it just goes and makes a new attribute called srv in the class and populates it with the value of 'mysql'. Do I need to cast $this into an array and check the array keys V's the input? I've tried searching for other ways but cant get anything that helps with this problem. Cheers
-
$data = mysql_query($sql) or die(mysql_error()."<br>-----------<br>$sql"); $num = mysql_num_rows($data); //<<<------ This line here is counting the number of rows returned by the query while($row = mysql_fetch_assoc($data)) look at the comment above. You see how $num is being assigned with the number of rows returned from the query? you just need to write an if statement to check that at least 1 row is fouund from the query, if it is, display the results, otherwise show your message about not finding the document.
-
I'm trying to cheack if $v is being assigned to an existing public var defined at the top of the class. if $k does not match any of the defined variables($host, $server, $user, $pass, $db - the other one is only there just now for testing) throw an error, if it does match assign $v to $this->$k problem is, if it doesn't find an existing variable by the name of $k ir just goes and makes a new one :/
-
Am I as well to cast $this as an array and then check the array keys V's the atempted attribute name?
-
assides from some scary bad coding practice, what's the actual problem?
-
OK, I have this working with a sample dataset: FORM PAGE : <?php //---------------- // Include files // - Connect to DB //---------------- include "newheader.php"; include "connect_db.php"; include "lib/toolfunctions.php"; ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Language" content="en" /> </head> <body> <p> <form action = "searchByDocID.php" method = "post"> <!-- body onLoad focuses textbox on load -- Only works in Chrome at the moment --> <body onLoad = "documentNumber.focus()"> <input type= "text" id= "documentNumber" name= "searchbyequipmenttype"/> <input type= "submit" name= "searchID" value="Search By Doc ID" /><br /> <font size = '2'>EG: 123</font> </p> </form> <div id="toolFooterWrapper"> <div id="toolFooter"> TC Tool<br/>Version 1.00 </div> </div> </body> </html> and searchByDocID PAGE : <?php include 'connect_db.php'; include 'newheader.php'; function sanitize_data($data) { $data = array_map('trim',$data); $data = array_map('strip_tags',$data); $data = array_map('htmlspecialchars',$data); $data = array_map('mysql_real_escape_string',$data); return $data; } $post = sanitize_data($_POST); if (isset($post['searchID']) && $post['searchbyequipmenttype'] != '') { $id = $post['searchbyequipmenttype']; $sql = <<<SQL SELECT * FROM sampleformid WHERE ( doc_id = $id ) SQL; $data = mysql_query($sql) or die(mysql_error()."<br>-----------<br>$sql"); $num = mysql_num_rows($data); while($row = mysql_fetch_assoc($data)) { echo "{$row['doc_id']}<br />". "{$row['doc_title']}<br />". "{$row['doc_number']}<br />". "{$row['doc_type']}<br />". "{$row['revision']}<br />". "{$row['cdm_link']}<br />". "{$row['mars_link']}<br />". "{$row['checklist_link']}<br />". "{$row['link_internal_1_3']}<br />". "{$row['impacted_products']}<br />". "{$row['scope']}<br />". "{$row['impacted_products_2']}<br />". "{$row['review_class']}<br />". "{$row['full_or_simplified']}<br />". "{$row['earliest_date']}<br />". "{$row['latest_date']}<br />". "{$row['previous_tc_reviews']}<br />". "{$row['proj_name']}<br />". "{$row['author_name']}<br />". "{$row['req_list']}<br />". "{$row['optional_list']}<br />". "{$row['information_only']}<br />". "{$row['chairperson']}<br />". "{$row['reviewers_required']}<br />". "{$row['review_duration']}<br />". "{$row['document_abstract']}<br />"; } } else{ echo "there was a problem with the form, please try again and make sure you have filled in a document number"; } include 'footer.php'; ?> the last include thre may be off as I deleted it and put it back in (the notice was bugging me) The Result I got was: 123 test X123-V2 test 1.0 n/a pluto till after none NARROW still none c simple like me whenever thenever none test me no no probably me not likely short as possible sure is I forgot to say - you will need to change the table name back from "FROM sampleformid" in the SQL code block, yours should read "FROM forms"
-
anyone tell me the proper syntax to check that a method is assigning a value to an existing class variable and not just making a new one?
-
ok, been looking over everything and have noticed I passed over a fairly important point, change the SQL statement to this: $sql = <<<SQL SELECT * FROM tc_tool.forms WHERE ( doc_number =$id ) SQL;
-
if you can give access in a secure manner (like temp user and pass) sure, pm it to me with the host address and I'll see what I can do.