This topic is locked
[SOLVED]

 MySQL

7/17/2011 9:00:32 AM
PHPRunner General questions
A
Andrzej author

Hi

I have problem displaying prospect ID data in another table in prospect_id field. Hope someone can help.

I am using this code:
global $conn;

$strSQL = "SELECT name, surname from prospects where id =".$value;

$rs = db_query($strSQL,$conn);

$record = db_fetch_array($rs);
$value = $record['name'] . " " . $record['surname'];
In some pages it works and in some not... Do I need to change any settings?. If I will cannge just this field for HTML ( without custom code) it works properly.
I am receiving this message on some pages:
Technical information

Error type 256

Error description 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 '' at line 1

URL localhost/Manager/site_address_list.php?

Error file C:\Users\Andrzej\Documents\PHPRunnerProjects\Manager\output\include\dbconnection.php

Error line 36

SQL query SELECT name, surname from prospects where id =
Regards

Andrew

Sergey Kornilov admin 7/17/2011

You code will break if $value is empty. Here is how you can modify it:

if ($value)

{

global $conn;

$strSQL = "SELECT name, surname from prospects where id =".$value;

$rs = db_query($strSQL,$conn);

$record = db_fetch_array($rs);

$value = $record['name'] . " " . $record['surname'];

}
A
Andrzej author 7/17/2011



You code will break if $value is empty. Here is how you can modify it:

if ($value)

{

global $conn;

$strSQL = "SELECT name, surname from prospects where id =".$value;

$rs = db_query($strSQL,$conn);

$record = db_fetch_array($rs);

$value = $record['name'] . " " . $record['surname'];

}



The value wasn't empty. I am trying it in few different tables and it's not working in all of them.
I can't find what's wrong I am doing.
Andrew

A
Andrzej author 7/17/2011

Now it is not showing error with this code:

if ($value)

{

global $conn;

$strSQL = "SELECT name, surname from prospects where id =".$value;

$rs = db_query($strSQL,$conn);

$record = db_fetch_array($rs);

$value = $record['name'] . " " . $record['surname'];

}
but also not showing records from database, just title and empty column.
Andrew
p.s.

despite the trouble beginner "programmer" with very little experience in php and MySQL is slowly beginning to understand and enjoy what I do. I think that soon I will be able see the cool effects of my work.

Sergey Kornilov admin 7/17/2011

According to SQL Query from the your first post $value was empty:

SELECT name, surname from prospects where id =


We need to see your database in order to help. Post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.

A
anjeko 7/17/2011



According to SQL Query from the your first post $value was empty:
We need to see your database in order to help. Post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.


Hi Andrzej,
Please try this:
$strSQL = "SELECT name, surname from prospects where id = '$value'";
Powinno pracowac.
Jerry

A
Andrzej author 7/18/2011



Hi Andrzej,
Please try this:
$strSQL = "SELECT name, surname from prospects where id = '$value'";
Powinno pracowac.
Jerry


Pracuje <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=59533&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
Thanks