I had two tables using INNER JOIN appears where the user information page. Now I needed to create another table and I am not able to do funcioncar with 3 tables together.
Follows the old code (with two tables) and below the current code with error (with three tables).
OLD CODE:
// Pega subdomínio
$urlExplode = explode('.', $_SERVER['HTTP_HOST']);
if (count($urlExplode) > 2 && $urlExplode[0] !== 'www') {
$subdomain = $urlExplode[0];
// echo $subdomain;
}
// Diz que o usuário é igual ao subdomínio
$usuario = $subdomain;
// Select DB da Tabela TEXTOS
$sql = "SELECT * FROM vms_textos i INNER JOIN vms_users u on u.id = i.id where u.usuario='$usuario'";
$result = mysql_query($sql);
if($result === FALSE) {
die(mysql_error());
// TODO: better error handling
}
else {
$row = mysql_fetch_array($result);
// Tabela Textos
$userKeywords = $row['userKeywords'];
$userDesc = $row['userDesc'];
$userTitleSite = $row['userTitleSite'];
$userTextSobre = $row['userTextSobre'];
$userTextContatos = $row['userTextContatos'];
$userTextMaisInfos = $row['userTextMaisInfos'];
}
CURRENT CODE
// Pega subdomínio
$urlExplode = explode('.', $_SERVER['HTTP_HOST']);
if (count($urlExplode) > 2 && $urlExplode[0] !== 'www') {
$subdomain = $urlExplode[0];
// echo $subdomain;
}
// Diz que o usuário é igual ao subdomínio
$usuario = $subdomain;
// Select DB da Tabela TEXTOS
$sql = "SELECT * FROM (vms_textos t INNER JOIN vms_users u ON u.id = t.id) INNER JOIN vms_cores c ON u.id = c.id where u.usuario='$usuario'";
$result = mysql_query($sql);
if($result === FALSE) {
die(mysql_error());
// TODO: better error handling
}
else {
$row = mysql_fetch_array($result);
// Tabela Textos
$userKeywords = $row['userKeywords'];
$userDesc = $row['userDesc'];
$userTitleSite = $row['userTitleSite'];
$userTextSobre = $row['userTextSobre'];
$userTextContatos = $row['userTextContatos'];
$userTextMaisInfos = $row['userTextMaisInfos'];
}
Thank you in advance for your help.