0

I have this error.. Can help me to solve this matter?

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '296''' at line 1

1 <?php include("db.php"); ?>

11 <?php
12 $Kod=$_REQUEST;
13 echo "$Kod";
14 ?>

Value has been passed succ. VALUE = 296

<?php
$query="SELECT * FROM hartanah_pt WHERE JKODPRO='$Kod'";
$result=mysql_query($query) or die(mysql_error());

This is my SQL query

39 while($row= mysql_fetch_array($result))
40 {
41 $JKODPRO_HAR=$row;
42 $HAR_KOD=$row;
43 }

3
Contributors
10
Replies
11
Views
7 Years
Discussion Span
Last Post by rajarajan07
0

Try this for your sql statement $query="SELECT * FROM hartanah_pt WHERE JKODPRO='{$Kod}'"; and when using numbers (integers) like id etc. You don't have to enclose them with ' '.

Edited by Timon87: n/a

0

$query="SELECT * FROM hartanah_pt WHERE JKODPRO='{$Kod}'"

Its not work, still same error appear..

0

What type of field is JKODPRO? if it is an integer try this query: $query="SELECT * FROM hartanah_pt WHERE JKODPRO=".$Kod.""; if it is not an integer try this query: $query="SELECT * FROM hartanah_pt WHERE JKODPRO='".$Kod."'";
What you could also do is try the query in phpmyadmin because it has a better error message.

0
$query="SELECT * FROM hartanah_pt WHERE JKODPRO='$Kod'";
echo $query;

Echo your query in browser and copy and paste in sql editor to check whether it is running. or it may be wrong table name or column name.

0

I cannot echo the query because it was failed since in 1st line. I think my database connection was not right.

Here is my d/base file connection (connection.php)
<?php
$hostname_connection = "localhost";
$database_connection = "zaza";
$username_connection = "root";
$password_connection = "";
$connection = mysql_pconnect($hostname_connection, $username_connection, $password_connection) or trigger_error(mysql_error(),E_USER_ERROR);
?>

And I include the file for all php files.
<?php include('connection.php'); ?>

Im not sure here either my connection is wrong / write. because I also have some problem like error "no database selected". Sometimes its work, and sometimes not.

0

Try to connect with connect

$connection = [B]mysql_connect[/B]($hostname_connection, $username_connection, $password_connection)
0

rajarajan07 : thank you for your help.. but it still cant work.

it showed 'no database selected'..
im new in PHP, XAMPP.. and all this.. it make hard for me when face the error.

0
// set database server access variables: 
$host = "localhost"; 
$user = "root"; 
$pass = ""; 
$db = "testdb"; 

// open connection 
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); 

// select database 
mysql_select_db($db) or die ("Unable to select database!");

Also check your xampp running both apache and mysql in you tray icons. Or open the xamp control panel to see whether it is checked.

0

ok.. thank.. its something wrong on my query.. not on my dbase connection.. its solved already.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.