Jump to content

hitman6003

Members
  • Posts

    1,807
  • Joined

  • Last visited

Posts posted by hitman6003

  1. 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.

  2. 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>';
    }
    }

  3. 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');

  4. 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.

  5. 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-arrays

     

    It 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');
    }

     

  6. It ran out of memory first of all...

     

    Allowed memory size of 8388608 bytes exhausted

     

    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

     

    Warning: unlink(C:\wamp\www\php\include/temp\PEAR\PackageFile\v2\Validator.php) [function.unlink]: Permission denied
  7. 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);

  8. 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.

  9. 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);
    
    ?>

×
×
  • 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.