Jump to content

hitman6003

Members
  • Posts

    1,807
  • Joined

  • Last visited

Everything posted by hitman6003

  1. You could do something like this: [code]$class = "td1"; foreach ($result as $row) { $class = ($class == "td1") ? "td2" : "td1"; echo '<td class="' . $class . '">some data</td>'; }[/code] Or, if your're set on using a function: [code]function eitan() { global $bully; $bully = ($bully == 1) ? 2 : 1; echo $bully; } $bully = 1; foreach ($result as $row) { echo '<td class="td' . eitan(). '">some data</td>'; }[/code]
  2. [code] echo '<table>   <tr>     <td>' . $sys->doMostPlayed() . '</td>     <td>' . $sys->doNewestgames() . '</td>   </tr> </table>'; [/code] Or use css boxes if that's your bag.
  3. Use a SUM query... [code]SELECT SUM(gamesplayed) as total_games_played_for_site FROM games[/code]
  4. Your insert query is generating an error...change: [code]mysql_query($query);[/code] to [code]mysql_query($query) or die(mysql_error());[/code] to see what it is.... Look at your table creation, you have these fields: id first last email web.  Now look at your insert statement: [code]INSERT INTO contacts VALUES('John','Smith','johnsmith@somewhere.com','http://www.somewhere.com')[/code] You have five columns in the table, but you are only inserting four.  Change your query to: [code]INSERT INTO contacts VALUES('', 'John','Smith','johnsmith@somewhere.com','http://www.somewhere.com')[/code] or [code]INSERT INTO contacts (first, last, email, web) VALUES ('John', 'Smith', 'johnsmith@somewhere.com', 'http://www.somewhere.com')[/code]
  5. Works fine for me. Are you getting any error messages?  What result are you getting?
  6. hitman6003

    fsockopen

    Why are you only opening a socket to a different web page and not doing anything with it? [quote]is there a better way of doing this?[/quote] Yes, use fopen, file, file_get_contents, etc. [quote]Or am I simply not using it correctly?[/quote] Yes, and no.  http://www.php.net/fsockopen.  Specifically the variable that is passed to the function that returns error messages.
  7. It's a string so you have to put it in single quotes: [code]$result = mysql_query("SELECT * FROM Usagers where Username = '" . $_Post['Username']) . "'";[/code]
  8. Use the concatenation operator ( . - a period): [code]$result = mysql_query("SELECT * FROM Usagers where Username = " . $_Post['Username']);[/code]
  9. The manual states: [quote]The query string should not end with a semicolon.[/quote] http://www.php.net/mysql_query#AEN116010
  10. Use google. http://sitten-polizei.de/php/reflection_api/docs/language.reflection.class.reflection_property.html
  11. you also have a lot of extra echo statements that are unnecessary. [code]$con = mysql_connect(***, ***, ***) or die(mysql_error()); mysql_select_db("database", $con); $result = mysql_query("SELECT * FROM Usagers"); while($row = mysql_fetch_array($result)) { echo " <table border='0'> <tr> <td>Nom Usager : </td> <td>" . $row['Username'] . "</td> </tr> <tr> <td>Nom :  </td> <td>" . $row['Nom'] . "</td> </tr> <tr> <td>Prenom :  </td> <td>" . $row['Prenom'] . "</td> </tr> <tr> <td>Age :  </td> <td>" . $row['Age'] . "</td> </tr> <tr> <td>Adresse :  </td> <td>" . $row['Adresse'] . "</td> </tr> </table>"; }[/code]
  12. is mail set up on your web server? If it's not, then you need to set it up, or, as the error states, point it to a mailserver to use in php.ini. If it is, then something is wrong with it.
  13. http://www.phpfreaks.com/tutorials/65/0.php
  14. Use phpmailer. http://phpmailer.sourceforge.net/
  15. if the keys always have the same text at the beginning..."item number" and "item qty", then this would work: [code]foreach ($array as $key => $value) { if (substr($key, 0, 11) == "item number") { $data[substr($key, 11, strlen($key)]['item_number'] = $value); } else if (substr($key, 0, 8) == "item qty") { $data[substr($key, 8, strlen($key)]['item_qty'] = $value; } }[/code] Which will generate an mulidimensional array that you can use however you like.
  16. I would recommend looking at this page.  It is much easier to post and retrieve data this way than the way you are doing it. http://us3.php.net/manual/en/wrappers.http.php#AEN271674
  17. http://www.phpfreaks.com/tutorials/129/0.php
  18. $anotherAr[0] may be creating a reference link to the original... look for the &= "assignment" operator.
  19. See the parse_ini_file function. http://www.php.net/parse_ini_file As far as it being on another server, yes, in a very round about way.  If it's another web server, you could use the ftp functions to get and put the file.  If it's a server on an intranet, you could configure it to pull from that server's shared directories, assuming the permissions were set correctly.  Or, you could use WebDAV if the server has it.
  20. If the values will always be paired like that (itm1, quan1, itm2, quan2, etc) then you could use something like this: [code]for ($x = 0; $x < count($array); $x + 2) { $data[$array[$x]] = $array[$x + 1]; }[/code] But if the values are ever in a different order, it wouldn't work.  It would also be inaccurate if there were an odd number of array elements...for example if an item with a quantity of 0 didn't create an array element.
  21. A while loop works well here. [code]<?php $input = array( array( 'filename' => 'home.html', 'title' => 'home page' ), array( 'filename' => 'products.html', 'title' => 'products' ), array( 'filename' => 'promotions.html', 'title' => 'promotions' ), array( 'filename' => 'private.html', 'title' => 'private' ), array( 'filename' => 'contact.html', 'title' => 'contact' ), array( 'filename' => 'prices.html',             'title' => 'prices' ) ); function go($input) { $data = array(); foreach ($input as $item) { //determine the highlighted portion if (!array_key_exists(substr($item['title'], 0, 1), $data)) { $x = substr($item['title'], 0, 1); $data[$x] = ' <li><a href="' . $item['filename'] . '" accesskey="' . $x . '"><em>' . $x . '</em>' . substr($item['title'], 1, strlen($item['title'])) . '</a></li>'; } else { $x = substr($item['title'], 0, 1); $y = 1; while (array_key_exists($x, $data)) { $y++; $x = substr($item['title'], 0, $y); } $data[$x] = ' <li><a href="' . $item['filename'] . '" accesskey="' . $x . '"><em>' . $x . '</em>' . substr($item['title'], $y, strlen($item['title'])) . '</a></li>'; } } return '<ul>' . implode("", $data) . '</ul>'; } echo '<style>em { font-weight: bold; }</style>'; echo go($input); ?>[/code]
  22. [quote author=kenrbnsn link=topic=115710.msg471228#msg471228 date=1164079733] Why make it complicated? [/quote] I agree...that's why my first suggestion was to use strtotime without modifying the string and see if it works...apparently that got overlooked.........
  23. Just use an if statement when you loop through the results: [code]$file = file($filename); foreach ($file as $Line) {   if (trim($line) != "") {     //do your operations   } }[/code]
  24. You aren't echoing out anything: [code]echo convert("Jun 2, 2006, 9:13pm");[/code]
  25. [quote]Can anyone post quick solution?[/quote] Not without knowing what your soap library is doing.
×
×
  • 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.