Jump to content

bertieboy_93

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

bertieboy_93's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I followed your advice and it worked brilliantly! I'd just like to express my thanks, it's fantastic that so many people are willing to help.
  2. I have an update script which receives some text from a session variable and updates an entry in the database with it. Apostrophes were usetting it. I have been told to use stripslashes and mysql_escape_string to solve the problem, but with the code below, at the beggining of each line and at each line break 'rn' is displayed. Here is my current update script: [code]<?php //Update database $query = "UPDATE Main SET PageHeading = '$pageheading', PageText = '$pagetext' WHERE PageName = '$pagename'"; $query = mysql_real_escape_string($query); $query = stripslashes($query); mysql_query($query) or die(mysql_error()); ?>[/code] Can someone please explain why this is happening? Thanks for any help you can give me.
  3. Here is my new update script. [code] <?php //Update database $query = "UPDATE Main SET PageHeading = '$pageheading', PageText = '$pagetext' WHERE PageName = '$pagename'"; $query = mysql_real_escape_string($query); $query = stripslashes($query); mysql_query($query) or die(mysql_error()); ?> [/code] The trouble is, at the beggining of each new line the letters rn are displayed. I don't know why this is happening. EDIT: Someone seems to be having a similar problem here: [url=http://www.phpfreaks.com/forums/index.php/topic,108657.0.html]http://www.phpfreaks.com/forums/index.php/topic,108657.0.html[/url]
  4. Wow! Thanks for responding so quickly. I did that and have determine that the problem is about apostrophes in the text field. Is there any way of stopping mysql getting upset about apostrophes?
  5. Hi, I'm not sure if this is a php problem or mysql problem, so sorry if this is in the wrong forum. I have a form which is used for a cms. You enter text into the form, it sends the data to a confirmation page just so you can check for any typos etc. Then it stores the data from the form into a session and passes it onto the update script when the user presses OK. Sometimes this all works great, and the entry in the database. Other times, it doesn't update. Everything is passed onto the confirmation dialogue fine, so it can't be a problem with my form. What I'm puzzled about is why it isn't always updating the database entry correctly. A lot of the time this happens when pasting from notepad, but I can't see why this would be a problem. My update script: [code] <? /* $pagename is a way of identifying which record to update in the database. $pageheading is the pageheading data retrieved from a session variable from the confirmation page. $pagetext is the pagetext data retrieved from a session variable from the confirmation page. PageHeading is varchar PageText is mediumtext */ //Update database $query = "UPDATE Main SET PageHeading = '$pageheading', PageText = '$pagetext' WHERE PageName = '$pagename'"; mysql_query($query); echo "Your changes on the $pagename page have been saved."; ?>[/code] Thanks in advance for any help.
  6. Thanks for replying so quickly and providing me with valuable information.
  7. [code]<? echo "<img src=\"" . $target_directory$id[color=red][i][b].[/b][/i][/color]jpeg . "\" alt=\"" . $comments . "\"/>" ?>[/code] The variable $target_directory = "../../images/" and $id is the id in a mysql database. In the source code of my browser it reads: [code]<img src="0jpeg" alt="e3"/>[/code] So the period between $id and jpeg has been removed, breaking the link.
  8. Hi, I'm a newbie to PHP and have very little experience so sorry if this is a stupid question. As far as I can tell, PHP ignores periods ([color=red][size=18pt][i][b].[/b][/i][/size][/color]). I have a php script which involves changing a filename and I cannot get the file extension to work because the periods are removed. So the file test.jpg is processed by the server and delivered to the browser as testjpg This obviously results in broken links. I'm sure there is an obvious solution but I have searched php.net and google and these returned nothing.
  9. Thanks for the solution, it worked great!
  10. No, I don't mean not the full URL. I mean site relative as in: <? include("[color=red][b]/[/b][/color]page.php"); ?>
  11. I have browsed the internet and have learnt that you cannot use PHP includes with site relative linking. I was wondering if there was any alternative way where I could use PHP to include a file using a site relative link to define the include file. As far as I know there isn't, and a google search hasn't shown an alternative. I can't use an SHTML file for the include as I have important PHP scripts on the page. Does anyone know of any sort of alternative or solution? Many thanks to anyone who can help.
  12. Great! That worked perfectly. It looks like there was quite a lot wrong with my code! I haven't got much knowledge of PHP or MySQL, I've just been following through numorous online tutorials. Thanks for such a speedy response, your help has been very valuable to me. Thanks again. Rob.
  13. Hi. I'm a newbie to these forums and to PHP, so please forgive me if the answer is something obvious. I am using a mysql database to store text which will be loaded onto my web pages. I want to use $_SERVER['PHP_SELF'] in order to identify the page that is currently open, and then match it up to the correct entry in the database. (by identifying the current page URL, and then matching that up to the URL field in the database). The problem is that I am receiving a Parse error, and it always identifies the line which contains $_SERVER['PHP_SELF'] as the culprit. The exact error is: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING... My PHP code is below. [code] <? //Define variables $username="XXX"; $password="XXX"; $database="XXX"; $URL="$_SERVER['PHP_SELF']"; //Connect to database mysql_connect(localhost,$username,$password); @mysql_select_db($database)or die(mysql_error()); //Select information from database $query = "SELECT PageHeading FROM Main WHERE PageURL=$URL"; $result = mysql_query($query); if (!$result) {   die('Could not query:' . mysql_error()); } //Display text echo mysql_result($result,0); ?> [/code] I tried manually typing in the URL rather than using $_SERVER['PHP_SELF'] but this returned the MySQL error: Could not query:Unknown column 'index.php' in 'where clause' The only thing that does work is manually typing in the Page_ID (primary key). Does anyone know a solution where I can use a script to determine the current page and then retrieve the correct entry from a MySQL database. I'd be incredibly grateful to anyone that could help.
×
×
  • 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.