If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Update NAME_OF_SITE problem Need Help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-25-11, 13:23
tonycoding tonycoding is offline
Registered User
 
Join Date: Jun 2011
Posts: 4
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,
Reply With Quote
  #2 (permalink)  
Old 06-25-11, 13:46
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
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"
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 06-25-11, 14:35
tonycoding tonycoding is offline
Registered User
 
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"');
Reply With Quote
  #4 (permalink)  
Old 06-25-11, 14:46
tonycoding tonycoding is offline
Registered User
 
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!!!
Reply With Quote
  #5 (permalink)  
Old 06-25-11, 15:12
it-iss.com it-iss.com is offline
Registered User
 
Join Date: Sep 2009
Location: San Sebastian, Spain
Posts: 620
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
Senior Oracle/MySQL DBA
http://www.it-iss.com
Reply With Quote
  #6 (permalink)  
Old 06-25-11, 20:32
tonycoding tonycoding is offline
Registered User
 
Join Date: Jun 2011
Posts: 4
Tryed still hung up on this and need help on this it will not update
Reply With Quote
  #7 (permalink)  
Old 06-26-11, 00:12
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #8 (permalink)  
Old 06-26-11, 05:48
it-iss.com it-iss.com is offline
Registered User
 
Join Date: Sep 2009
Location: San Sebastian, Spain
Posts: 620
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
Senior Oracle/MySQL DBA
http://www.it-iss.com
Reply With Quote
  #9 (permalink)  
Old 06-26-11, 06:26
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
Quote:
Originally Posted by it-iss.com View Post
Can you show us your table definition?
he already did, in post #1

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On