Jump to content

HuggieBear

Members
  • Posts

    1,899
  • Joined

  • Last visited

Everything posted by HuggieBear

  1. I see you didn't include my suggestion in your code, why did you remove that section? Huggie
  2. Try changing this: [code]// set a default location if one wasn't specified $loc = "Location1";[/code] To this: [code]// set a default location if one wasn't specified $loc = "Location_";[/code] In MySQL the underscore ( _ ) acts as a wild card for a single character.  You'll also need to change the query to look loke this: [code]$query = "SELECT * FROM employees WHERE location LIKE '$loc'";[/code] Regards Huggie Regards Huggie
  3. Try mysql_num_rows() instead of msql_num_rows(). You have a typo... ou're missing a 'Y' if you'll excuse the pun ;o) Huggie
  4. It should just read them anyway.  As if the page were one large continuous stream of text without the PHP interruptions. Regards Huggie
  5. Thanks Thorpe, I thought as much but wouldn't want to look a fool when replying to post saying as much. Regards Huggie
  6. Below is a section of code I use in one of my classes, send_html is one of the functions inside the class.  It all works fine, but I want to shorten it, so can I replace the first block of code with the second block? [code]<?php function send_html() {   $headers = "Content-type: text/html\n\n";   $result = mail($this->to, $this->subject, $this->body, $headers);   if ($result){       return true;   }   else {       return false;   } } if ($mail->send_html()){   echo "Message sent OK"; } else {   echo "Message failed"; } ?>[/code] [code]<?php function send_html() {   $headers = "Content-type: text/html\n\n";   return mail($this->to, $this->subject, $this->body, $headers); } if ($mail->send_html()){   echo "Message sent OK"; } else {   echo "Message failed"; } ?>[/code] I guess what I'm asking, is can I return the value of a php function within my user defined function, directly through to the calling script? Regards Huggie
  7. I've corrected in the above post, you can try again now. Huggie
  8. Give this a try... [code]<?php // connect to db include('mysql_connect.php'); // check the url for a location ID if (isset($_GET['location'])){   $loc = $_GET['location']; } else {   // set a default location if one wasn't specified   $loc = "Location1"; } // query the database $query = "SELECT * FROM employees WHERE location = '$loc'"; $result = mysql_query($query); // loop through each record while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){   extract($row); // import the column names into the namespace   echo "$proid, $name, $title, $location, $exn, $exdd, $email, $ext<br>\n"; } ?>[/code] Then call this with something like [color=green]employees.php?location=Location1[/color] Regards Huggie
  9. OK, I'm afraid you're quite a way off here, but not so far gone that you can't be helped :) Regards Huggie
  10. No problem, happy to help. Huggie
  11. OK, this maybe an issue relating to register_globals. Where you have these lines near the top of your code: [code]$memory=$_REQUEST['memory']; $photo=$_REQUEST['photo']; $datap=$_REQUEST['datap'];[/code] Try adding this below: [code]$submit=$_REQUEST['submit'];[/code] Regards Huggie
  12. Is this the only code you have? Huggie
  13. If you just want to put the contents of what was posted in a file then try this (with comments included): [code]<?php // file name and location $file_to_write = "/var/tmp/post.txt"; // open the file for writing and assign to a resource id ($file) $file = fopen($file_to_write, "w"); // write a header to the file fwrite($file, "The following entries were posted:\n\n"); // write a row in the file for each of the posted elements foreach ($_POST as $key => $value){   fwrite($file, "$key: $value\n"); } // close the file fclose($file); ?>[/code] Incidentally, I took these instructions directly from the [url=http://uk.php.net/manual/en/]PHP Manual[/url]!  A first stop for every PHP Newbie. Regards Huggie
  14. The form looks good, but what information do you want to put into the cookie?  Their userid? Try something like this: [code]<?php $validate = @mysql_query("SELECT * FROM members WHERE username='{$_POST['username']}' AND password = md5('{$_POST['password']}') AND verified = '1'"); if(mysql_num_rows($validate) == 1){   while($row = mysql_fetch_assoc($validate)){       $_SESSION['login'] = true;       $_SESSION['userid'] = $row['id'];       $_SESSION['first_name'] = $row['first_name'];       $_SESSION['last_name'] = $row['last_name'];       $_SESSION['email_address'] = $row['email_name'];       $_SESSION['username'] = $row['username'];       if($row['admin_access'] == 1){         $_SESSION['admin_access'] =true;       }       // This has been added       if (isset($_POST['cookie'])){         setcookie("authenticated", $row['id'], time()+604800, "/", "domain.co.uk"); // set to expire in 7 days       }             $login_time = mysql_query("UPDATE members SET last_login=now() WHERE id='{$row['id']}'");   }   header("Location: /index.php"); } else{   myheader(" - Login Failed!");   echo '<p>Login Failed</p>';   echo '<p>If you have already joined our website, you may need to validate '.   'your email address. Please check your email for instructions.';   footer(); } ?>[/code] This will add the cookie to the domain if they've ticked the checkbox.  You'll need to change the condition on your pages that check for login though, as they'll need to check for [code=php:0]$_COOKIE['authenticated'][/code] and [code=php:0]$_SESSION['login'] [/code] Regards Huggie
  15. I don't have a fancy IDE, but I do use a free application with syntax highlighting.  Something like [url=http://www.crimsoneditor.com/]Crimson Editor[/url]. Regards Huggie
  16. It should be fine, so what error occurs when you try this? [code] <form name="form2" method="post" action="<?php $_SERVER['PHP_SELF']; ?>"> <div align="center">   <br>   <br>   <br>   <table width="185" height="102" border="0" cellspacing="0" cellpadding="0" background="JPGS/tags/members.jpg">   <tr>     <td valign="middle">     <center>       <table width="95%" border="0" cellspacing="0" cellpadding="0" bgcolor="#e5eaee">       <tr>         <td colspan="3">         <div align="center" class="layerText">MEMBERS AREA</div>         </td>       </tr>       <tr>         <td class="small2">         &nbsp;&nbsp;Login:         </td>         <td colspan="2">         <div align="left">           <input name="username" type="text" size="14" id="username" value="<?php $_POST['username']; ?>">         </div>         </td>       </tr>       <tr>         <td class="small2">         &nbsp;&nbsp;Password:         </td>         <td colspan="2">         <div align="left">           <input name="password" type="password" size="14" id="password" value="<?php $_POST['password']; ?>">         </div>         </td>       </tr>       <tr>         <td colspan="3">         <table border="0" cellspacing="0" cellpadding="0">           <tr>           <td width="112"><a href="forgot_your_password.php" class="link">Forgot your password?</a>           </td>           <td width="64" valign="middle">             <input name="submit_butt" type="submit" value="Submit">           </td>           </tr>         </table>         </td>       </tr>       </table>     </center>     </td>   </tr>   </table> </div> </form> <?php $cstyle_query = mysql_query("SELECT * FROM choosen_style") or die (mysql_error()); $cstyle_row = mysql_fetch_array($cstyle_query); $cstyle_id = $cstyle_row['csty_id']; $style_query = mysql_query("SELECT * FROM styles WHERE sty_id='$cstyle_id'") or die (mysql_error()); $style_row = mysql_fetch_array($style_query); $style_id = $style_row['sty_id']; $foot = $style_row['foot']; $pole2 = $style_row['pole2']; ?> <td height="21" colspan="5" background="JPGS/top_navi/<?php echo $pole2; ?>"> </td> </tr> <tr> <td height="30" colspan="5" background="JPGS/footers/<?php echo $foot; ?>">   <table width="100%" cellspacing="5">   <tr>     <td width="10">&nbsp;     </td>     <td>     <span class="white">Copyright &copy; 2006 eventindustires.com All Right Reserved.</span>     </td>     <td align="right">     <div align="right"><a href="terms.php" class="white_link">Terms of use</a> <span class="white">- <a href="mailto:info@eventindustries.com" class="white_link">Contact us</a></span> </div>     </td>     <td width="10">&nbsp;</td>   </tr>   </table> </td> </tr> <tr> <td width="22" height="27"> </td> <td width="363">   <p><span class="error">Created by Spires1</span><br><a href="http://www.spires1.com" target="_blank" class="link">web and graphic design</a>   </p> </td> <td width="316"></td> <td width="22"></td> [/code] Regards Huggie
  17. Does the highlighted code not help you?  The fact that nearly all your code is red, apart from a few lines, the first of which being line 30? Line 30 contains a quote with "double quotes" around it.  Do you think you need to do anything to those double quotes to have them show correctly? Regards Huggie
  18. Don't forget to remove your database connection info when posting. I'd suggest calling each of the checkboxes the same thing, something like [color=green]todelete[][/color] but with the value of [code=php:0]$MASSEGES['id'][/code] this way you'll end up with an array called [color=green]$todelete[/color] in php and you can use it something like this: [code]<?php $delete = implode(",", $todelete); // This creates a string of id's e.g. "1,4,8," $limit = count($todelete); // set a limit as a safety precaution $sql = "DELETE FROM tablename WHERE id IN ($delete) LIMIT $limit"; $result = mysql_query($sql); if ($result){   echo "The following ID's were successfully deleted: $delete\n"; } else {   echo "There was an error deleting rows from the database\n"; } ?>[/code] Regards Huggie
  19. The function in your class is called aadbar (notice the two 'a') and you call is using addbar (notice the two 'd'). Regards Huggie
  20. Are you getting the same response in both IE and Firefox?  What browser are you using? Regards Huggie
  21. I'd use mysql_fetch_array() [code] <?php $sql = "SELECT column FROM table WHERE uid = '$uid'"; $result = mysql_query($sql) or die ("Unable to run $sql: " . mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); if ($row['column'] == 1){   // do something here } else {   // do something here } ?> [/code] Regards Huggie
  22. You're not actually echoing anything. I'd change this: [code]<?php if ($num_rows == 1) {   // Enable sessions   //if (isset($_SESSION['loggedin']))   //{   $_SESSION['username'] = $_POST['username'];   $_SESSION['memberid'] = $_POST['memberid'];   header("Location: members.php");   exit; } else {   if ($num_rows == 0){       // display bad username and password error       $loginError = "Your user name and password do not match any in our database! Please try again. <a class='body' href='login.php'>Return to login page.<br>\n"; }[/code] To this: [code]<?php if ($num_rows == 1) {   $_SESSION['username'] = $_POST['username'];   $_SESSION['memberid'] = $_POST['memberid'];   header("Location: members.php");   exit; } else {   // display bad username and password error   $loginError = "Your user name and password do not match any in our database! Please try again. <a class='body' href='login.php'>Return to login page.<br>\n";   echo $loginError; }[/code] Regards Huggie
  23. Try changing this: [code=php:0]$num=mysql_numrows($result);[/code] to this [code=php:0]$num=mysql_num_rows($result);[/code] You named the function incorrectly. Huggie
  24. As I thought... In that case change this in members.php [code=php:0]$username = $_POST['username'];[/code] to this [code=php:0]$username = $_SESSION['username'];[/code] Regards Huggie
×
×
  • 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.