Jump to content

displays strings with spaces fine in IE but nothing after the space in Firefox


DZaveski

Recommended Posts

I have a website that uses PHP and MySql to store and display information entered from the same site.  Strings with out spaces "HelloWorld" will save and display correctly in both IE and FF.  But strings with spaces "Hello World" work fine in IE but in FF only the first word is displayed and saved.  I am very new to all this so I am sure I am doing something fundamentally wrong. 
This is the code I use to save a string:
      $sql = "INSERT INTO names SET
                    `fname`='$fname',
                    `lname`='$lname'";
      if (@mysql_query($sql)){
        echo ("<center><font color=lime>Entry Added</font></center>");     
      }else{
        echo("entry failed".mysql_error());
      }

This is the code I use to get info:
  $result = @mysql_query("SELECT * FROM names WHERE key = '$logkey'");
  if(!$result) {
      die('<p>Error performing Query: '.mysql_error().'</p>');
  }else{
      $row=mysql_fetch_array($result);
      $fname = $row['fname'];
      $lname = $row['lname'];
  }

This is the code I use to display info:
echo(" 
First Name -
<input TYPE='TEXT' NAME='fname' SIZE='49' MAXLENGTH='49' VALUE=`$fname`><br>
Sail Number -
<input TYPE='TEXT' NAME='lname' SIZE='10' VALUE=`$lname`><br>
");

I am very new at this so be kind.
[code]
First Name -
<input TYPE='TEXT' NAME='fname' SIZE='49' MAXLENGTH='49' VALUE="$fname">

Sail Number -
<input TYPE='TEXT' NAME='lname' SIZE='10' VALUE="$lname">
[/code]

i found that the ` doesnt group data in all browsers, try using the " instead
Which field are you entering the 'Hello World' into?

With my INSERTs I make them look like this:
[code]
INSERT INTO names(fname, lname) VALUES ('{$fname}', '{$lname}')
[/code]

Does the 'Hello World' get stored in the database properly?
[quote author=SharkBait link=topic=115775.msg471488#msg471488 date=1164132177]
Which field are you entering the 'Hello World' into?

With my INSERTs I make them look like this:
[code]
INSERT INTO names(fname, lname) VALUES ('{$fname}', '{$lname}')
[/code]

Does the 'Hello World' get stored in the database properly?

[/quote]


I can put the hello world in either the Fname or Lname string it doesn't matter same result.
if I use IE the "hello world" gets stored correctly but in FF only up to the first space.  If the string is stored correctly but viewed from using FF I only see the first word even though it is stored correctly in the database.
[quote author=taith link=topic=115775.msg471486#msg471486 date=1164132177]
[code]
First Name -
<input TYPE='TEXT' NAME='fname' SIZE='49' MAXLENGTH='49' VALUE="$fname">

Sail Number -
<input TYPE='TEXT' NAME='lname' SIZE='10' VALUE="$lname">
[/code]

i found that the ` doesnt group data in all browsers, try using the " instead
[/quote]

I will try this... 

Here is a second question related to this issue only because it is the reason for my use of the ` mark.  Which is the proper way to code PHP:  I have been starting PHP "<?php" at the top of my code and using echo(" HTML "); for all my output to screens then ending PHP "?>" at the bottom.  This is why I could not use the " mark in my code. OR should I just start PHP "<?PHP" each time I have a PHP code then end it "?>" at the end of that code, so that I would be starting and stopping the PHP tags many times though out the code.  Sorry for such a basic question.
Either method is acceptable.

If you're within PHP and want to echo a double quote, you can either enclose that string in a single quote or escape it:
[code]<?php
echo 'This string contains a double quote "<br>';
echo "So does this string \"";
?>[/code]

There's also using the [url=http://us3.php.net/manual/en/language.types.string.php]HEREDOC[/url] method (look about 1/2 way down the page).

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.