Page 1 of 1
PHP & mySQL Query
Posted: Tue Oct 07, 2008 5:01 pm
by bcyork
$content = mysql_query("SELECT * FROM 'content' WHERE 'purl' = "$purl"", $DBCNX);
I am getting this error for the above line. Parse error: syntax error, unexpected T_VARIABLE
I have been trying to figure it out and can't any ideas? I'm new a this.
I can post more if it will help
Re: PHP & mySQL Query
Posted: Tue Oct 07, 2008 5:03 pm
by VladSun
Column/table names in MySQL are surrounded with the ` symbol, not like the MS SQL - the ' symbol.
Also string concatenation is done this way:
Code: Select all
$string2 = "You are looking at " . $string1 . " - the first string value concatenated"
Re: PHP & mySQL Query
Posted: Tue Oct 07, 2008 6:19 pm
by bcyork
It seems like everyone has a different syntax. Some people say to put periods before variables ... does that do anything besides cause more errors. Some of the simplest things there are about 5 different ways people write it varying ) ' . " ] all in different places. (I'm speaking of people not on this forum)
So the above post helped get rid of the errors but I still can't get anything to show up from the data base.
Is their any issues with any of this?
Code: Select all
<?php require_once("cnx.php");
mysql_select_db("DBname", $DBCNX);
$content = mysql_query("SELECT * FROM 'content' WHERE 'purl' = '$purl'", $DBCNX);
mysql_close($DBCNX);
?>
<title>
<?php if ($purl == "index") {
echo $content[title]; echo "Static Title Home Page.";
} else {
echo $content[title]; echo "Static Title";
}
?>
</title>
cnx.php
Code: Select all
<?php
$DB_HOST = 'localhost';
$DB_USER = 'hpread';
$DB_PW = 'sdfsdfsdfsdf';
$DBCNX = mysql_connect($DB_HOST, $DB_USER, $DB_PW);
if (!$DBCNX)
{
die('Could not connect: ' . mysql_error());
}
?>
Re: PHP & mySQL Query
Posted: Tue Oct 07, 2008 6:36 pm
by VladSun
VladSun wrote:Column/table names in MySQL are surrounded with the ` symbol, not like the MS SQL - the ' symbol.