Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2011
    Posts
    4

    Unanswered: Update NAME_OF_SITE problem Need Help

    I'm having trouble with this cant get it to work


    This below will make a text box; in the text box you would put the name of whatever the site would be
    then once you press next then it would update the sql table like text scrapping in the TABLE_metatags; Its supossed to rename the ="NAME_OF_SITE" PART but I cant get it to work proper it wont update
    this part I've tried lots of things but no luck just yet.

    this PHP page is form.php; this example calls once
    Code:
    <td class="inputField"><?php echo 'name of site<br />' . draw_input_field('SITE_CEW', null, 'class="text"'); ?></td>

    then update works like this goes and updtes the Table_metatags
    Code:
    db_query('update ' . table_metatags . ' SET id = "' . trim($HTTP_POST['SITE_CEW']) . '" WHERE meta name = "description" AND Content = "NAME_OF_SITE"');

    And this is the last thing it will do is rename the meta name in the
    Table_metatags below example

    Code:
    -- Table structure for table `metatags`
    --
    
    CREATE TABLE IF NOT EXISTS `metatags` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `mtags` text NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
    
    --
    -- Dumping data for table `metatags`
    --
    
    INSERT INTO `metatags` (`id`, `mtags`) VALUES
    (1, '<meta name="description" content="NAME_OF_SITE" />\r\n<meta name="keywords" content="WHAT_ITS_ABOUT" />\r\n<meta name="author" content="THE_AUTHOR" />\r\n');


    I need help with this I tried many things I know I'm close but
    still cant seem to break this to make it work

    Any help would grateful!!

    Thank you much,

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    what you gotta do is test your sql outside of php first

    that way, you will obtain the benefit of seeing the actual mysql error message when you do stuff like this --
    Code:
    WHERE meta name = "description"
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jun 2011
    Posts
    4

    Update NAME_OF_SITE problem Need Help

    your right r937,
    I test the code by adding or die (mysql_error()); at end of the below code:

    <code>db_query('update ' . table_metatags . ' SET id = "' . trim($HTTP_POST['SITE_CEW']) . '" WHERE meta name = "description" AND Content = "NAME_OF_SITE"') or die (mysql_error());</code>

    same problem I suspected. but, don't know which should be in after the WHERE
    statement thats where I have been hung up!

    Need help on what belongs in after the WHERE = "NAME_OF_SITE"');

  4. #4
    Join Date
    Jun 2011
    Posts
    4
    this was the result of running this test on the code below:

    Code:
    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 'name = "description" AND Content = "NAME_OF_SITE"' at line 1

    Still need a hand on this, my mind is still duh at this point, Momentarily?
    Thanks ahead of time!!!

  5. #5
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    This usually indicates that the error is just before 'name = "description"...'. If you check the syntax of the statement you will see your problem.
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

  6. #6
    Join Date
    Jun 2011
    Posts
    4
    Tryed still hung up on this and need help on this it will not update

  7. #7
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by tonycoding View Post
    Tryed still hung up on this and need help on this it will not update
    please show the exact query that you pass to mysql

    not the php code that produces the query, but the actual query itself

    then show the entire error message
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  8. #8
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    Can you show us your table definition? Your issue is with the field meta name. This must be encapsulated within `meta name`as it should appear as a single field name.
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

  9. #9
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by it-iss.com View Post
    Can you show us your table definition?
    he already did, in post #1

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •