Jump to content

hitman6003

Members
  • Posts

    1,807
  • Joined

  • Last visited

Everything posted by hitman6003

  1. In your first example, where is the value of the variable $id coming from?  If there is no value assigned to it you will not see anything on your page because it only displays html if at least one record was returned from the database. [code]<?php include("dbinfo.inc.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die("Unable to select database"); $query = "SELECT * FROM contacts WHERE id='$id'"; $result = mysql_query($query); $num = mysql_numrows($result); mysql_close(); $i=0; if ($num > 0) { while ($i < $num) { $first=mysql_result($result,$i,"first"); $last=mysql_result($result,$i,"last"); $phone=mysql_result($result,$i,"phone"); $mobile=mysql_result($result,$i,"mobile"); $fax=mysql_result($result,$i,"fax"); $email=mysql_result($result,$i,"email"); $web=mysql_result($result,$i,"web"); ?> <form action="updated.php"> <input type="hidden" name="ud_id" value="<?php echo "$id"; ?>"> First Name: <input type="text" name="ud_first" value="<?php echo "$first"?>"><br> Last Name: <input type="text" name="ud_last" value="<?php echo "$last"?>"><br> Phone Number: <input type="text" name="ud_phone" value="<?php echo "$phone"?>"><br> Mobile Number: <input type="text" name="ud_mobile" value="<?php echo "$mobile"?>"><br> Fax Number: <input type="text" name="ud_fax" value="<?php echo "$fax"?>"><br> E-mail Address: <input type="text" name="ud_email" value="<?php echo "$email"?>"><br> Web Address: <input type="text" name="ud_web" value="<?php echo "$web"?>"><br> <input type="Submit" value="Update"> </form> <?php ++$i; } } else { echo 'No results returned from the database.  Value of ID is: ' . $id; } ?>[/code]
  2. Are you sure that your version of MySQL supports nested queries?  I think the MySQL version must be greater than 4.11, although you will have to check MySQL's documentation to be sure. The error is not in your php...it's in your SQL.
  3. it's the "greater than" comparison operator... [code]if ($name > $something) { do something }[/code] if $name is greater than $something do something.
  4. If you use htmlentities withthe ENT_QUOTES option it should replace all quotes, single and double, with their html equivalent.  That should prevent them from being used to add additional headers. [code]$msg = htmlentities($msg, ENT_QUOTES);[/code]
  5. use the explode function. http://www.php.net/explode [code]$foo = "1,2,3,4,5"; $foo = explode(",", $foo);[/code]
  6. I think he is referring to someone forcing additional mail headers...for example using his mail line from above: [code]mail ("my_email_address", "Hardcoded subject", "$msg");[/code] if the value of $msg is: [code]Hi from your friend!!!", "-f somemail@address.com[/code] When the mail is sent by the mail function it would appear to be from somemail@address.com, not from the mail server.
  7. don't use the !... [code]if (isset($ipaddress)) {   $query="UPDATE visitor_log SET status = '1' WHERE ipaddress ='".$ipaddress."'";   $result=mysql_query($query); }[/code] You're saying "If $ipaddress is not set" by using the !.
  8. I think he means one of the WYSIWYG text editors, such as TinyMCE or FCKeditor.
  9. add / subtract the number of seconds in 12 hours (43200) to your time value... [code]$current_time = time() - 43200;[/code]
  10. Reverse your urldecode / unserialize functions... [code]else{   $testCart = unserialize(urldecode($_SESSION['testCart'])); }[/code] Also, urlencode shouldn't be necessary...the session data is stored on the server...only a session id is sent to the user (via a cookie when possible, or the url if cookies are disabled).
  11. it will update all reacords in the database that have no value for ip address.
  12. Use realpath and pass the result of that to your function. http://www.php.net/realpath [code]echo date("Y-m-d H:i:s", filemtime(realpath("../somefile.txt")));[/code]
  13. What code are you using? Are you using the full path to the file or a relative path?  On some servers I have had problems using a relative path, but it works with the full path.
  14. Just eliminate the HEREDOC syntax then: [code]  echo '   <div> <!-- left side -->   <img src="' . $row['pic_url'] . '" alt="" /><br />   <p>' . $description . '</p>   </div>   <div> <!-- right side -->   <p>' . $row['name'] . '</p>   <p>' . $row['price'] . '</p>   </div>';[/code]
  15. the "EOF;" should not be tabbed over...it should be the first and only thing on the line.
  16. [code]<?php $button_text = array('Make it so','What's the score?','Happy Feet'); echo '<input type="submit" name="submit" value="' . $button_text[array_rand($button_text)] . '">'; ?>[/code] You may have to move the array_rand function out from between the brackets ( [ and ] ), but the idea is the same.
  17. Use an UPDATE query... [code]UPDATE tablename SET field1 = 'newvalue', field2 = 'newvalue' WHERE idfield = 'a value'[/code]
  18. Set "$metadata" equal to something.... Change: [code]function extract_mff_files($filename,&$global,&$local) { $metadata;[/code] to [code]function extract_mff_files($filename,&$global,&$local) { $metadata = "";[/code] Or $metadata = array();
  19. Are you and pyro sitting next to eachother? http://www.php.net/substr
  20. Make the serialization of the cart the last thing you do before outputting data to the user.  Then any other functions applied to the cart are always included, rather than using an outdated cart, or being applied to a cart that has already been serialized and saved in the session.
  21. Just use mysql: [code]SELECT id, DATEDIFF(columnname, NOW()) AS time_in_db FROM tablename[/code] Then loop through the results: [code] $result = mysql_query("SELECT id, DATEDIFF(columnname, NOW()) AS time_in_db FROM tablename"); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {   if ($row['time_in_db']  > 30) {     $ids_to_remove[] = $row['id'];   } } $query = "DELETE FROM tablename WHERE id IN('" . implode("', '", $ids_to_remove) . "')"; mysql_query($query) or die(mysql_error()); [/code] You may have to modify the DATEDIFF a little depending on if it's an actual timestamp column or not.  If not, just use DATE_FORMAT and other mysql functions. http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html
  22. The html: [code]<input type="radio" name="emailto" value="me"> Send to my email<br /> <input type="radio" name="emailto" value="you"> Send to someone else[/code] the php: [code]echo $_POST['emailto'];[/code]
  23. In perl it is refering to the opponent object's winstreak value.  In your perl script you say that the $data->{rating}, $opponent->{winstreak} and $opponent->{rating} are coming from the database...you need to execute those queries to get the results in another object...for this example I'll call them "data_query" and "opponent_query". [code]//execute the data_query $data_result = mysql_query($data_query); //retrieve the first object returned...using mysql_fetch_array or mysql_fetch_assoc would work here too $data = mysql_fetch_object($data_result); //repeat for opponent $opp_result = mysql_query($opponent_query); $opponent = mysql_fetch_object($opp_result); #Insert game data into the gametable $games_query = "INSERT INTO $gametable (user1, user2, yourname, opponentname, score, reportdate, time, comment, rating1, rating2, streak) " .   "VALUES ('$username','$opponent','$yourname','$opponentname','$score','DATE()','localtime()','$comment','" . $data->rating ."','" . $opponent->rating . "','" . $opponent->winstreak . "')"; $sql_games = mysql_query($games_query);[/code]
  24. The easiest way I've found: [code]$colors = array( 'FFFFFF' => 'White', '87CEFA' => 'Light sky blue', 'FFA500' => 'Orange', '8B4513' => 'Saddle brown ', 'C0C0C0' => 'Silver', 'FA8072' => 'Salmon', 'CD853F' => 'Peru', 'D2B48C' => 'Tan', 'FF69B4' => 'Hot pink' ); $color_select = ""; foreach ($colors as $hex => $color) { $color_select .= ' <option value="' . $hex . '"'; if ($hex == $_POST['bgcolor']) { $color_select .= ' selected'; } $color_select .= '>' . $color . '</option>'; } ?> <tr> <td valign=top><font face="Arial">Background Color:</font></td> <td> <select name="bgcolor" size="1"> <?php echo $color_select; ?> </select> </td> </tr>[/code]
×
×
  • 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.