Jump to content

happy2learn

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

happy2learn's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm using MySQL version 4.1.21 Standard on a webhosting service in Australia. I have successfully set up a database online using phpMyAdmin version 2.8.2 and PHP version 4.4.4 I've been able to code pages to INSERT stuff and to SELECT stuff and I've successfully coded a page to display two fields in textareas, then save the edited stuff. The page that I post the edit form to displays the results without a hitch. However, when I try to UPDATE the table with the strings that have displayed the stuff, I get an error that I just cannot solve ... Here is the code I'm using: <?php $page2edit = $_POST["page_id"]; $description = stripslashes($_POST["description"]); $keywords = $_POST["keywords"]; echo "<p>The page to edit is " . $page2edit . "</p>"; echo "<p>Description:<br /><span style='color: red'>" . $description . "</span></p>"; echo "<p>Keywords:<br /><span style='color: green'>" . $keywords . "</span></p>"; $keywords = addslashes($keywords); THEN THE CONNECTION CODE (not included here for security reasons, but it works everywhere I've put it) $query = "UPDATE pages SET page_description=$description, page_keywords=$keywords WHERE page_id=$page2edit"; echo "<p>The SQL query is:<br />" . $query . "</p>"; mysql_query($query); if (mysql_affected_rows() == 1) { print '<p>The entry has been updated!</p>'; } else { print "<p>Could not update the entry because: <strong>" . mysql_error() . "</strong>.<br />The query was $query.</p>"; } mysql_close($con); ?> OK now have a look at what that produces ... The page to edit is 1 Description: A great homepage for anyone living in Australia's Blue Mountains Keywords: search engine blue mountains The SQL query is: UPDATE pages SET page_description=A great homepage for anyone living in Australia's Blue Mountains,page_keywords=search engine blue mountains WHERE page_id=1 [here's the error message stuff ...] Could not update the entry because: 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 'great homepage for anyone living in Australia's Blue Mountains,page_keywords=sea' at line 1. The query was UPDATE pages SET page_description=A great homepage for anyone living in Australia's Blue Mountains,page_keywords=search engine blue mountains WHERE page_id=1. I've tried putting single quotes around the string values but that doesn't work either. The table in the database uses page_id as an auto-incremented increment and page_description and page_keywords are two of the other fields. I can use phpMyAdmin for editing the database, but I'd rather do it by code I've written. No trouble with INSERT or SELECT queries - only with UPDATE. I'd be most grateful if anyone can show me why this is not working.
  2. Hi I'm trying to customise PHP pages by setting variables for the page Title and the Meta Tags for Description and Keywords. I did this by creating three variables - $title, $description and $keywords at the head of individual pages, then inserting the following code into my header.php file which delivers the header and left column (nav) to each page of the site: <title><?php echo $title ?></title> and similar code for the meta tags for description and keywords. No problems with Firefox, but in IE6 I get the $title printed at the top of the page instead of in the blue bar at the top of the browser. Yet no meta tags are printed on the page - but they appear normally along with the title in the page source. Is this a quirk in IE (which I loathe, but I know so many people use) or something I've done incorrectly in my code? In ASP you can write <% =strTitle %> but is there something similar in PHP that I haven't discovered yet? Any help will be greatly appreciated. Regards (from Australia) happy2learn
  3. Hi I've some experience with PHP, but I'm having great trouble integrating FCKeditor into my site. I've just transferred from ASP.NET back to PHP because I found I could do a lot of things in PHP without the bloated code I had to write for ASP.NET. Can anyone recommend a less complex online editor that would be more suitable for a less experienced PHP programmer? Open Source is great, but the documentation often assumes a knowledge level far beyond what an intermediate programmer would have. Any advice would be much appreciated.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.