Jump to content

jcg31

Members
  • Posts

    11
  • Joined

  • Last visited

jcg31's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Recordset2 comes from the tasks table that contains tasks associated with a particular category of books and marketing of same. Recordset1 has the details of each category. Both tables have category_id as a field. The application takes the contents of Recordset2 and presents the tasks contained within in table form using a repeater; the category_id is included in a hidden field. I want the user to be able to hover over a particular task and have a tooltip come up that provides the detail of that category from Recordset1 using the category_id in the hidden field.
  2. Recordset1 as from a database call.
  3. Thanks Mac_gyver. Learned (learning) from forums like this one, bunches of views on how to do things, I apparantly picked the wrong one. My iterating through the recordset was just for the purpose of testing my real need (but good to get your input on that). My real question is how to retrieve a particular row in the recordset? Got my current approach from http://stackoverflow.com/questions/6782615/display-specific-line-or-record-of-a-recordset. So, if Recordset1= Book1 Author1 Cost1 Remainder1 Book2 Author2 Cost2 Remainder2 Book3 Author3 Cost3 Remainder3 Book4 Author4 Cost4 Remainder4 What is the best way to retreive Cost3? Thanks, Jim
  4. I am getting an "Unable to jump to row 155 on MySQL result index 4 in C:\wamp\www\Inventory.php on line 64" . This code is just test code to try and isolate this " unable to jump" issue that I am having with a bigger project In the test code I first tried iterating through the recordset (see code below) which worked without issue, providing the output I would have expected and wanted (including category_id 155). The category_id is what I am incrementing, so the test verified that the proper id was being passed and that the proper category_label and category_id was being returned. I then tried accessing the category_label using <?php echo mysql_result($Recordset1, 155, 2); ?> (line 64 in the code) And it threw the error. Any help would be appreciated. Thanks, Jim mysql_select_db($database_Inventoryserver, $Inventoryserver); $query_Recordset1 = "SELECT * FROM category"; $Recordset1 = mysql_query($query_Recordset1, $Inventoryserver) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); mysql_select_db($database_Inventoryserver, $Inventoryserver); $query_Recordset2 = "SELECT * FROM tasks "; $Recordset2 = mysql_query($query_Recordset2, $Inventoryserver) or die(mysql_error()); $row_Recordset2 = mysql_fetch_assoc($Recordset2); $totalRows_Recordset2 = mysql_num_rows($Recordset2); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Welcome</title> </head> </head> <body> <?php echo mysql_result($Recordset1, 155, 2); ?> <table width="900" border="1"> <?php $i=0; do { ?> <tr> <td><?php echo $row_Recordset1['category_label']; ?></td> <td><?php echo mysql_result($Recordset1, $i, 2); ?></td> <td><?php echo $row_Recordset1['category_id']; ?></td> </tr> <?php $i++ ?> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> </table> </body> </html> <?php mysql_free_result($Recordset1); mysql_free_result($Recordset2); ?>
  5. I gave htmlentites a shot in the following manner. Same result, what am I doing wrong? $theresult= htmlentities($result->ProspectName,ENT_QUOTES); echo <<<html <li onClick="fill('{$result->ProspectName}','{$result->id}','{$result->assignedrep}','1');">{$theresult}</li> html;
  6. Absolutely, http://forums.phpfreaks.com/topic/277621-apostrophe-messing-with-ajax-results/ Thanks again.
  7. I am using some code that I have seen on a number of forums to search a database using ajax and return a result from the `ProspectName` field (written by Amit Sarwara and apparently working fine for others) . All works fine until the name of the prospect contains an apostrophe. Advice from another forum suggested using addslashes with the result $theresult=addslashes($result->ProspectName); echo <<<html <li onClick="fill('{$result->ProspectName}','{$result->id}','{$result->assignedrep}','1');">{$theresult}</li> html; and while that added the slash it didn't resolve the issue. the attachment to this post provides firebug's feedback. Any help would be apprecitated. Thanks, Jim Here is the code: <?php // PHP5 Implementation - uses MySQLi. // Written by Amit Sarwara // mysqli('localhost', 'yourUsername', 'yourPassword', 'yourDatabase'); $db = new mysqli('127.0.0.1', 'root' ,'', 'progadad'); if(!$db) { // Show error if we cannot connect. echo 'ERROR: Could not connect to the database.'; } else { // Is there a posted query string? if(isset($_POST['queryString'])) { $queryString = $db->real_escape_string($_POST['queryString']); // Is the string length greater than 0? if(strlen($queryString) >0) { // Run the query: We use LIKE '$queryString%' // The percentage sign is a wild-card, in my example of countries it works like this... // $queryString = 'Uni'; // Returned data = 'United States, United Kindom'; // YOU NEED TO ALTER THthE QUERY TO MATCH YOUR DATABASE. // eg: SELECT yourColumnName FROM yourTable WHERE yourColumnName LIKE '$queryString%' LIMIT 10 $query = $db->query("SELECT id, ProspectName, prospectorFullName, assignedrep FROM captureddata WHERE ProspectName LIKE '$queryString%' LIMIT 8"); if($query) { // While there are results loop through them - fetching an Object (i like PHP5 btw!). while ($result = $query ->fetch_object()) { // Format the results, im using <li> for the list, you can change it. // The onClick function fills the textbox with the result. // YOU MUST CHANGE: $result->value to $result->your_colum echo <<<html <li onClick="fill('{$result->ProspectName}','{$result->id}','{$result->assignedrep}','1');">{$result->ProspectName}</li> html; } } else { echo 'ERROR: There was a problem with the query.'; } } else { // Dont do anything. } // There is a queryString. } else { echo 'There should be no direct access to this script!'; } } ?>
  8. And you nailed it. Many thanks. Any thoughts on the ajax apostrophe issue that I mistakenly had as a related issue?
  9. Ah, yes, sorry, and thanks for sticking with me. The field with the special character issue is actually "ProspectName" not "businessname' as mentioned in my first post. I mistakenly posted the wrong code because it was my more recent discovery of the issue with "PropspectName". In that case it is the apostrophe with the line of code immediately below (from the code offering above). If I eliminate the apostrophe the prospect name will populate the textbox in an ajax search, with the apostrophe included it won't. Code fails at: <li onClick="fill('{$result->ProspectName}','{$result->id}','{$result->assignedrep}','1');">{$result->ProspectName}</li> With the code below the issue is the ampersand, take it out and all the copy that is suppose to follow appears, put it in and the last word that appears is "Coffee" (of Pete's Coffee & Tea) . . . <?php /*Recordset1*/ $colname_Recordset1 = "-1"; if (isset($_GET['id'])) { $colname_Recordset1 = $_GET['id']; } mysql_select_db($database_localserver, $localserver); $query_Recordset1 = sprintf("SELECT * FROM captureddata WHERE id = %s", GetSQLValueString($colname_Recordset1, "int")); $Recordset1 = mysql_query($query_Recordset1, $localserver) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); $val=$totalRows_Recordset1; ?> ...Table with bunches of content not affecting issue ... </label></td> </tr> <tr> <td height="24" align="right"> <td height="24" align="right"><?php $RepName= $row_Recordset1['assignedrep']; $firstLast= explode(" ",$RepName); $firstName=$firstLast[0] ?> <?php $myToString= $row_Recordset2['email'];?><!-- email recipient --> <?php $mySubjectString="New Prospect Assignment"; ?> <?php $myCCString= $row_Recordset3['mgrEmail']; ?> <?php $myMgrSignoff= $row_Recordset3['mgrFirstName']; ?> <?php $myPptrName= $row_Recordset1['ProspectorsName']; ?> <?php $myIDName= $row_Recordset1['id']; ?> <?php if ($myToString==""){$myToString="You need to make the assignment before sending email.";}?> <input type="submit" name="btnSubmit" id="btnSubmit" value="Assign to Account Rep" onmousedown= "mymailfunction()" /> <tr> <td height="24" align="right"> <td height="24" align="right"> <a href ="https://mail.google.com/mail/?view=cm&ui=2&tf=0&fs=1&to=<?php echo $row_Recordset2['email'];?>&su=New Prospect Assignment&body= <?php echo $firstName.", ";?>%0D%0A%0D%0A I have assigned <?php echo $row_Recordset1['ProspectName']; ?> as a new prospect for you to call on this week.%0D%0A%0D%0ADetails of the prospect profile created by <?php echo $row_Recordset1['prospectorFullName']; ?> can be found at http://www.nccmprospects.com/narrativeonly.php?id=<?php echo $myIDName;?> .%0D%0A%0D%0APlease claim your lead by going to http://www.nccmprospects.com/AdRepInputNnav.php?id=<?php echo $myIDName;?> and selecting the Claimed radio button. %0D%0A%0D%0AThen as you make progress on the account, please update your progress by returning to the prospecting tool and selecting the 'Update Progress' in the 'Goto My Sales' section of the website.%0D%0A%0D%0AThanks,%0D%0A<?php echo $myMgrSignoff;?> "TARGET="_blank">SEND EMAIL</a> with the cod above it fails at I have assigned <?php echo $row_Recordset1['ProspectName']; ?> as a new prospect for you to call on...
  10. Sorry folk, was out of town, thank you for the responses. Here is the code written by Amit Sarwara and adapted for my purpose; <?php // PHP5 Implementation - uses MySQLi. // Written by Amit Sarwara // mysqli('localhost', 'yourUsername', 'yourPassword', 'yourDatabase'); $db = new mysqli('127.0.0.1', 'root' ,'', 'progadad'); if(!$db) { // Show error if we cannot connect. echo 'ERROR: Could not connect to the database.'; } else { // Is there a posted query string? if(isset($_POST['queryString'])) { $queryString = $db->real_escape_string($_POST['queryString']); // Is the string length greater than 0? if(strlen($queryString) >0) { // Run the query: We use LIKE '$queryString%' // The percentage sign is a wild-card, in my example of countries it works like this... // $queryString = 'Uni'; // Returned data = 'United States, United Kindom'; // YOU NEED TO ALTER THthE QUERY TO MATCH YOUR DATABASE. // eg: SELECT yourColumnName FROM yourTable WHERE yourColumnName LIKE '$queryString%' LIMIT 10 $query = $db->query("SELECT id, ProspectName, prospectorFullName, assignedrep FROM captureddata WHERE ProspectName LIKE '$queryString%' LIMIT 8"); if($query) { // While there are results loop through them - fetching an Object (i like PHP5 btw!). while ($result = $query ->fetch_object()) { // Format the results, im using <li> for the list, you can change it. // The onClick function fills the textbox with the result. // YOU MUST CHANGE: $result->value to $result->your_colum //print_r($result); $theresult=addslashes($result->ProspectName); echo <<<html <li onClick="fill('{$result->ProspectName}','{$result->id}','{$result->assignedrep}','1');">{$result->ProspectName}</li> html; } } else { echo 'ERROR: There was a problem with the query.'; } } else { // Dont do anything. } // There is a queryString. } else { echo 'There should be no direct access to this script!'; } } ?>
  11. I have a database that has as a field `businessname`. I do a number of things with this field that are working fine, like populating textboxes, printing out as echo in any number of uses (<?php echo Recordset1['businessname'] ?>). But for some reason when I try to echo in precisely the same fashion in an automated gmail all I get is "Pete's Coffee" and none of the subsequent text that normally accompanies the name of the business appears. I know that the & is a special character but just as I have no idea why it is causing an error to be thrown, I can't understand why it appears fine in others. Given that the string resides in fine shape in the database (with apostrophe and ampersand intact) is there something I can do to sanitize the string when retreived by a query so it can be used in all applications? Any help will be appreciated. Jim
×
×
  • 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.