Jump to content

Michael4172

Members
  • Posts

    41
  • Joined

  • Last visited

    Never

Everything posted by Michael4172

  1. [code]                        $select_team = "SELECT *";                         $from_team   = " FROM mc_base";                         $where_team = " WHERE mc_sponsor_id = '$myid'";                         $sname_team = mysql_query($select_team . $from_team . $where_team, $dbcnx);                                                $count = 0;                 while ($sname_view_list = mysql_fetch_array($sname_team)) {                 $count++;                 $member_fname = $sname_view_list["mc_fname"];                                         echo("<tr><td>$count</td>");                                         echo("<td>$member_fname</td></tr>");                                         echo("</table> } [/code]
  2. You can get a function at the below link. I believe if you change the content type to whatever image format you have (.gif / .bmp) it would work [a href=\"http://uk.php.net/imagecopyresized\" target=\"_blank\"]PHP Manual - imagecopyresized[/a]
  3. [!--quoteo(post=388351:date=Jun 27 2006, 12:16 AM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ Jun 27 2006, 12:16 AM) [snapback]388351[/snapback][/div][div class=\'quotemain\'][!--quotec--] the reason why ^ returns blank page is because you do this: $key_row = $row['keyword']; before your if statement. this makes it true, even if there is no value. you are creating the variable, so simply doing if ($key_row == true) ... well it exists, even if it is empty, so it's true. what is your query string? are you expecting more than 1 row returned? something like this should work if you are expecting more than 1 row returned. there are more efficient ways if only 1 row is expected to be returned [code] $found = FALSE; while($row = mysql_fetch_array($result)) {    //not sure how your data is stored, so this should cover your bases    if (($row['keyword'] != NULL) && (!empty($row['keyword'])) && (trim($row['keyword']) != "")){       echo $row['keyword'];       echo "<br />";       echo $row['definition'];       echo "<br />";       $found = TRUE;     } } if ($found == FALSE) {    echo "not found"; } [/code] [/quote] I am just expecting one match per keyword, but the code you supplied works great :) Thanks for that.
  4. [!--quoteo(post=388339:date=Jun 26 2006, 11:37 PM:name=phpstuck)--][div class=\'quotetop\']QUOTE(phpstuck @ Jun 26 2006, 11:37 PM) [snapback]388339[/snapback][/div][div class=\'quotemain\'][!--quotec--] Try this [code] while($row = mysql_fetch_array($result))         $key_row = $row['keyword'];   if ($key_row != ""){       echo $row['keyword'];       echo "<br />";       echo $row['definition'];       echo "<br />";   } else {       echo "The keyword wasn't found";   } [/code] [/quote] This code works correctly if the keyword isn't in the DB...but displays the blank page if it does exist....kinda odd... [code] while($row = mysql_fetch_array($result))   {      $key_row = $row['keyword'];   if ($key_row > 0){       echo $row['keyword'];       echo "<br />";       echo $row['definition'];       echo "<br />";}   else {       echo "The keyword wasn't found";}   } [/code] I tried this, It gives a "Keyword wasn't found" when I type in a keyword that's in the database. It returns a blank page when an incorrect keyword is entered. [code] while($row = mysql_fetch_array($result))   {      $key_row = $row['keyword'];   if (! $key_row){       echo $row['keyword'];       echo "<br />";       echo $row['definition'];       echo "<br />";}   else {       echo "The keyword wasn't found";}   } [/code] This does same thing as #1 [code] while($row = mysql_fetch_array($result))   {      $key_row = $row['keyword'];   if ($key_row == true){       echo $row['keyword'];       echo "<br />";       echo $row['definition'];       echo "<br />";}   else {       echo "The keyword wasn't found";}   } [/code] This returns the keyword when its found. But returns a blank page when the keyword isn't found. :( In addition I've also attempted = true and === true on this one as well. Also tried $key_row = 1... I also have tried this [code] while($row = mysql_fetch_array($result))   {      $key_row = $row['keyword'];   if ($key_row == true){       echo $row['keyword'];       echo "<br />";       echo $row['definition'];       echo "<br />";}   else if ($key_row == false){       echo "The keyword wasn't found";}   } [/code] It returns the keywords if true, but returns a blank page if false :(
  5. I'm doing a simple IF test statement below. I would expect it to return the $rows if $key_row equals anything other than a blank, and would expect it to return keyword wasn't found if its blank. However, when I use the code below it returns keywork and definition if true, but returns a blank page if they weren't found. Am I overlooking something below? [code] while($row = mysql_fetch_array($result))   {      $key_row = $row['keyword'];   if ($key_row != ""){       echo $row['keyword'];       echo "<br />";       echo $row['definition'];       echo "<br />";}   else {       echo "The keyword wasn't found";}   } [/code]
  6. For others who may wanna try this, for it to work, I ended up doing the following: [code] <?php $user = "user"; $pass = "password"; $db = "joa"; $link = mysql_connect( "localhost", $user, $pass ); if ( ! $link )    die( "Couldn't connect to MySQL" ); mysql_select_db( $db, $link )   or die ( "Couldn't open $db: ".mysql_error() ); if (isset($_REQUEST['keyword'])) { // Do this if a keyword was set $result = mysql_query("SELECT * FROM joa WHERE keyword='$keyword'"); while($row = mysql_fetch_array($result))   {   echo $row['keyword'];   echo "<br />";   echo $row['definition'];   echo "<br />";   } } else { echo "Didn't work"; } ?> [/code] Thanks for all the help gentlemen :)
  7. Actually I was echoing $result. :) Thanks for the help
  8. Ok so far here is what I got: [code] <?php $user = "user"; $pass = "pass"; $db = "joa"; $link = mysql_connect( "localhost", $user, $pass ); if ( ! $link )    die( "Couldn't connect to MySQL" ); mysql_select_db( $db, $link )   or die ( "Couldn't open $db: ".mysql_error() ); if (isset($_REQUEST['keyword'])) { // Do this if a keyword was set $keyword = $_REQUEST['keyword']; //Sets $keyword equal to what its the URL $sql = "SELECT * from joa WHERE keyword='$keyword'";  // Selects all fields for the APPLE or whatever the keyword is $result = mysql_query($sql); // Now you are connected to the database, table and the correct row for the keyword } else { echo "Didn't work"; } ?> [/code] However, when I type in a keyword that is in the db... "Apple" as [a href=\"http://www.site.com/keyword.php?keyword=Apple\" target=\"_blank\"]http://www.site.com/keyword.php?keyword=Apple[/a] it just shows as a blank page.....Any ideas?
  9. Thanks, I'm gonna play around with it some :)
  10. The code I displayed is actually the code where I'm inputting the data to MYSQL so I guess that is not a good example. Lets say I create a page whose purpose is to SOLEY display the keyword.php?keyword=APPLE . How would I set it up so if you view keyword.php by itself its blank, but if you input keyword.php?keyword=APPL (assuming APPLE is int he db) it would display that ID, keyword, def ect...
  11. [!--quoteo(post=388129:date=Jun 26 2006, 01:11 PM:name=DaveLinger)--][div class=\'quotetop\']QUOTE(DaveLinger @ Jun 26 2006, 01:11 PM) [snapback]388129[/snapback][/div][div class=\'quotemain\'][!--quotec--] But saying keywords.php?keyword doesnt tell the php code anything. You'd need keywords.php?keyword=thewordtolookfor [/quote] Ok well that is fine as well. Question is, how would I set that up?
  12. Ok here is the code (I have thus far) for the db where I insert the information into the MySql itself: [code] <?php $keyword = $_REQUEST['keyword']; $definition = $_REQUEST['definition']; $user = "user"; $pass = "password"; $db = "joa"; $link = @mysql_connect( "localhost", $user, $pass ); if ( ! $link ){     die( "Couldn't connect to MySql: ".mysql_error() ); } print "<h2>Successfully connected to server</h2>\n\n"; @mysql_select_db( $db )     or die ( "Couldn't open $db: ".mysql_error() ); print "Successfully selected database \"$db\"<br />\n"; $query = "INSERT INTO joa( keyword, definition )     values ( '$keyword', '$definition' )"; print "running query: <br />\n$query<br />\n"; mysql_query( $query, $link )     or die ( "INSERT error: ".mysql_error() ); mysql_close( $link ); ?> [/code] WHat I'm doing is entering keywords and definitions. I have a bit of javascript where you can click on anyword in an article and a popup window comes up. I aim at filling the DB full of words, and if they click one that's not there, it'll take them to a form where they can submit a request for that word. What I"m trying to do is, in the javascript it looks for somthing like [a href=\"http://www.mysite.com/keywords.php?keyword\" target=\"_blank\"]http://www.mysite.com/keywords.php?keyword[/a]. Ideally I could get the ?keyword to show like that :)
  13. [!--quoteo(post=387865:date=Jun 25 2006, 06:40 PM:name=adamwhiles)--][div class=\'quotetop\']QUOTE(adamwhiles @ Jun 25 2006, 06:40 PM) [snapback]387865[/snapback][/div][div class=\'quotemain\'][!--quotec--] the only time you would want to do that is if your passing a variable or value to a page like say, you want to view the 5th post in a database, you will do [a href=\"http://www.yourdomain.com/posts.php?post=5\" target=\"_blank\"]http://www.yourdomain.com/posts.php?post=5[/a] Then in your php code on posts.php you would have something like this: $_GET['post']; the value of $_GET['post'] would be 5 since you had the ?post=5 after posts.php [/quote] I'm actually trying to do the same thing. A couple questions though. Would the name 'post' be the database name or would it be a table in the database itself?
  14. Are you wanting the user to be required to enter in a unique username and password in order to download the files on your site?
  15. PHP Mail - [a href=\"http://us3.php.net/mail\" target=\"_blank\"]http://us3.php.net/mail[/a] Or a better option is if you the PEAR module for SMTP authentication.
  16. golebara, A simple fix to this is to sign up for a hosted shopping cart. Once payment is processed through there, most have an option where a download link is sent to the user (you can set the link to expire XX mins/hrs after payment is received). To me this would be your easiest solution.
  17. Testing Hmmm, I keep getting: Fatal error: Call to a member function on a non-object. on line 18. Line 18 appears to be: [code] $mail = $smtp->send($to, $headers, $body); [/code]
  18. Thanks for the code. However, I'm trying to use the other one since it makes use of SMTP and I don't have that option with just using that code. Any ideas on the original code? :)
  19. I'm attempting to use the following piece of code that I've downloaded from the web. However when I run the script it gives me a "Fatal error: Undefined class name 'mail' on line 15'. Any ideas? [code] <?php require_once "test.php"; $from = "<support@abc.net>"; $to = "<abc@abc.net>"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; $host = "abc.abc.net"; $username = "abc@abc.net"; $password = "abc"; $headers = array ('From' => $from,'To' => $to,   'Subject' => $subject); $smtp = Mail::factory('smtp',array ('host' => $host,'auth' => true,'username' => $username,'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) {   echo("<p>" . $mail->getMessage() . "</p>"); } else {   echo("<p>Message successfully sent!</p>"); } ?> [/code]
  20. I found what I was looking for in $_SERVER['HTTP_REFERER']
  21. [!--quoteo(post=384127:date=Jun 15 2006, 07:14 AM:name=Lorian)--][div class=\'quotetop\']QUOTE(Lorian @ Jun 15 2006, 07:14 AM) [snapback]384127[/snapback][/div][div class=\'quotemain\'][!--quotec--] Well if you don't know the previous page, then how to you expect to be able to go to that page and get the contents of the title tag...? [/quote] That was my question. I am not wanting to install this manually on every page (doing this manually for hudnreds of pages is not practical). Like I said this is a dynamic type application, which means that I won't know the page. However I am thinking if there is a referrer type variable that I may use.
  22. [!--quoteo(post=384080:date=Jun 15 2006, 01:07 AM:name=phpvolution)--][div class=\'quotetop\']QUOTE(phpvolution @ Jun 15 2006, 01:07 AM) [snapback]384080[/snapback][/div][div class=\'quotemain\'][!--quotec--] Hey Mike, just pass the variable with the link: [code] <?php $page = file_get_contents("page.php"); preg_match('!<title>(.*?)</title>!is', $page, $match); $title = $match[1]; ?> <a href="emailpage.php?title=<?=$title?>">e-mail this article to a friend</a> [/code] that should do it [/quote] Thanks for the info :) However, that begs the question, what if I won't always know the previous page? How would I get that info? As my site is a CMS that has hundreds of possible pages.
  23. [!--quoteo(post=381601:date=Jun 8 2006, 05:12 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 8 2006, 05:12 PM) [snapback]381601[/snapback][/div][div class=\'quotemain\'][!--quotec--] str_replace should do, but you can also use htmlentities or htmlspecialchars with ENT_QUOTES: [code]$string = htmlentities($string, ENT_QUOTES);[/code] [a href=\"http://www.php.net/htmlentities\" target=\"_blank\"]http://www.php.net/htmlentities[/a] [a href=\"http://www.php.net/htmlspecialchars\" target=\"_blank\"]http://www.php.net/htmlspecialchars[/a] They will replace " ' " with & #039; Post #625, that is 25^2 or 5^4. I like this number [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] [/quote] Ok thanks I shall give that a try and play with it some :)
  24. I tried this to no avail. [code] <?php $text = str_replace("'", "'", 'If you haven't been here long, you may want to leave.'); echo $text; ?> [/code] I regularly have things like <div id = "blah"> is the reason I rather use single quotes as oppose to the double on the end.
×
×
  • 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.