-
Posts
1,807 -
Joined
-
Last visited
Posts posted by hitman6003
-
-
The variable $TestArray is outside the scope of the method of your class...
-
I have a table in my database and one particular column can have pretty lengthy values
How long is "pretty lengthy"?
when retrieving the data from the database and displaying it, the value is always cut off at a random place, even though the data is intact in the database. Is there any limit to how much data either mssql_fetch_row or echo/print can hold?
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.
-
They should be "elseif" not "else if"
Either way works...
In PHP, you can also write 'else if' (in two words) and the behavior would be identical to the one of 'elseif' (in a single word) -
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);
-
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>'; } }
-
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');
-
You can use MySQL...
SELECT * FROM tablename WHERE datecolumn > DATE_SUB(datecolumn, 72 HOUR)[/ode]
-
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.
-
using $_SESSION variables and organizing your data however you want
You are using $_SESSION variables, just not directly. And by using namespaces, you are organizing however you want.
Zend wants you to use their syntax to set session variables in separate sub-arraysIt would defeat the purpose of using Zend_Session if you don't use their class methods to manipulate the session variables.
I have been forced to commit those session variables to Zend_Registry values (have to be set for each page load, but are available to all files within your M/V/C framework).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.
So basically, I now have to initialize the session variables and commit them to Zend_Registry values for EVERY page load via the bootstrap file.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)".
This is retarded. Absolutely retarded.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'); }
-
It ran out of memory first of all...
Allowed memory size of 8388608 bytes exhaustedAnd the other errors stem from it not being able to delete the file C:\wamp\www\php\include/temp\PEAR\PackageFile\v2\Validator.php
Warning: unlink(C:\wamp\www\php\include/temp\PEAR\PackageFile\v2\Validator.php) [function.unlink]: Permission denied -
-
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.
-
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);
-
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.
-
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.
-
why are you wanting to put it into a function?
-
How do you want them sorted?
-
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' )";
-
-
What is that HTML Textarea box called?
Ummm, a textarea.
What do you want to do with it?
-
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); ?>
-
-
use single quotes
value='a"b'
-
[SOLVED] Is there a limit to string length of an array, or to an echo/print?
in PHP Coding Help
Posted
Have you tried echoing out the variable directly?