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

$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 }

Recommended Answers

All 10 Replies

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 ' '.

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

Its not work, still same error appear..

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.

Member Avatar
$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.

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)
$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.

Member Avatar

Try to connect with connect

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

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.

Member Avatar
// 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.

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

Member Avatar

Mark the thread as solved.

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.