Jump to content

[SOLVED] SQL Syntax Error


SkyRanger

Recommended Posts

I have been fighting with this for about an hour, it is late, I can't see the problem.  Somebody have a look at this and let me know that the heck I am doing wrong:

 

if (empty($_SESSION['language']['lid'])) {
$_SESSION['language']['lid'] = "1";
}

// mysql
include "inc/dbinfo.inc.php";

$connection=mysql_connect ("$dblocation", "$dbusername", "$dbpassword") or die ('I cannot connect to the database because: ' . mysql_error());

$result = mysql_query( "SELECT * FROM 'languages' WHERE lid = '" . $_SESSION['language'] ['lid'] . "'" ) or die(mysql_error());

 

Error I am getting is:

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 ''languages' WHERE lid = '1'' at line 1

Link to comment
https://forums.phpfreaks.com/topic/46226-solved-sql-syntax-error/
Share on other sites

That is the default until somebody chooses another language.

 

But I found another problem, that is starting to tick me off:

 

[b]Main PHP File[/b]

include "./inc/get_language.php";

include "./lang" . $object->lpath . "main.lang.php";
include "install/header.inc";

echo NAME;

include "install/footer.inc";

 

if (empty($_SESSION['language']['lid'])) {
$_SESSION['language']['lid'] = '1';
}

// mysql
[b]get_language.php file[/b]

include "inc/dbinfo.inc.php";

$connection=mysql_connect ("$dblocation", "$dbusername", "$dbpassword") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("$dbname");

$result = mysql_query( "SELECT * FROM languages WHERE lid = '" . $_SESSION['language']['lid'] . "'" ) or die(mysql_error());

 

And this is the error I am getting:

 

Warning: include(./lang/main.lang.php) [function.include]: failed to open stream: No such file or directory

 

Table data is:

____________________

|      languages          |

|__________________|

|    lid    | lpath        |

|__________________|

|    1    | /english/    |

|    2    | /french/    |

|__________________|

 

Can anybody see the problem?

Has anybody got any ideas, not sure if I am missing a piece of code in the main.php file or what.

 

The error I get is:

 

Warning: include(./langmain.lang.php) [function.include]: failed to open stream: No such file or directory in /home/mysite/public_html/main.php on line 6

Warning: include() [function.include]: Failed opening './langmain.lang.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/mysite/public_html/main.php on line 6

 

This is how I need it to include:

 

include './lang/english/main.lang.php';

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.