Jump to content

bluedot

Members
  • Posts

    21
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

bluedot's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I should probably just search some syntax library but abusing forums is so much easier How would i remove access stuff (like quotes, periods, and commas) from a string variable?
  2. It is printing the correct values. They print whatever the search parameters were that the user entered. Except when I go to page two. I only display 4 results per page, then i have " <prev <<first last>> next>" links to go to the next page of results. When i go to the "next" page the search results are gone
  3. P.S. I didn't know bluedot's were bongs until after i had it as a username
  4. Yeah, they all have the correct values. Just not on any page but the first. They are blank after i change pages.
  5. Hi, I have the following HTML Forum. <html> <head> <title>CSA Quotes Database</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css"> <!-- body { background-color: #FFFFCC; } .style1 { font-size: 12px; color: #FF0000; font-weight: bold; } --> </style></head> <body> <table width="802" border=1 align="center"> <!--DWLayoutTable--> <tr> <td width="303" height="240" valign="middle"> <div align="center"><img src="images/csalogotrns.gif" width="277" height="193"></div></td> <td width="289" valign="middle"> <div align="center"> <h1>CSA Quotes Database </h1> </div></td> <td width="186" valign="middle"> <div align="center"><img src="images/jsnlogo.gif" width="180" height="236"></div></td> </tr> <tr> <td height="71" valign="middle"> <div align="center"><strong><a href="quotes.php">Browse All</a></strong></div></td> <td> </td> <td> </td> </tr> </table> <p> </p> <p> </p> <form name="form1" method="post" action="quotequery.php"> <table width="556" border="1" align="center"> <tr> <td width="164"><div align="right">Search In: </div></td> <td width="376"><label> <select name="conditions" id="conditions"> <option value="author">Author</option> <option value="source">Source</option> <option value="quote" selected>Quote</option> </select> <span class="style1">Source includes the date </span></label></td> </tr> <tr> <td><div align="right"></div></td> <td><label></label> <p><label></label> <label> <input type="radio" name="condition" value="contains"> Contains</label> <br> <label> <input type="radio" name="condition" value="exact"> Exact Phrase</label> <br> </p></td> </tr> <tr> <td><div align="right">Keywords:</div></td> <td><input name="find" type="text" id="keyword1"></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td><label> <input type="reset" name="Submit2" value="Reset"> </label></td> <td><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </form> <p> </p> </body> </html> That is sent to the following PHP Script <?php //$testing = $_POST['find']; //echo "<h2>$testing **</h2><br>"; //echo "$find *** $condition *** $exact <br>"; // Connect to database server include ("xoops-auth.php"); $hd = mysql_connect("$host", "$username","$password") or die ("Unable to connect"); mysql_select_db ("$database", $hd) or die ("Unable to select database"); $data1 = mysql_query("SELECT * FROM quotes", $hd) or die(mysql_error()); $rows = mysql_num_rows($data1) or die ("Unable to select database"); $origanal = $_POST['find']; $conditions = $_POST['conditions']; $condition = $_POST['condition']; if ($condition == "contains") { $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); } //This is the number of results displayed per page $page_rows = 4; //This tells us the page number of our last page $last = ceil($rows/$page_rows); //this makes sure the page number isn't below one, or more than our maximum pages if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } //This sets the range to display in our query $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; $data = mysql_query("SELECT * FROM quotes WHERE upper($conditions) LIKE'%$find%' $max", $hd); if (mysql_num_rows($data) > 0) { ?> </p> <table width="468" border=1 align="center"> <tr> <td width="124" height="71"> </td> <td width="206"><div align="center"> <h3>CSA Quotes Database </h3> </div></td> <td width="116"> </td> </tr> <tr> <td height="23" colspan="3"><div align="center"><strong><a href="quotes.php">Browse All</a></strong> <strong><a href="index.html">Home</a> <a href="events.php">Events</a></strong> </div></td> </tr> </table> <p>You searched for:<br> <?php echo "$origanal<br><h3>$rows results</h3><br>"; ?></p> <p> </p> <table width="979" border="1" align="center"> <tr class="row"> <td>Author</td> <td>Source</td> <td>Quote</td> </tr> <?php while ($result_ar = mysql_fetch_assoc($data)) { ?> <tr <?php if($i%2 == 1){ echo "class='body2'"; }else{echo "class='body1'";}?>> <td width="12%" class="style1"><?php echo $result_ar['author']; ?></td> <td width="24%" class="style1"><?php echo $result_ar['source']; ?></td> <td width="64%" class="style1"><?php echo $result_ar['quote']; ?></td> </tr> <?php } // end while loop } // end the if number of rows > 0 else { echo "<h2>Sorry, your search did not return any results. <a href='quotessearch.php'>Search Agian</a></h2><br>"; } ?> </table> <div align="center"> <?php // This shows the user what page they are on, and the total number of pages echo " --Page $pagenum of $last-- <p>"; // First we check if we are on page one. If we are then we don't need a link to the previous page or the first page so we do nothing. If we aren't then we generate links to the first page, and to the previous page. if ($pagenum == 1) { } else { echo " <div align='center'><a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a>"; echo " "; $previous = $pagenum-1; echo "<a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> <-Previous</a>"; } //just a spacer echo " --- "; //This does the same as above, only checking if we are on the last page, and then generating the Next and Last links if ($pagenum == $last) { } else { $next = $pagenum+1; echo "<a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next -></a> "; echo " "; echo "<a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a></div> "; } ?> The html form sends the variables to the PHP script via the post and $_POST features. Then the php script limits the results of the search and splits them up between the needed pages (determined by the number of results). The first page of results works fine. However the second page and any other pages after that get an error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in *path*quotequery.php on line 102 This, i am guessing means the query failed because the variables received from the HTML form are no longer in memory. So my question is how can I get the variables from the form to stay in memory. Thanks in advanced.
  6. Thank you very much! that fixed it.
  7. like bold or or italics or centering
  8. Hi, I have a search script that the user chooses to search under 1 of 3 columns (author, source, quote). author and source are "varchar" columns, and if i choose one of those 2 to search in it works fine. However quote is a "blob" column as I allow some formating in this column. If i put a test row in the database with no formating in the quote column it can be found by the search just fine. But if there is any text that is formated can't be found. Im guessing this is due to the way blobs are stored, so my question is how do I query it? This is my current query: <?php $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); $data = mysql_query("SELECT * FROM quotes WHERE upper($conditions) LIKE'%$find%'", $hd); ?> $find is what they searched for, and $conditions is where what column they wanted to search in. Thank you.
  9. Wow can't believe i did'nt think of that, guess i shoulda had my coffe before posting. I was calling the wrong table in the database  >:( Thanks for reply
  10. Hi I have the following HTML form and a script that is supposed to search a database and return results. However when they are executed nothing is returned even though it should as I am searching for somthing that i know is in the database. HTML Form: [code]<html> <h2>Search</h2> <form name="search" method="post" action="search.php"> Seach for: <input type="text" name="find" /> in <Select NAME="field"> <Option VALUE="software_name">Software Name</option> <Option VALUE="catagory">Catagory</option> <Option VALUE="description">Description</option> </Select> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" /> </form> </html>[/code] PHP Script: [code]<?php $searching = $_POST['searching']; $field = $_POST['field']; $find = $_POST['find']; //This is only displayed if they have submitted the form if ($searching =="yes") { echo "<h2>Results</h2><p>"; //If they did not enter a search term we give them an error if ($find == "") { echo "<p>You forgot to enter a search term"; exit; } // Otherwise we connect to our Database require ("admin/connect.php"); // We preform a bit of filtering $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); //Now we search for our search term, in the field the user specified $data = mysql_query("SELECT * FROM users WHERE upper($field) LIKE'%$find%'"); //And we display the results ?> <table width="1417" border="1" align="center">   <tr>     <td width="149"><div align="center">Picture</div></td>     <td width="171"><div align="center">Name</div></td>     <td width="171"><div align="center">Catagory</div></td>     <td width="149"><div align="center">Description</div></td>     <td width="149"><div align="center">Version</div></td> <td width="149"><div align="center">More Options</div></td>   </tr> <? while($result_ar = @mysql_fetch_array($data)){ ?>   <tr>     <td><div align="center"><? echo "$result_ar[product_pic]" ?></div></td> <td><div align="center"><? echo "$result_ar[software_name]" ?></div></td>     <td><div align="center"><? echo "$result_ar[catagory]" ?></div></td>     <td><div align="center"><? echo "$result_ar[description]" ?></div></td>     <td><div align="center"><? echo "$result_ar[version]" ?></div></td> <td><div align="center">more stuff</div></td>   </tr> <? } //This counts the number or results - and if there wasn't any it gives them a little message explaining that $anymatches=@mysql_num_rows($data); if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query<br><br>"; } //And we remind them what they searched for echo "<b>Searched For:</b> " .$find; } ?>[/code]
  11. It was the $user thing, thank you very much :)
  12. Hi I have the following code: At the begining I have an IF statment checking to see if the status = "loggedin"  Using an echo statement I know that the correct status is getting that far. As well as "background-color: #FFFFCC;" is executed as the background of the page is the correct color. but after that nothing is displayed, the page comes up blank (except for the background color). I have other pages that do almost the exact same thing, am i missing somthing? Thank you very much. [code]<?php session_start(); if($_SESSION["status"]==="loggedin") { ?> <html> <head> <title>CSA Leaders Admin Page</title> <style type="text/css"> <!-- body { background-color: #FFFFCC; } --> </style></head> </head> <body> <?php include ("DBlogin.php"); include ("connectDB.php"); $result = mysql_query("SELECT * FROM userinfo WHERE username='$user'", $hd) or die("Error querying database"); while($row = @mysql_fetch_assoc($result)) { ?> <table width="760" height="355" border="1">   <tr>     <td width="144" rowspan="4"><img src="414f6e1a.gif" width="130" height="205" alt="logo" /></td>     <td width="429" rowspan="4"><div align="center">       <h2><strong>Welcome to the CSA Leaders Admin Page </strong></h2>     </div></td>     <td height="36"><div align="center"><a href="changeuserform.php">Change Username </a></div></td>   </tr>   <tr>     <td height="36"><div align="center"><a href="changepassform.php">Change Password</a></div></td>   </tr>   <tr>     <td height="36"><div align="center"><a href="edituservalid.php">Change Personal Info</a></div></td>   </tr>   <tr>     <td width="165" height="68">&nbsp;</td>   </tr>   <tr>     <td height="23" colspan="3"><p><? if ("$row[fname]" != ""){ echo "Welcome $row[fname]"; } else { echo "Please Update your personal information"; }?></p>     <p><strong>What would you like to do? </strong></p></td>   </tr>   <tr>     <td height="27"><div align="center"><a href="eventmenu.php">Edit Events </a></div></td>     <td colspan="2" rowspan="4">Please email Josh W. for help/tips etc.</td>   </tr>   <tr>     <td height="23">&nbsp;</td>   </tr>   <tr>     <td>&nbsp;</td>   </tr>   <tr>     <td>&nbsp;</td>   </tr> </table> <? } } else {     echo "This is an Admin page only!<META HTTP-EQUIV = 'Refresh' Content = '2; URL =login.php'>";     } ?> </body> </html> [/code]
  13. i think that applies to any session functions.. not sure though. Im new to php too.
  14. I believe this means somewhere in that php file there is a command called "startsession()" that startsession() command must be the very first function in your php file. Try putting the include function after the sessionstart() function. hope this helps
  15. that does'nt seem to work, it prints a blank. what are the 0's for in [code]setcookie("mysite_username", $username,0,"www.mysite.com",0);[/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.