Jump to content

hitman6003

Members
  • Posts

    1,807
  • Joined

  • Last visited

Everything posted by hitman6003

  1. mysql_connect is a function, not a method inside of an object. <?php $host = "localhost"; $user = "xx"; $password = "xx"; $database = "xx"; $db = mysql_connect($host, $user, $password) or die(mysql_error()); mysql_select_db($database, $db) or die(mysql_error()); ?> Of course, that assumes that you are not using a database abstraction class and you have created an object named "mysql" and you are calling a method called "connect"....if you are trying to do that, then you need a "$" in front of the "Mysql".
  2. hitman6003

    Ranks

    See this page: http://arjen-lentz.livejournal.com/55083.html
  3. hitman6003

    Ranks

    Think this might work. Barand will be of more help as he is scary good at SQL... SELECT COUNT(id) AS rank FROM ( SELECT (characters / lines) AS avg_chars FROM table_name ) WHERE avg_chars > ( SELECT (characters / lines) FROM table_name WHERE username = 'user' ) May be thrown off by ties.
  4. create $ListInformation as an array at the start so you always know it is one...and you don't need to use array_push.... This will give you the same result you currently have: $ListInformation = array(); while ... { $ListInformation[]['listid'] = $result->fields['id']; }
  5. $query = "SELECT *FROM jobs DESC LIMIT 1, 1"; //selects the second item
  6. You can use wmi to do some things on remote windows servers (but only from a windows box).
  7. Look at what values are stored in $_SERVER. http://us2.php.net/manual/en/reserved.variables.php#reserved.variables.server
  8. Is there any php in your includes? If not, try echoing them: echo file_get_contents("css/layout1.php");
  9. if $orderid returned == 0, that evaluates to false...use ===, and also double check you are getting the expected return values (i.e. a positve integer)
  10. It can be done two ways (that I know of)...mod_rewrite or by making the .html extension equate to a php script. Just like you have to tell apache (or IIS) that ".php" means to use the php interpreter, you can tell it to use the php interpreter for .html files as well.
  11. For comparison, here is the code and results I used / got: function microtime_float() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } $heredoc_times = array(); $echo_times = array(); for ($i = 0; $i < 10000; $i++) { $start = microtime_float(); echo <<<LINE test test test $start test test test LINE; $heredoc_times[] = (microtime_float() - $start); } for ($i = 0; $i < 10000; $i++) { $start = microtime_float(); echo " test test test $start test test test "; $echo_times[] = (microtime_float() - $start); } echo '<pre> HEREDOC: Total: ' . array_sum($heredoc_times) . ' Average: ' . (array_sum($heredoc_times) / count($heredoc_times)) . ' echo: Total: ' . array_sum($echo_times) . ' Average: ' . (array_sum($echo_times) / count($echo_times)); HEREDOC: Total: 0.210633277893 Average: 2.10633277893E-5 echo: Total: 0.221266508102 Average: 2.21266508102E-5 I'm using a Core2 Duo Laptop with 2 GB RAM running the latest version of XAMPP (PHP 5.2.5, Apache 2.2.6).
  12. You can get the album and song data at the same time, then put it into a multidimensional array: $query = "SELECT ID, album, picture, title FROM `songlist` WHERE artist = '" . urldecode($artist) . "' ORDER BY album ASC, title ASC" $database->setQuery($query); while ($row = $database->loadRow()) { $data[$row->album]['tracks'][$row->ID] = $row->title; if (!$data[$row->album]['picture']) { $data[$row->album]['picture'] = $row->picture; } } print_r($data); Then you should be able to loop through the array and format your data for display: echo ' <table>'; foreach ($data as $album => $info) { echo ' <tr> <td><img src="' . $info['picture'] . '" /></td> <td>'; foreach ($info['tracks'] as $track_id => $title) { echo '<a href="somelink.php?track_id=' . $track_id . '">' . $title . '</a><br />' . "\n"; } echo ' </td> </tr>'; } echo ' </table>'; Hopefully you can use this to accomplish what you are wanting.
  13. Since the notice was saying that at least one of those elements was empty, then your querying for one of three things: a blank username and password, a blank username with a password, or a username with a blank password...depending on which variable is empty (username or password). Echo your query before it's executed to make sure that it is populated with the values you are expecting.
  14. You aren't actually doing the join... SELECT b.oid, b.amazonuk, s.title FROM Booklinks b JOIN Submit s ON b.username = s.username WHERE b.amazonuk != '' AND b.username = '$username' You could also do it using the "shorthand" syntax: SELECT b.oid, b.amazonuk, s.title FROM Booklinks b, Submit s WHERE b.username = s.username AND b.amazonuk != '' AND b.username = '$username'
  15. phreeek's solution will prevent the notices from being displayed, however they are "just" notices, not errors. Php is telling you that you are trying to address an array element that doesn't exist.
  16. No, but it's considered impolite to do so, and if myspace doesn't like that they could block people from doing so when the referrer is your web site. Yes, there are scripts...I don't know of any off hand. The basic principle is to use a command like file_get_contents to retrieve the image, then use the GD commands to manipulate it. http://www.php.net/file_get_contents http://www.php.net/gd
  17. $interest_rate should be expressed as a portion of 1...i.e. 5% interest would be ".05".
  18. just use str_replace: <?php $search = 'a'; $body = 'apple'; $body = str_replace($search, '<span class="colored">' . $search . '</span>', $body); echo $body; ?>
  19. $username is a string and should be in single quotes in your query: $sql = "SELECT Booklinks.oid,Booklinks.amazonuk,Submit.title FROM Booklinks,Submit WHERE Booklinks.amazonuk != '' AND Booklinks.username='$username'";
  20. Not sure about oscommerce, but if I remember high school math correctly, interest can be calculated as so: $total_with_interest = $price * pow((1 + $interest_rate), $years_financed); Course, i could be completely wrong....
  21. Use mysql_error to get the error that occurs during your query: change: $result = mysql_query("SELECT * FROM Categories ORDERBY `cat_id` ASC"); to $result = mysql_query("SELECT * FROM `Categories` ORDER BY `cat_id` ASC") or die(mysql_error());
  22. Yes...for example, say you have $_POST like this: $_POST['name'] = 'abcde'; $_POST['pass'] = 'secret'; When you "extract" $_POST, it will create variables named "$name" and "$pass" that are equal to their $_POST equivalents.
  23. use the shell command "which"... which gpg It will tell you where in your path the gpg command is located at. If it returns as not found, then make sure it's installed. If it's not in a common location (/usr, /usr/local, /usr/sfw, /opt, etc...) then you may have to use the find command (IF you are sure that gpg is installed)
×
×
  • 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.