Jump to content

kicken

Gurus
  • Posts

    4,704
  • Joined

  • Last visited

  • Days Won

    179

Everything posted by kicken

  1. You have to use the var keyword to limit the scope. When you use a variable, JS will walk up the scope chain to find it. If it gets up to the global scope before finding it, it will create it there. Using the 'var' keyword will declare the variable at that scope level so JS will find it and not look further. Though not really technically correct, you can think of it as: Variables are global by default, and you use 'var' to make them local.
  2. You have no field in your form named submit. You named it loginsubmit: <input type="submit" value="" class="submit" name="loginsubmit" />
  3. http://www.nipnotes.com/styles/forms.css Lines 15-17: That is why it does not display.
  4. You should write to a file without any PHP code, then prepending the contents would be simply: $logFile = 'log.txt'; $newContents = 'blah blah blah'; $oldContents = file_get_contents($logFile); file_put_contents($logFile, $newContents, $oldContents);
  5. Oracle supports sequences. It's been a long time since I used it, but if these google results are accurate still it'd be something like: first create the sequence CREATE SEQUENCE jobAutoInc INCREMENT BY 1 START WITH 1; Then, whenever you insert: INSERT INTO jobs (jobId, Name, whateverElse) VALUES (jobAutoInc.NEXTVAL, 'blah', 'bleh'); If you need the id for later use in your code, you can first do a SELECT jobAutoInc.NEXTVAL FROM DUAL and grab the results, then use it in your insert and wherever else you need it.
  6. For one, mysql_query doesn't return an object, but your trying to use it's result as an object. Second, your $result variable is only going to contain the data for the last select, all the rest are ignored. Third, you can do everything in a single query rather than using a loop like your doing. Put all the id's in an IN clause in the query.
  7. <?php if(isset($_POST['image_id'])){ foreach ($_POST['image_id'] as $file_id=>$actions){ if (isset($actions['save']){ /// } if (isset($actions['delete'])){ /// } if (isset($actions['rotate'])){ /// } } } Your $_POST['image_id'] is an array where each key is the file id, and the value is an array of actions. You can just loop over it using a standard foreach loop, including a variable for the key. Then you just test which actions are set and do whatever needs done for each action.
  8. Because you can't embed an if condition into a string like that, and you don't echo vars into a string. Move your condition outside and set a variable, then embed that variable in the string. As for your echo, just concatenate the variable. if ($row['customertitle'] != '') { $name = $row['customertitle'].' '.$row['customerlastname']; } else ( $name = $row['customerfirstname']; } $body = " Dear ".$name." <BR> This is a test. ".$_SERVER['SERVER_ADDR']." <BR> ".$accessinformation." ";
  9. Google for a bbcode parser library. It wll parse out sequences like that. Save yourself the trouble of having to try and code it yourself.
  10. Just as a quick side note about your code: if (isset($cond)) { $query .= " WHERE {$cond}"; } isset() is probably not what you want. isset will be true pretty much always for a parameter, unless it's value is null. If you want to check that it's got a value that is not the empty string, use !empty() or just if ($var). if (is_array($rows)) { if (isset($rows) && $rows != "*") { Checking isset() is a bit pointless there. if it is an array, it is set. Also, as mentioned above isset would only return false if you pass null, not if you pass say an empty string or empty array. Also, if $rows is an array, then it is guaranteed to != '*'. Perhaps you ment $rows[0] != '*'? function select($table, $rows = array('*'), $cond = "") { $query = "SELECT {$rows} FROM `{$table}`"; if ($cond){ $query .= " WHERE {$cond}"; } if (is_array($rows) && $rows[0] != '*') { foreach ($rows as $v) { print_r($v); } } //return mysql_query($query); }
  11. You need to put quotes around the value of your onclick attribute. Also, depending on the datatype of your variables, you may need quotes around them as well. echo '<a onclick="vieww_det('. $arr[$i].', '.$arr[$j].')">View Details</a>';
  12. Your missing your ; at the end of the echo statement. It looks like maybe you just transposed the quote and the semi-colon.
  13. Are you sure the error is not in say your header.php or footer.php files?
  14. Perhaps this is what you want? <?php ob_start(); require(dirname( __FILE__ ) . '/../../folder/file.php'); $output = ob_get_clean(); $message = "<HTML> email body section A ".$output." email body section B </HTML>"
  15. You have to create the function. Ex: function mySortCmp($a, $b){ ///..do any comparisons here //..return -1 if $a is less than $b //..return 0 if $a is the same as $b //..return 1 if $a is greater than $b } usort($arr, 'mySortCmp'); PHP will call your function several times, each time it will pass two elements of the array ($a and $b). Your function has to compare them and return a value which is either less than 0, 0, or greater than 0...depending on how $a compares to $b. So, create a function which will compare your elements, first by the add_date then by the add_time.
  16. usort() is the function you want. It requires a callback which will compare the two array elements. Seeing as you said you already tried it, I can only assume you attempted to make that callback function. Post what you tried and we can help you fix it.
  17. if (strpos($str, ' ')===false){ //no space $str = substr_replace($str, ' ', -3, 0); //insert space }
  18. disable javascript.
  19. You never defined $row, so it doesn't exist. If you'd have had your error_reporting set to E_ALL you would have gotten a notice about it. while($info = mysql_fetch_array( $data )) { -------^^^^ You defined $info as the variable holding your results.
  20. The function appears to be expecting a unix timestamp value, but your providing it something else. You need to convert the value from your database into a timestamp prior to passing it to the function. strtotime will probably work.
  21. unless for some reason you need to have the fields declared as properties, I would just handle it via __get and __set magic methods: abstract class DBTable { protected static $fields=array(); private $values; public function __construct(){ $this->values=array(); foreach (static::$fields as $f){ $this->values[$f]=null; } } public function __get($nm){ if (!in_array($nm, static::$fields)){ throw new Exception('Field '.$nm.' does not exist.'); } return $this->values[$nm]; } public function __set($nm, $v){ if (!in_array($nm, static::$fields)){ throw new Exception('Field '.$nm.' does not exist.'); } $this->values[$nm] = $v; } } class Users extends DBTable { protected static $fields=array('username', 'password', 'email', 'firstname', 'lastname'); //... } class Post extends DBTable { protected static $fields=array('subject', 'content', 'by'); }
  22. When you say recursive print, what do you mean? using print_r or var_dump? As for the one line thing, I assume your talking about setting the keys/values inside the array() construct. It doesn't have to be on one line: $returnInfo = array( 'totalWords' => $totalWords, 'uniqueWords' => count($uniqueWords), 'positiveWords' => $positiveWords, 'negativeWords' => $negativeWords, 'rating' => $mappedrating ); return $returnInfo; Doesn't really matter one way or the other though, just a matter of preference.
  23. Sounds to me like rather than grab a list of users, then loop that and get privcy settings you should work that into your initial query for the list of users. Not sure how your tables are setup, but something like this is what i mean: SELECT * --the fields you need instead FROM users u INNER JOIN privcy_settings ps ON ps.UserId=u.UserId WHERE ps.VisibleToPublic=1 A query that returns your list of users already filtered by whether they are visible or not.
  24. How are you determining how many queries are being run?
  25. That function is only going to run one query. Check the rest of the code to see how many times your calling that function, and reduce the number of calls.
×
×
  • 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.