Jump to content

hitman6003

Members
  • Posts

    1,807
  • Joined

  • Last visited

Everything posted by hitman6003

  1. change: [code]$result = mysql_query("SELECT * FROM Market");[/code] to: [code]$result = mysql_query("SELECT * FROM Market") or die(mysql_error());[/code] to see what the error is.
  2. Multiply by -1. [code]$x = 10; echo 'x = ' . $x . "<br>-x = ' . $x * -1; $y = -20; echo 'y = ' . $y . "<br>-y = ' . $y * -1;[/code]
  3. Here is a function that will do what you want: http://us2.php.net/manual/en/function.readdir.php#64613 Make sure that the directory has the correct permissions for the web server user to be able to read from it.  For example, I have a script that does the same thing on an IIS6 server...reads the files in a directory that is stored on a network share.  However, the IUSR_servername user doesn't have permissions on the directory, and can not access it.  I have to run that script as my username, because I have permissions on the directory.
  4. I must not be paying attention today..... change: [code]echo "<td align=\"center\"><font face=\"Arial\" size=\"2\">" . echo $row['Player'] . "</font></td>";[/code] to: [code]echo "<td align=\"center\"><font face=\"Arial\" size=\"2\">" . $row['Player'] . "</font></td>";[/code] In all of the other, equivalent, statements as well.
  5. You have one too many opening curly braces ( { ) after the while statement. [code]<?php require_once("connection.php"); if(isset($_POST['id'])){ $id = $_POST['id']; mysql_select_db("scores"); $result = mysql_query("SELECT * FROM scores WHERE id='$id';"); while($row = mysql_fetch_array($result)) { echo ' <form action="update" method="POST"> <input type="hidden" name="id" value="' . $row['id'] . '"> Author: <input type="text" name="home" value="' . $row['home'] . '"> <br /> <input type="text" name="away" value="' . $row['away'] . '"> <br /> <input type="text" name="homescore" value="' . $row['homescore'] . '"> <br /> <input type="text" name="awayscore" value="' . $row['awayscore'] . '"> <br /> <input type="text" name="date" value="' . $row['date'] . '"> </font><br /> <table align="center" width="800"> <tr> <td align="center"><input type="submit" value="Update Form"></td> </tr> </table> </form>';       }   } } ?>[/code]
  6. [quote]I've tinkered with this and have come to the conclusion that I can't do it using this type of 'foreach' method. Or, can I? Would I need to switch from mysql_fetch_row to mysql_fetch_array then extract the array to set field variables and lay out the HTML manually and insert the $vars into the respective <td>'s? [/quote] I have no idea what that means. Anyway, you should pass the id in the url... [code]<?php $sql=("SELECT * FROM phase_one"); $results=mysql_query($sql); $row = mysql_fetch_row($results); $num_rows = mysql_num_rows($results); if ($num_rows == 0) { echo " <font class='bodytext'> <center>We are sorry. The lot information is unavailable at this time.<br /> Please contact us for details on available lots.<br />"; } else { echo " <table width='650' border='0'> <tr> <th>Unit No.</th> <th>Location</th> <th>View</th> <th>Sale Price</th> <th>&nbsp;</th> <tr>"; while ($a_row = mysql_fetch_row( $results )) { echo " <tr> <td style=\"text-align: center;\">" . $a_row['unitid'] . "</td> <td style=\"text-align: center;\">" . $a_row['location'] . "</td> <td style=\"text-align: center;\">" . $a_row['View'] . "</td> <td style=\"text-align: center;\">" . $a_row['price'] . "</td> <td style=\"text-align: center;\"><a href=\"contact.php?id=" . $a_row['unitid'] . "\">Contact</a></td> </tr>"; } print "</table>\n"; ?>[/code] Then on the contact.php, use $_GET['id'] to retrieve the number from the URL.
  7. http://www.google.com/search?hl=en&q=php+blog+tutorial&btnG=Google+Search Take your pick.
  8. Try this one: http://www.dhtmlgoodies.com/index.html?whichScript=dhtmlgoodies_menu2 It uses an unordered list, but it also uses js to make it compatible with IE without using some crazy hacks the only work half the time.
  9. [quote]You need to escape the double quotes in your echo statements if you are going to enclose them in double quotes.[/quote] [code]echo "<td align="center"><font face="Arial" size="2">" . echo $row['Player'] . "</font></td>";[/code] should be" [code]echo "<td align=\"center\"><font face=\"Arial\" size=\"2\">" . echo $row['Player'] . "</font></td>";[/code] All of the other echo statements should be the same way...you have to escape them. Same holds true for this line: [code]<table border='1'>[/code] Because it's in an echo statment that encloses the echoed text in single quotes, they must be escaped or they will cause an error. [code]<table border=\'1\'>[/code]
  10. See if this works for you: [code]<?php $link1 = "http://radio.weblogs.com/0001011/"; $link2 = "http://radio.weblogs.com/0001011/2005/11/27.html#a11433"; $link3 = "http://scobleizer.wordpress.com/"; $link4 = "http://scobleizer.wordpress.com/feed/"; $link5 = "http://radio.weblogs.com/0001011/2005/11/27.html#a11433"; $link6 = "http://scoblecomments2.scripting.com/comments?u=1011&amp;p=11433&amp;link=http%3A%2F%2Fradio.weblogs.com%2F0001011%2F2005%2F11%2F27.html%23a11433"; $text = ' <?xml version="1.0" ?> <rss version="2.0"> <channel> <title>Scobleizer: Microsoft Geek Blogger</title> <link>' . $link1 . '</link> <description>Robert Scoble\'s look at geek and Microsoft life.</description> <language>en-us</language> <copyright>Copyright 2005 Robert Scoble</copyright> <item> <title>PLEASE SUBSCRIBE TO MY NEW BLOG</title> <link>' . $link2 . '</link> <description> <p> Hello, we know you\'re still subscribed to this blog (9,000 of you are on Bloglines, for instance). So, please unsubscribe from this blog and come over and visit me in my new home at <a href="' . $link3 . '">' . $link3 . '</a> </p> <p> My new RSS feed is here: <a href="' . $link4 . '">' . $link4 . '</a> </p> <p>I have permanently moved over there, so please do come and visit!</p> </description> <guid>' . $link5 . '</guid> <pubDate>Sun, 27 Nov 2005 13:44:16 GMT</pubDate> <comments>' . $link6 . '</comments> </item> </channel> </rss>'; if ($fp = fopen("aaaa.xml","w")) { fwrite($fp,$text); fclose($fp); echo "XML has been written.  <a href=\"aaaa.xml\">View the XML.</a>"; } else { echo "could not save"; } ?>[/code]
  11. You need to escape the double quotes in your echo statements if you are going to enclose them in double quotes. You aren't echoing out the html that is inside of the php.  For example: [code]echo "</table>"; </td> </tr> </table>[/code] Should be, at a minimum like this: [code]echo "</table> </td> </tr> </table>";[/code] this should work overall: [code]<?php mysql_select_db("fmprotasy_reg", $con); $result = mysql_query("SELECT * FROM Market"); echo ' <table border="0" bgcolor="#FF8C00" width="100%" cellpadding="10"> <tr> <td width="100%" valign="top" style="border-style: solid; border-width: 2"> <p align="left"><b><font face="Arial" size="2">Transfer Market</font></b> </td> </tr> </table> <table border="0" bgcolor="#FF8C00" width="100%" cellpadding="10" height="15"> <tr> <td width="100%" valign="top" height="1" style="border-style: solid; border-width: 2"> <table border='1'> <tr> <th>Player</th> <th>Club</th> <th>Position</th> <th>Age</th> <th>Ka</th> <th>Ta</th> <th>Pa</th> <th>Sa</th> <th>Type</th> <th>Price</th> </tr>'; while($row = mysql_fetch_array($result)) {   echo "<tr>";   echo "<td align="center"><font face="Arial" size="2">" . echo $row['Player'] . "</font></td>";   echo "<td align="center"><font face="Arial" size="2">" . echo $row['Team'] . "</font></td>";   echo "<td align="center"><font face="Arial" size="2">" . echo $row['Position'] . "</font></td>";   echo "<td align="center"><font face="Arial" size="2">" . echo $row['Age'] . "</font></td>";   echo "<td align="center"><font face="Arial" size="2">" . echo $row['GK'] . "</font></td>";   echo "<td align="center"><font face="Arial" size="2">" . echo $row['DEF'] . "</font></td>";   echo "<td align="center"><font face="Arial" size="2">" . echo $row['MID'] . "</font></td>";   echo "<td align="center"><font face="Arial" size="2">" . echo $row['ATT'] . "</font></td>";   echo "<td align="center"><font face="Arial" size="2">" . echo $row['Type'] . "</font></td>";   echo "<td align="center"><font face="Arial" size="2">" . echo $row['Price'] . "</font></td>";   echo "</tr>"; } echo " </table> </td> </tr> </table>"; mysql_close($con); ?>[/code] Please read a tutorial on basic php syntax, which will solve 95% of the problems you experience. http://www.w3schools.com/php/default.asp
  12. [code][code]Use a join... http://dev.mysql.com/doc/refman/5.0/en/join.html [/code]SELECT * FROM shirtcolors   LEFT JOIN colors ON shirtcolors.color_id = colors.color_id   LEFT JOIN shirts ON shirtcolors.shirt_id = shirts.shirt_id WHERE color = 'Blue';[/code]
  13. either [code]echo "<pre>" . $text . "</pre>";[/code] tags around the text, or use the nl2br function. http://www.php.net/nl2br
  14. [code]$query = "UPDATE mytable SET timestamp = '" . time() . "' WHERE fid = '$blah'";[/code]
  15. the function session_set_save_handler requires six parameters be passed to it.  You are only passing five. http://www.php.net/session_set_save_handler
  16. [code]<?php $query = "SELECT * FROM grad_profile LEFT JOIN userdata ON grad_profile.id = userdata.id ORDER BY userdata.lastname"; $result = mysql_query($query) or die('Query '.$query.' failed: ' . mysql_error()); while($row = mysql_fetch_object($result)) $select .= '<option value="' . $row['id'] . '">' . $row_user['firstname'] . ' ' . $row_user['lastname'] . '</option>' . "\n"; } ?> <form method="post" name="userdata" action="grad_profile.php">                     <select name="id">                     <?php echo $select; ?>                     </select>                     <input type="hidden" name="choose" value="choose">                     <input type="submit" value="Submit Info" onmouseover="this.className='buttonon'" onmouseout="this.className='button'" class="button">&nbsp;<input type=reset value="Clear Form" onmouseover="this.className='buttonon'" onmouseout="this.className='button'" class="button">                   </form> [/code]
  17. [quote]My first question is, is the echo before every part of the table nessary?[/quote] What do you mean before every part of the table? This will do the same thing: [code]<?php echo " <table border='1'> <tr> <th>Firstname</th> <th>Lastname</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "   <tr>   <td>" . echo $row['FirstName'] . "</td>   <td>" . echo $row['LastName'] . "</td> </tr>"; } echo "</table>"; ?>[/code]
  18. PHP is weakly typed, so it will convert the keys to whatever format you request them in.  So long as the two are equivalent, either string, int, or float, then they will equate to eachother.
  19. what format are you storing the date in your database?
  20. change: [code]$pathname .= $path . $value['name']; $thumbpath .= $path2 . $value['name'];[/code] to: [code]$pathname = $path . $value['name']; $thumbpath = $path2 . $value['name'];[/code] Notice it's no longer using the ".=" (concatenation) operator.
  21. Please post the code that is giving you trouble.  Without it we can only make guesses that will probably not help you at all.
  22. [code]$combodate = mktime(null, null, null, $RESULT['Lmo'], $RESULT['Lda'], $RESULT['LYR']); $lastjuly1 = mktime(null, null, null, 7, 1, $RESULT['LYR'] - 1); echo '$combodate = ' . $combodate . ' which is: ' . date("Y-m-d", $combodate) . "<br />"; echo '$lastjuly1 = ' . $lastjuly1 . ' which is: ' . date("Y-m-d", $lastjuly1);[/code]
  23. Yes. [code]if($_SESSION['user_level'] == 0){     header("location: user_level_0.html"); } if($_SESSION['user_level'] == 1){     header("location: user_level1.php"); } [/code]
  24. [code]$mysql = "rack_pm"; mysql_select_db($mysql); foreach ($_FILES as $value) { $pathname .= $path . $value['name']; $thumbpath .= $path2 . $value['name']; $sql = "INSERT INTO `returnedfiles` (`imagepath`, `thumbpath`, `jobnum`, `pname`, `num`, `autojobnum`) VALUES ('$pathname', '$thumbpath', '000', 'nada', NULL, '1')"; mysql_query($sql) or die(mysql_error()); echo $pathname . "<br>"; echo $thumbpath . "<br><br>"; } [/code]
  25. [code]$query = "SELECT status FROM locations WHERE location IN (" . implode(",", $locations_array) . ")";[/code] Then you would loop through to put them into an array using the location as the key (assuming all locations occur only once).  Then to get the status, just use [code]$location_status_array[$location][/code] to get the status
×
×
  • 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.