Reputation: 4505
I am fairly new to PHP and MySQL and am trying to write a code where I display all the values of the column value
where the column attribute_id = 64
. This is what I have written but I can't seem to get it to display:
<?
mysql_connect ("localhost","cpsdev_mage1","**********");
mysql_select_db ("cpsdev_mage1");
$sql = "select 'value' from mage_catalogsearch_fulltext
WHERE 'Attribute_id' = 64";
$result = mysql_query ($sql) or die($myQuery."<br/><br/>".mysql_error());
while($row = mysql_fetch_array($result))
{
echo $row['value'];
}
?>
Upvotes: 0
Views: 285
Reputation: 3845
As a solution to your problem please try executing the below query
$sql = "select value from mage_catalogsearch_fulltext
WHERE 'Attribute_id' = 64";
In sql query columns do not need to be enclosed in quotes. and also prefer using php full tags instead of short tags as in some servers short tags might be set to off which can create problems across different server environments
Upvotes: 0
Reputation: 26732
Try this code-
<?php
mysql_connect ("localhost","cpsdev_mage1","**********");
mysql_select_db ("cpsdev_mage1");
$sql = "select value from mage_catalogsearch_fulltext WHERE Attribute_id = 64";
$result = mysql_query ($sql) or die($myQuery."<br/><br/>".mysql_error());
while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
echo $row['value'];
}
?>
What i added --
<?
to <?php
.mysql_fetch_array($result,MYSQL_ASSOC)
.Upvotes: 0
Reputation: 2246
$sql = "select value from mage_catalogsearch_fulltext WHERE Attribute_id = 64";
Also your code should begin with <?php
not <?
Upvotes: 0
Reputation: 5605
<?php // instead of <?
mysql_connect ("localhost","cpsdev_mage1","**********");
mysql_select_db ("cpsdev_mage1");
$sql = "SELECT value FROM mage_catalogsearch_fulltext
WHERE Attribute_id = 64"; // <------------ removed un-needed single quotes
$result = mysql_query ($sql) or die("<br/><br/>".mysql_error()); // removed '$myQuery'
while($row = mysql_fetch_array($result))
{
echo $row['value'];
}
?>
Upvotes: 0
Reputation: 89
Try this :-
$sql = "select value from mage_catalogsearch_fulltext WHERE Attribute_id = 64";
Upvotes: 1