Jump to content

hitman6003

Members
  • Posts

    1,807
  • Joined

  • Last visited

Everything posted by hitman6003

  1. The variable $TestArray is outside the scope of the method of your class... http://www.php.net/language.variables.scope
  2. How long is "pretty lengthy"? If you get the same row twice, does it cut off at different places? Or the same? Echo/print has no limit to my knowledge. I doubt that mssql_fetch_row has a limit either, unless the result exceeds php's memory limit.
  3. Either way works... -- http://www.php.net/control-structures.elseif
  4. Are you sure that $file exists and is readable by the Apache (or IIS, depending) user can access it? Use stat... echo '<pre>' . print_r(stat($file), true);
  5. This should help you troubleshoot: while($row = mysql_fetch_array($result)) { $minusdate = (($dayday + $theday) - ($minusdayday + $minusday)); // debug... echo "Row with id " . $row['id'] . " has a minusdate of " . $minusdate . "<br />"; echo "Values were: ((" . $dayday . " + " . $theday . ") - (" . $minusdayday . " + " . $minusday . "))<br />"; echo str_repeat("-", 30) . "<br />"; if ($minusdate == -1) { echo ' <tr> <td>Hello </td> </tr>'; } else { echo ' <tr> <td> <a href=\"http://*********.org/wiki/Image:' . $row['img_name'] . '" target="_blank">' . $row['img_name'] . '</a> </td> <td>' . $row['img_size'] . '</td> <td>' . $row['img_description'] . '</td> <td>' . $row['img_timestamp'] . '</td> <td>' . $minusdate . '</td> </tr>'; } }
  6. mysql_query_add is not a function in php. I think you want something like this: SELECT SUM(SquareFeet) AS total_square_feet FROM sqtable Which you would use like so: $result = mysql_query($query); echo 'Total Square Footage: ' . mysql_result($result, 0, 'total_square_feet');
  7. You can use MySQL... SELECT * FROM tablename WHERE datecolumn > DATE_SUB(datecolumn, 72 HOUR)[/ode]
  8. Try this... <?php $handle = fopen($file, "r"); // assuming you have php5, leave the second parameter null while (($data = fgetcsv($handle, null, ",")) !== FALSE) { if ($rowcnt != 1) { if ($data[7] == "") { $data7 = date("Y-m-d H:i:s",strtotime($inspectDate)); } else { $data7 = date("Y-m-d H:i:s",strtotime($data[7])); } $query = sprintf("INSERT INTO reportdevices VALUES( %d, '%s', '%s', '%s', %d)", $data[0], $data[6], $data[8], $data[7], $_GET['reportID']); $errnct = 0; if ($data[6] != "") { $db->query($query); } else { $devcnt--; } } $rowcnt++; $devcnt++; } I'm not familiar with the fgetcsv command, so my inclination is that the problem is there. You may want to try reading the file into an array (http://www.php.net/file) and looping through it that way, then exploding each line on the commas.
  9. You are using $_SESSION variables, just not directly. And by using namespaces, you are organizing however you want. It would defeat the purpose of using Zend_Session if you don't use their class methods to manipulate the session variables. Using the registry is fairly normal for this. However, you can also create your own static class to act as a repository for your session namespace(s), which can be summoned from any page. If you aren't using the registry (which is a static class to store variables), then you are probably creating multiple instances of the same session namespace, which can lead to confusion and the wrong data being stored / retrieved. Additionally, since locks and such are stored in the instance (not the session variables themselves), if you set a lock in one instance, the other(s) don't know about it and will still modify the value. Ummm, you have to do with with normal sessions anyway...session_start(). Using Zend_Session you're just using "$session = new Zend_Session_Namespace('yournamespace', true)". I'm sorry you think so. Namespacing the session is actually quite good for security purposes. Probably the most common thing to store in a session is whether a user is authenticated or not....e.g. "$_SESSION['authenticated'] = true". Well, imagine you have other applications running on your server that require authentication to access. If they all use the above $_SESSION['authenticated'] to determine if the user should be allowed access, then when the user logs into one, they are logged into them all...even applications that they may not actually have access to (remember session data is separated on the server by domain names...not path to the file requesting session data...so if all of your apps are on www.myserver.com, then they all share a $_SESSION array). If you are using Zend_Session and creating a namespace for each application, then you don't have to worry about that... Application1: $session = new Zend_Session_Namespace('application1', true); if ($session->isAuthenticated == true) { ... } Application2: $session = new Zend_Session_Namespace('application2', true); if ($session->isAuthenticated == true) { ... } This allows you to reuse your authentication methods...you simply pass Zend_Auth the session namespace as it's storage adaptor and it will store the auth data in the namespace. So now, all of your applications can use the same authentication code, without fear of cross application authentication. Application1 bootstrap: // create the namespace for this app $session = new Zend_Session_Namespace('application1', true); // get our authentication, which is an extension of Zend_Auth // The intention here is to write a reusable single class to authenticate your users, say against your // local Active Directory domain, which is then used by all applications...users only have one // username and password for all applications...... $auth = My_General_Purpose_Code_Library_Authentication::getInstance(); // make this applications auth code use the namespace for this application // Zend_Auth will, by default, use the Zend_Auth namespace, but this defeats the purpose // of namespacing to protect against cross application authentication $auth->setStorage($session); Application1 Authentication controller: // This isn't a full example of how to use Zend_Auth, but you get the point... $auth = My_General_Purpose_Code_Library_Authentication::getInstance(); $auth->username = $_POST['username']; $auth->password = $_POST['password']; // do authentication, which stores the result in our namespace $auth->authenticate(); Using the above, you can now check to see if the user is authenticated from any other place in your application Application1 Someother Controller: // get the auth instance $auth = My_General_Purpose_Code_Library_Authentication::getInstance(); if (!$auth->hasIdentity()) { // user is not authenticated $this->_redirect('auth', 'login'); }
  10. It ran out of memory first of all... And the other errors stem from it not being able to delete the file C:\wamp\www\php\include/temp\PEAR\PackageFile\v2\Validator.php
  11. http://www.php.net/curl
  12. The most effective method of preventing SQL injection is to use the db's own escape method... http://www.php.net/mysql_real_escape_string Or, if you're using PDO (which I prefer), then use the prepare method on each statement.
  13. change while(false !== ($FileName=$d->read ())) { if ($FileName !="." && $FileName !="..") { echo "<option value=\"$FileName\">$FileName</option>\n"; } } to while (false !== ( $FileName = $d->read() )) { if ($FileName !="." && $FileName !="..") { $mtime = filemtime($FileName); // check to make sure we're not overwriting a file if ($files[$mtime]) { // if there was already a file modifed at this time, increment // the mtime by one second until we reach a time that doesn't have // a file while ($files[$mtime]) { $mtime++; } } // save the file $files[filemtime($FileName)] = '<option value="' . $FileName . '">' . $FileName . '</option>'; } } ksort($files); echo implode("\n", $files);
  14. SELECT m.name, p.title FROM members m LEFT JOIN posts p ON m.id = p.memberid As Matty said, learn about joins...this is as basic as they come.
  15. if(stristr($message, "DROP TABLE") || stristr($message, "DESCRIBE TABLE") || stristr($message, "SELECT *") || stristr($message, "OR 1 = 1")){ return false; //if possible inject string found } You just eliminated anyone wanting to use it for posing SQL code, as we do here.
  16. why are you wanting to put it into a function?
  17. Not 100% sure what you're trying to accomplish... while ($row = mysql_fetch_assoc($result)) { $short[] = $row['short']; $varshort[] = $$row['short']; } $fields = implode(',',$short); echo $fields . "<br /> "; $values = implode("','",$varshort); echo $values; $sql = "insert into `data` (name, spot, piret, text, $fields) VALUES ('$name', '$spot', '$piret', '$text', '$values' )";
  18. http://www.google.com/search?hl=en&q=javascript+rich+text+editor&btnG=Google+Search
  19. You probably have a syntax error...I'm guessing in conn.php, as the code you have posted seems fine...it would help if you cleaned up your code: <?php require_once('conn.php'); $hosta = $_REQUEST['name']; $hosta1 = $_REQUEST['name']; $q = "SELECT hybridizer, size, price, description from hostajess where hosta_name='$hosta'"; $r = @mysqli_query ($magic, $q) or die(mysqli_error()); if ($r) { echo ' <table align="center" cellspacing="3" cellpadding="3" width="75%"> <tr> <td align="left" width="33.3%">Hybridizer</td> <td align="left" width="33.3%">Size</td> <td align="left" >Price</td> </tr>'; while ($row = mysqli_fetch_array($r,MYSQLI_ASSOC)) { echo ' <tr> <td align="left">' .$row['hybridizer'] . '</td> <td align="left">' .$row['size'] . '</td> <td align="left">' .$row['price']. '</td> </tr>'; } } echo '</table>'; $q = "SELECT description from hostajess where hosta_name='$hosta1'"; $r = mysqli_query ($magic, $q) or die(mysqli_query()); if ($r) { echo ' <table align="center" cellspacing="3" cellpadding="3" width="75%"> <tr> <td align="left">Description</td> </tr>'; while ($row = mysqli_fetch_array($r,MYSQLI_ASSOC)) { echo ' <tr> <td align="justify">' .$row['description'] . '</td> </tr>'; } } echo '</table>'; mysqli_close($dbc); ?>
  20. Did you compare against the manual? http://www.php.net/mysql_connect
×
×
  • 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.