Hello fourm members this is my first post. I am having a problem with a string in my code and cant figure it out... here is the code maybe someone here can assist me.
thanks in advance
-dellux

*#*#*#*#*#*#*#*#*#*#*#

<html>
<head>
<title>Loggin DB</title> 
</head>
<body>
<body bgcolor="#82CAFA">
<form method="get" action="loggin1.php">
Page:
<select name="Page"> 
<option value="approve.php" >Approve</option> 
<option value="custquery" >CustQuery</option> 
<option value="slpnlogin">SlpnLogin</option>
</select>
User Code:
<select name="User Code">
<option >T3</option>
<option >J9</option>
<option>BL</option>
<option >SC</option>
<option >MN</option>
<option >CA</option>
<option>MW</option>
<option >TJ</option>
<option >E2</option>
</select>
Date: 
<input type="text" name="Date">
<p><input type="submit" value="send"/></p></form>
<?php
echo $_GET['Page'];
$db = $_SERVER['DOCUMENT_ROOT']."/../data/log.db"; //connect to sql
$handle = sqlite_open($db);
$query = "SELECT * FROM  log where id > 85076";
if ($_GET["Page"] !="")
{	
	$query.=" 'and page=" .$_GET["Page"]. "and userCode=" .$_GET["UserCode"].'and time=' .$_GET['Time']."";
}
echo $query;
$result = sqlite_query($handle, $query);
$row = sqlite_fetch_array( $result );
echo "<table>";
while($row = sqlite_fetch_array($result)){
	echo "  <tr>\n";
	echo "    <td> $row[id]</td><td> $row[page]</td> <td>  $row[desc]  </td><td>  $row[userCode]  </td><td>  $row[codeType]  </td><td>". date( "Y-m-d", $row['time'])."</td><td>  $row[ipaddr]</td>\n";
	echo "  </tr>\n";
}
echo "</table>";
?>
</html>

*#*#*#*#*#*#*#*#*#*#*#
this is the error I recieve
*#*#*#*#*#*#*#*#*#*#*#

Notice: Undefined index: UserCode in c:\program files\Apache\htdocs\loggin1.php on line 36

Notice: Undefined index: Time in c:\program files\Apache\htdocs\loggin1.php on line 36
SELECT * FROM log where id > 85076 'and page=custqueryand userCode=and time=
Warning: sqlite_query() [function.sqlite-query]: near "'and page=custqueryand userCode=and time=": syntax error in c:\program files\Apache\htdocs\loggin1.php on line 39

Warning: sqlite_fetch_array() expects parameter 1 to be resource, boolean given in c:\program files\Apache\htdocs\loggin1.php on line 40

Warning: sqlite_fetch_array() expects parameter 1 to be resource, boolean given in c:\program files\Apache\htdocs\loggin1.php on line 42

*#*#*#*#*#*#*#*#*#

Member Avatar for Rhyan

your select name contains a space

<select name="User Code">

Remove the space and try again. This should solve your issue. The first error resolution should resolve the other issues by itself.
What editor you use for php editing. If it supports line numbering enable line numbering and you will find your errors easier, as php throws lines with errors.

thanx but that did not resolve the issue. it actually did nothing?!?!? im reallynew to coding so...lol

Member Avatar for Rhyan

You have a lot of code to clear. What error does php throw this time? Mind your spaces and quotes. Your sql query string should not have " ' and statement' 'and statement'" etc.
Check your code carefully and read the errors carefully as well. If you're new to coding, the best way to learn is to analyze and learn from your own mistakes. If someone solves your problems you'll never learn.

Could you repost your code, wrapping it with [icode][code][/icode]?

SQL querys should look like this:

$query = SELECT name FROM users WHERE " . $_GET['id'] = userid ."

Use concatation when dealing with text and variables/code. (Concatation is gluing strings together. For example, you would have [icode]$onlineusers= "There are " . $_GET['activeusers'] . "online";[/icode] instead of using quotation marks and apostrophes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.