Jump to content

HuggieBear

Members
  • Posts

    1,899
  • Joined

  • Last visited

Everything posted by HuggieBear

  1. I don't think you are the first, and it can be done the other way around, .htaccess login info can be sent to a php page by using the $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] variables.  I'm not sure about the other way though, passing values from php to .htaccess, maybe it's just a case of setting the values of those variables, so when apache looks for them, they're valid. I'll test it. Regards Huggie [size=8pt][color=red][b]Note:[/b][/color] That didn't work :([/size]
  2. The error is occuring because on line 25 you have an open curly bracket [color=green][b]{[/b][/color] but it's not preceeded by an [color=green][b]else[/b][/color]. The code that sasa's provided should clear it up. Regards Huggie
  3. I would imagine that one of the other include pages, either DISCOUNT-file.inc, or file.inc, is also trying to send headers. Look at the include files and adjust accordingly. Regards Huggie
  4. [quote author=Colin-uk link=topic=112440.msg456435#msg456435 date=1161625366] Thanks HuggieBear :) But I just realised I posted the wrong code  :-[  Sorry. This is the code i'll be attempting to use: [code] <?php include("dbconnect.php"); $id = $_POST['id']; foreach($_POST as $key => $val) {   mysql_query("UPDATE dbname SET $key = '$val' WHERE id = '$id'") or die(mysql_error()); } ?> [/code][/quote] OK, if you're taking the 'id' seperately then you'll not want it in the foreach, you'll want a condition to exclude it, so try this... [code] <?php include("dbconnect.php"); $id = $_POST['id']; foreach($_POST as $key => $val) {   if ($key != "id"){       mysql_query("UPDATE dbname SET $key = '$val' WHERE id = '$id'") or die(mysql_error());   } } ?> [/code]
  5. How are you assigning the values to the session variable.  Can you show me the code for page 1? Regards Huggie
  6. This has been answered now in another post! The user obviously double posted, I didn't see this one :( Regards Huggie
  7. That syntax looks fine. You might want to sanitise the input first of all, search here for terms such as "SQL injection" and "Sanitise" or "Sanitize". Regards Huggie
  8. OK, on line 61, try changing this: [code=php:0]<?php if ($loggedIn == "unknown" || $loggedIn == "false") { ?> [/code] To this: [code=php:0]<?php } if ($loggedIn == "unknown" || $loggedIn == "false") { ?> [/code] Regards Huggie
  9. There's only 80 lines in the code you posted, have you posted the correct/complete code? Regards Huggie
  10. I'd be inclined to save it in an array keyed on company name if there's only a couple, or a database if theirs lots. [code]<?php $email_addresses = array('CompanyA' => "me@mycompany.com", 'CompanyB' => "you@yourcompany.com"); $to = $email_address['$_REQUEST['Company']']; ?>[/code] Regards Huggie
  11. Sure, rather than using javascript to call the fields serial_num0 serial_num1 etc, get it to call all the fields the same thing.  Get it to call them all [color=green]serial_num[][/color]. Then php can access them by using the following: [code]<?php foreach ($_REQUEST['serial_num'] as $serial){   echo "$serial<br>\n"; } ?>[/code] Regards Huggie
  12. That's impossible, you must have the email addresses somewhere... If I select Company A from your drop down, how does the form know that Company A's email address is me@company.com? Regards Huggie
  13. Where are you storing the email addresses? Regards Huggie
  14. What I did was put $result into this line: [code=php:0]echo nl2br(stripslashes($result)); [/code] Regards Huggie
  15. You aren't echoing it anymore... Try this: [code]<?php function emoticon($post) {   $emoticonarray = array(       ':)'  => 'smile.gif',       ':('  => 'sad.gif',       ';)'  => 'wink.gif',       ':P'  => 'tongue.gif'   );   foreach($emoticonarray as $emoticon => $img) {       $search[] = $emoticon;       $replace[] = '<img src="images/emotions/' . $img . '" alt="' . $emoticon . '" />';   }   $post = str_replace($search, $replace, $post);   return $post; } $result = emoticons($r['post']);     echo stripslashes($r['username']); ?></td>     <td style="width:80%;background-color:#101010;">     <?     echo nl2br(stripslashes($result)); ?></td>[/code] Regards Huggie
  16. $post gets assigned whatever is passed to emoticons(), that's because it's specified when defining the function, like this: [code=php:0]function emoticons($post){   // Function code here   return $post; } [/code] So you can call the function with any variable you like, and it will get assigned to $post inside the function: [code=php:0]$result = emoticons($r['post']); [/code] This takes whatever's in $r['post'], assigns it to $post inside the function and returns it as $result. I hope that this makes sense. Regards Huggie
  17. LoggedIn is always going to be set to false, as you've got it coded outside of a conditional statement.  Look at line 8 of your code. Regards Huggie
  18. Your getting confused between defining a function and calling one... Try this: [code]<?php function emoticon($post) { //This defines the function   $emoticonarray = array(       ':)'  => 'smile.gif',       ':('  => 'sad.gif',       ';)'  => 'wink.gif',       ':P'  => 'tongue.gif'   );   foreach($emoticonarray as $emoticon => $img) {       $search[] = $emoticon;       $replace[] = '<img src="images/emotions/' . $img . '" alt="' . $emoticon . '" />';   }   $post = str_replace($search, $replace, $post);   return $post; } // This is the end of the function echo stripslashes($r['username']); ?> </td> <td style="width:80%;background-color:#101010;"> <?php echo nl2br(stripslashes(emoticons($r['post']))); // This is where the function's called ?> </td>[/code] Regards Huggie
  19. Yes, your code doesn't have a section for logged out. It should be destroying the session variable and changing $loggedin to false. Regards Huggie
  20. I'm using the ternary operator, you can read about it [url=http://uk.php.net/manual/en/language.operators.comparison.php]here[/url] It's the same as saying... [code] <?php if (empty($_GET['action'])){ // This says if the variable is empty, has nothing assigned to it   $action = ""; } else {   $action = $_GET['action']; } ?> [/code] Regards Huggie
  21. You need to get the value of action from the URL. You have this at the top of your code: [code=php:0]$action = ""; [/code] Change it to this: [code=php:0]$action = (empty($_GET['action'])) ? "" : $_GET['action']; [/code] I'd also change your query as currently you're getting all the rows from the database, you'd be better with this: [code] $query = "SELECT * FROM Users where Username = '$uname' AND Password = '$pwd'"; $result = mysql_query($query); if ($result){   $row = mysql_fetch_array($result);   $_SESSION['LoggedInUser'] = $uname;   $loggedin = "true"; } [/code] Regards Huggie
  22. In that case it's your form... Can you export the table structure from phpMyAdmin by using the export tab, and then post it here along with the code and I'll get on the case. Regards Huggie
  23. I think you're possibly going to need the [url=http://uk.php.net/manual/en/ref.curl.php]cURL[/url] library. Regards Huggie
  24. [quote author=buraisu link=topic=112089.msg454873#msg454873 date=1161340338] Well, this may sound lame, but if I can find a way to get my friends nexopia profile hitcount up by a certain amount I am oing to get 50$. [/quote] I don't think it's lame, I like someone who shows initiative when finding solutions. Many people who post here are trying to find solutions to code problems that they themselves are charging customers for.  I'm also sure that they're charging a hell of a lot more than $50 ;D Regards Huggie
  25. I may have something wrong here, but I always thought that the 'switch' statement was an alternative way of writing 'if' statements?  If this is a case, then why combine both in the same piece of code... [quote author=ltoto link=topic=112094.msg454870#msg454870 date=1161339827] [code]<?php switch($row_rsHotel['hotelType']) { case 'Hotel': if($row_rsPages['Id']== "15") [/code] [/quote] 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.