Can Someone Please Help Me With This PHP Error

Discussion in 'Programming' started by Fat_Man, Jun 18, 2011.

  1. #1
    I keep getting my own error which is "Could not execute query" but I cant figure out why. Can someone help me with this problem?

    
    <?php
    
    
    
    header("Content-Type: application/rss+xml; charset=ISO-8859-1");
    
    
    
    DEFINE ('DB_USER', 'username');
    
    DEFINE ('DB_PASSWORD', 'password');
    
    DEFINE ('DB_HOST', 'localhost');
    
    DEFINE ('DB_NAME', 'database');
    
    
    $rssfeed .= '<?xml version="1.0" encoding="UTF-8"?> 
    <rss version="2.0" xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" xmlns:ne="http://site.org/schemas/rss" > 
    <channel>';
    
    
    $rssfeed .= "\r\n\t\t<title>My Title</title>\r\n";
    
    $rssfeed .= "\t\t<link>http://www.site.org</link>\r\n";
    
    $rssfeed .= "\t\t<description>my website desciption</description>\r\n";
    
    $rssfeed .= "\t\t<language>en-us</language>\r\n";
    
    $rssfeed .= "\t\t<copyright>Copyright (C) 2011 site.org</copyright>\r\n";
    
    
    $connection = @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die('Could not connect to database');
    
    mysql_select_db(DB_NAME) or die ('Could not select database');
    
    
    
    $query = "
    
    SELECT
    
    	c.OfferTitle, 
    
    	c.Description,
    
    	c.DateAdded,
    
    	w.WebsiteName, 
    
    	w.WebsiteTitle
    
    FROM `Wrbsite_Offers` c 
    
    LEFT JOIN `Website` w ON w.WebsiteID = c.WebsiteID 
     
    
    ORDER BY
    
    	c.DateAdded DESC
    
    LIMIT 0, 25";
    
    $result = mysql_query($query) or die ("Could not execute query");
    
    
    
    while($row = mysql_fetch_array($result)) {
    
    	extract($row, EXTR_PREFIX_ALL, 'row');
    
    
    
    	$rssfeed .= "\t\t<item>\r\n";
    
    	$rssfeed .= "\t\t\t\t<description>" . htmlspecialchars($row_Description) . "</description>\r\n";
    
    	$rssfeed .= "\t\t\t\t<title>" . htmlspecialchars($row_OfferTitle . " - " . $row_WebsiteTitle) . " Coupon" . "</title>\r\n";
    
    	$rssfeed .= "\t\t\t\t<link>http://coupo.org/" . htmlspecialchars($row_WebsiteTitle) . "/</link>\r\n";
    
    	$rssfeed .= "\t\t\t\t<pubDate>" . date('r', strtotime($row_DateAdded)) . "</pubDate>\r\n";
    
    	$rssfeed .= "\t\t</item>\r\n";
    
    }
    
    
    
    $rssfeed .= "\t</channel>\r\n";
    
    $rssfeed .= '</rss>';
    
    
    
    echo $rssfeed;
    
    
    
    ?>
    PHP:

     
    Fat_Man, Jun 18, 2011 IP
  2. ByteCoder

    ByteCoder Active Member

    Messages:
    239
    Likes Received:
    2
    Best Answers:
    2
    Trophy Points:
    65
    #2
    `Wrbsite_Offers` and `Website`, should be 'Wrbsite_Offers' and 'Website'.
    Notice the kind of ' you're using.

    Good luck
     
    ByteCoder, Jun 18, 2011 IP
  3. Fat_Man

    Fat_Man Peon

    Messages:
    102
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you sir while the superquotes were not the problem you pointed out that the line that you sowed me was incorrectly spelled Wrbsite_Offers should be Website_Offers.. I fixed the misspelling and it worked.

     
    Fat_Man, Jun 18, 2011 IP
  4. ByteCoder

    ByteCoder Active Member

    Messages:
    239
    Likes Received:
    2
    Best Answers:
    2
    Trophy Points:
    65
    #4
    Funny. Atleast it works now :)
     
    ByteCoder, Jun 19, 2011 IP