View Single Post
  #1  
Old 21st May 04, 07:30 PM
JacKDynne's Avatar
JacKDynne JacKDynne is offline
Administrator
 
Join Date: Oct 2001
Location: The Past Through Tomorrow
Posts: 1,591
JacKDynne will become famous soon enoughJacKDynne will become famous soon enough
Send a message via MSN to JacKDynne
Ok goes like this:

I have a php/mysql app that captures telephone calls via user entry, all works fine except for this - when users check to see if the caller has called before there is a query that lists previous callers by using this query:
Code:
$query = mysql_query("select `FirstName` , `LastName` from tracker ORDER BY `FirstName`") or die(mysql_error());
which when run directly against the db in mysql returns everything fine but when returned to the web page that calls it in php will not list those with the same last name or first name, depending on how I structure the query.

Here is the complete code (in the order that it's called):

viewclient.php


Code:
<? session_start(); header("Cache-control: private"); if ($_SESSION["loggedin"] != 1) { echo "Please login before trying to access this script."; exit(); } require("include/config.php"); include("templates/header.php"); $connection = mysql_connect ($host, $user, $pass) or die(mysql_error()); mysql_select_db ($db) or die (mysql_error()); $query = mysql_query("select `FirstName` , `LastName` from tracker ORDER BY `FirstName`") or die(mysql_error()); echo "<form name='frmClient' method='post' action='clientid.php'>"; echo "<table><tr><td class='formleft'>Please select a client:</td>"; echo "<td class='formright'><select name='client'>"; while ($line = mysql_fetch_row($query)) { if ($prev != $line[0] && $prev2 != $line[1]) { &nbsp;$line[0] = str_replace("\\","",$line[0]); &nbsp;echo "<option>" . $line[0] . " " . $line[1] . "</option>"; } $prev = $line[0]; $prev2 = $line[1]; } echo "</select></td></tr><tr><td class='formleft'>&nbsp;</td><td class='formright'>"; echo "<input type='submit' />&nbsp;<input type='reset' /></td></tr></table>"; include("templates/resultsfoot.php");
clientid.php:
Code:
<? session_start(); header("Cache-control: private"); if ($_SESSION["loggedin"] != 1) { echo "Please login before trying to access this script."; exit(); } require("include/config.php"); include("templates/header.php"); $connection = mysql_connect ($host, $user, $pass) or die(mysql_error()); mysql_select_db ($db) or die (mysql_error()); $names = explode(" ",$client); $query = mysql_query("select `index` , `Screening` from tracker WHERE `FirstName` = '$names[0]' AND &nbsp;`LastName` = '$names[1]' ORDER BY `index`") or die(mysql_error()); echo "<form name='frmClient' method='post' action='reports/client.php'>"; echo "<table><tr><td class='formleft'>Please select a call number:</td>"; echo "<td class='formright'><select name='callnumber'>"; while ($line = mysql_fetch_row($query)) { if ($prev != $line[0]) { &nbsp;$line[0] = str_replace("\\","",$line[0]); &nbsp;echo "<option>" . $line[0] . " Date entered: " . $line[1] . "</option>"; } $prev = $line[0]; } echo "</select></td></tr><tr><td class='formleft'>&nbsp;</td><td class='formright'>"; echo "<input type='submit' />&nbsp;<input type='reset' /></td></tr></table>"; include("templates/resultsfoot.php"); ?>
client.php:
Code:
<? ob_start("ob_gzhandler"); session_start(); header("Cache-control: private"); if ($_SESSION["loggedin"] != 1) { echo "Please login before trying to access this script."; exit(); } require("../include/config.php"); echo "<html style='overflow-x: hide'>\n<head>\n<title>\nWID Call Tracking\n</title>\n<link rel='stylesheet' type='text/css' href='../stylesheet/style.css' />\n</head>\n<body>\n<img src='../images/header.jpg' alt='' />\n<hr style='color: black; height: 1px' />\n"; $connection = mysql_connect ($host, $user, $pass) or die(mysql_error()); mysql_select_db ($db) or die (mysql_error()); $id = explode(" ",$callnumber); $query = mysql_query("select * from tracker WHERE `index` = '$id[0]'") or die(mysql_error()); $results = mysql_fetch_array($query) or die(mysql_error()); $index = 0; $cquery = mysql_query("select count(*) from descriptions") or die(mysql_error()); $count = mysql_result($cquery, 0); while($index != $count) { $results[$index] = str_replace("\\","",$results[$index]); $index = $index + 1; } echo "<table width='725' style='height: 70%' align='left'>\n"; $index2 = 1; $query2 = mysql_query("select `desc` from descriptions") or die(mysql_error()); while ($line = mysql_fetch_row($query2)) { $line[0] = str_replace("\\","",$line[0]); echo "\n<tr>\n<td class='formleft'>\n" . $line[0] . "\n</td>\n<td class='formright'>"; echo "\n" . $results[$index2] . "\n</td>\n</tr>\n"; $index2 = $index2 + 1; } include("../templates/resultsfoot.php"); ?>
Like I said, when I run the query straight against the db it returns all called just fine but when it's run via the browser it does not return any records that have the same name, depending on the ORDER BY order, in this case the firstname.

Any ideas? Puhhhhhhhhllllleeeeeeeeeeeeeeeeeeeeeeeeesssssse?

MUCHO TIA

/JD
__________________


Reply With Quote