kaisaj
-
Posts
7 -
Joined
-
Last visited
Never
Posts posted by kaisaj
-
-
YOUR THEORY WAS RIGHT! They were truncated because of the field's former VARCHAR exploits.
I reimported my csv file into the database and now the thing works great. Thank you so very much!
-
Mikosiko - I did change the column sdescription from VARCHAR to text but you are right, it is acting just like a VARCHAR field.
Here's the structure:
Jayarsee, you are right - it's Act. Dumb brain work too hard - smart brain take vacation.
I viewed the source and it is getting cut off in the HTML output as well:
<br />Client(s) has/have retained firm for legal representation in debt matters. Pursuant to the Fair Debt Practices Collection act, 15 U.S.C. § 1692, client(s) may no longer be contacted by collection representatives. All further collection based communicatio<br />
[attachment deleted by admin]
-
Yes, I am much better at the law thing than the PHP but we persevere.
Thank you for fixing my code
It is getting cut off on the page.
This is what I get:
1: Name
Client(s) has/have retained firm for legal representation in debt matters. Pursuant to the Fair Debt Practices Collection act, 15 U.S.C. § 1692, client(s) may no longer be contacted by collection representatives. All further collection based communicatio (This is at the edge of my page)
SSN:XXX-XX-XXXX
-
After much tearing out of my hair I've got a simple database query using PHP to work!
But now I've got results that are cut off because one of the table fields contains data that is a little long. Not War and Peace - just a small paragraph. It is as follows
"Client(s) has/have retained firm for legal representation in debt matters. Pursuant to the Fair Debt Practices Collection act, 15 U.S.C. § 1692,
client(s) may no longer be contacted by collection representatives. All further collection based communications must be directed to client/s'
retained legal counsel, ******. All written collection correspondence must be directed to: *******."
Right now it's cutting off at the middle of communications. It seems like a simple problem but I can't find the solution anywhere. How do I format my SQL search results using PHP? Or anything for that matter.
Here's the code w/o database connection language.
mysql_select_db($dbDatabase) or trigger_error("Failed to connect to database {$dbDatabase}. Error: " . mysql_error());
// Set up our error check and result check array
$error = array();
$results = array();
// First check if a form was submitted.
// Since this is a search we will use $_GET
if (isset($_GET['search'])) {
$searchTerms = trim($_GET['search']);
$searchTerms = strip_tags($searchTerms); // remove any html/javascript.
if (strlen($searchTerms) < 3) {
$error[] = "Search terms must be longer than 3 characters.";
}else {
$searchTermDB = mysql_real_escape_string($searchTerms); // prevent sql injection.
}
// If there are no errors, lets get the search going.
if (count($error) < 1) {
$searchSQL = "SELECT sid, sbody, stitle, sdescription FROM simple_search WHERE ";
// grab the search types.
$types = array();
$types[] = isset($_GET['body'])?"`sbody` LIKE '%{$searchTermDB}%'":'';
$types[] = isset($_GET['title'])?"`stitle` LIKE '%{$searchTermDB}%'":'';
$types[] = isset($_GET['desc'])?"`sdescription` LIKE '%{$searchTermDB}%'":'';
$types = array_filter($types, "removeEmpty"); // removes any item that was empty (not checked)
if (count($types) < 1)
$types[] = "`sbody` LIKE '%{$searchTermDB}%'"; // use the body as a default search if none are checked
$andOr = isset($_GET['matchall'])?'AND':'OR';
$searchSQL .= implode(" {$andOr} ", $types) . " ORDER BY `stitle`"; // order by title.
$searchResult = mysql_query($searchSQL) or trigger_error("There was an error.<br/>" . mysql_error() . "<br />SQL Was: {$searchSQL}");
if (mysql_num_rows($searchResult) < 1) {
$error[] = "The search term provided {$searchTerms} yielded no results.";
}else {
$results = array(); // the result array
$i = 1;
while ($row = mysql_fetch_assoc($searchResult)) {
$results[] = "{$i}: {$row['stitle']}<br />{$row['sdescription']}<br />{$row['sbody']}<br /><br />";
$i++;
}
}
}
}
function removeEmpty($var) {
return (!empty($var));
}
?>
<html>
<title>My Simple Search Form</title>
<h1>Client Database Search Form</h1>
<li>Enter your customer's name or the last six digits of his or her social security number to ascertain case status</li>
<style type="text/css">
#error {
color: red;
}
</style>
<body>
<?php echo (count($error) > 0)?"The following had errors:<br /><span id=\"error\">" . implode("<br />", $error) . "</span><br /><br />":""; ?>
<form method="GET" action="<?php echo $_SERVER['PHP_SELF'];?>" name="searchForm">
Search For: <input type="text" name="search" value="<?php echo isset($searchTerms)?htmlspecialchars($searchTerms):''; ?>" /><br />
Search In:<br />
SSN: <input type="checkbox" name="body" value="on" <?php echo isset($_GET['body'])?"checked":''; ?> /> |
Name: <input type="checkbox" name="title" value="on" <?php echo isset($_GET['title'])?"checked":''; ?> /> |
Case Status: <input type="checkbox" name="desc" value="on" <?php echo isset($_GET['desc'])?"checked":''; ?> /><br />
Match All Selected Fields? <input type="checkbox" name="matchall" value="on" <?php echo isset($_GET['matchall'])?"checked":''; ?><br /><br />
<input type="submit" name="submit" value="Search!" />
</form>
<?php echo (count($results) > 0)?"Your search term: {$searchTerms} returned:<br /><br />" . implode("", $results):""; ?>
</body>
</html>
HELP Please. I'm so close. Any links, referrals, anything, I will take.
-
Thank you for your help, but now I've got that danged "Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource". I've tried to match everything up to make sure the resources are there for fetching, but I cannot get it to work.
:shrug:I feel like this is something really obvious I am overlooking. I have just been trying to get this to work for so many days!
-
Help. I used the great Simple SQL search tutorial provided by this site, but when I tried to customize it for my site, it keeps falling apart. I am a newbie, but any disgust at my idiocy is fine as long as I find a ball of string to lead me out of the labyrinth.
Here's the code (modified from the tutorial) sans the login information:
$con = mysql_connect($dbHost, $dbUser, $dbPass) or trigger_error("Failed to connect to MySQL Server. Error: " . mysql_error());
mysql_select_db($dbDatabase) or trigger_error("Failed to connect to database {olsendai_ssn}. Error: " . mysql_error());
// Set up our error check and result check array
$error = array();
$results = array();
// First check if a form was submitted.
// Since this is a search we will use $_GET
if (isset($_GET['search']))
$searchTerms = trim($_GET['search']);
$searchTerms = strip_tags($searchTerms); // remove any html/javascript.
if (strlen($searchTerms) < 3) {
$error[] = "Search terms must be longer than 3 characters.";
}else {
$searchTermDB = mysql_real_escape_string($searchTerms); // prevent sql injection.
}
// If there are no errors, lets get the search going.
if (count($error) < 1) {
$searchSQL = "SELECT name, ssn FROM simple_search WHERE ";
// grab the search types.
$types = array();
$types[] = isset($_GET['name'])?"`name` LIKE '%{$searchTermDB}%'":'';
$types[] = isset($_GET['ssn'])?"`ssn` LIKE '%{$searchTermDB}%'":'';
$types = array_filter($types, "removeEmpty"); // removes any item that was empty (not checked)
if (count($types) < 1)
$types[] = "`name` LIKE '%{$searchTermDB}%'"; // use the name as a default search if none are checked
$andOr = isset($_GET['matchall'])?'AND':'OR';
$searchSQL .= implode(" {$andOr} ", $types) . " ORDER BY `ssn`"; // order by ssn.
$searchResult = mysql_query($searchSQL) or trigger_error("There was an error.<br/>" . mysql_error() . "<br />SQL Was: {$searchSQL}");
if ($num_rows < 1 ) {
echo '<b>No Titles Found.</b><br><br><br>';
}
}else {
$results = array(); // the result array
$i = 1;
while ($row = mysql_fetch_assoc($searchResult)) {
$results[] = "{$i}: {$row['ssn']}<br /><br />{$row['name']}<br /><br />";
$i++;
}
}
}
function removeEmpty($var) {
return (!empty($var));
}
?>
<html>
<title>My Simple Search Form</title>
<style type="text/css">
#error {
color: red;
}
</style>
<name>
<?php echo (count($error) > 0)?"The following had errors:<br /><span id=\"error\">" . implode("<br />", $error) . "</span><br /><br />":""; ?>
<form method="GET" action="<?php echo $_SERVER['PHP_SELF'];?>" name="searchForm">
Search For: <input type="text" name="search" value="<?php echo isset($searchTerms)?htmlspecialchars($searchTerms):''; ?>" /><br />
Search In:<br />
name: <input type="checkbox" name="name" value="on" <?php echo isset($_GET['name'])?"checked":''; ?> /> |
ssn: <input type="checkbox" name="ssn" value="on" <?php echo isset($_GET['ssn'])?"checked":''; ?> /> |
/><br />
Match All Selected Fields? <input type="checkbox" name="matchall" value="on" <?php echo isset($_GET['matchall'])?"checked":''; ?><br /><br />
<input type="submit" name="submit" value="Search!" />
</form>
<?php echo (count($results) > 0)?"Your search term: {$searchTerms} returned:<br /><br />" . implode("", $results):""; ?>
</name>
</html>
When I try this, it gives me this message:
Parse error: syntax error, unexpected '}' in /home/olsendai/public_html/sqlfour.php on line 65.
Help. Please!
It seems simple, but when I remove the unexpected '}', it comes back with this error - before I have even used the search feature
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/olsendai/public_html/sqlfour.php on line 60
The following had errors:
Search terms must be longer than 3 characters.
Self Updating MySQL database from mirrored database
in MySQL Help
Posted
Hello everyone. The last time I posted on this site I received kindness and fantastically amazing help. My advanced apologies for any stupidity involved here. If this is one of those questions that has been answered countless time, a simple reference to the URL of the post will suffice. I'm just not having any luck with my searches.
Here is my situation:
I presently have a PHP page set up to do a search from a MySQL database. It's humming along nicely thanks to the help I got here. The MySQL database is updated every few days by ME, using the import feature and a CSV file. The CSV file is created by exporting the data from a program called Time Matters. Right now I just use the program's features to export this to a CSV and yadda, yadda, yadda...
But, I know this is a lame way to go. I need to create a way to make this thing self update. Time Matters is on a SQL platform. It seems like I should be able to get into that data (I have done this before for trial prep with our other SQL programs and Access) and mirror it on a server somewhere, and then ???
Please help! This is one of those problems where I don't really even fully understand my problem enough to grasp the problems of the steps. I'm having major surgery in a few weeks and if there is anyway this thing could self-automate, it would be a huge relief! Thank you!