Page 1 of 1

quotes [Solved]

Posted: Tue Feb 08, 2005 12:25 am
by C_Calav
hi guys,

i have some feilds (int) where i insert quotes eg 12 1/2"

inserts fine and displays fine.

but when i go to update it and i pull the values out of the DB the quotes arnt there..

here is my php for pulling the values out of the DB


Code: Select all

$query = "select * from planes where P_Stock= '$P_Stock'";

    $result = mysql_query($query);

    $num_results = mysql_num_rows($result);

     $row = mysql_fetch_array($result);

     $itemId = $rowї'itemId'];
     $P_Stock = $rowї'P_Stock'];
     $P_Name = $rowї'P_Name'];
     $P_Cat = $rowї'P_Cat'];
     $P_Scale = $rowї'P_Scale'];
     $P_Length = $rowї'P_Length'];
     $P_Span = $rowї'P_Span'];
     $P_CostPrice = $rowї'P_CostPrice'];
     $P_Price = $rowї'P_Price'];
     $P_Desc = $rowї'P_Desc'];

     mysql_close();
   
?>
these are the two feilds with the quotes.

Code: Select all

$P_Length = $rowї'P_Length'];
     $P_Span = $rowї'P_Span'];
how can i bring the quotes out to?

thanx

Posted: Tue Feb 08, 2005 12:47 am
by feyd
can we see a live example of this happening? Because I'm not quite understanding "displays fine. " and "how can i bring the quotes out to?" happening at the same time... :?: :?


7000 posts!!! 8)

Posted: Tue Feb 08, 2005 12:47 am
by C_Calav
is it to do with the way i am inserting them? or the way i am pulling the values out?

i have mucked around with addslashes and stripslashes but no luck. i just keep bring up the forward slash.

Posted: Tue Feb 08, 2005 12:51 am
by C_Calav
i cant really show you a example.

basicaly

i want to pull a value
12"
out of the DB and display it in a text box so i can update it. but when i pull it out of the DB it comes out as
12
with out the double quote

does that help feyd?

Posted: Tue Feb 08, 2005 12:53 am
by feyd
is the double quote in the html code though? if so, then it's inserting fine, you just need to encode it so the form field can show it:

Code: Select all

htmlentities( $rowї'whatever'], ENT_QUOTES );

Posted: Tue Feb 08, 2005 12:59 am
by C_Calav
can you explain what you mean by
s the double quote in the html code though?
?? i dont quite understand..


i changed my code to this:

Code: Select all

$P_Length = $rowї'P_Length'];
     $P_Span = htmlentities( $rowї'whatever'], ENT_QUOTES );
     $P_CostPrice = $rowї'P_CostPrice'];
     $P_Price = $rowї'P_Price'];
     $P_Desc = $rowї'P_Desc'];
and now does not display anything in the text box

Posted: Tue Feb 08, 2005 1:07 am
by feyd
you might want to change 'whatever' to 'P_Span' for instance.... :roll:

Posted: Tue Feb 08, 2005 1:09 am
by C_Calav
<span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> i didnt see that! 8O

Posted: Tue Feb 08, 2005 1:14 am
by C_Calav
still out putting a blank value

Code: Select all

$P_Scale = $row&#1111;'P_Scale'];
     $P_Length = $row&#1111;'P_Length'];
     $P_Span = htmlentities( $row&#1111;'$P_Span'], ENT_QUOTES );
     $P_CostPrice = $row&#1111;'P_CostPrice'];
     $P_Price = $row&#1111;'P_Price'];
     $P_Desc = $row&#1111;'P_Desc'];

here is my insert script in case it is something in that


Code: Select all

<?php
 
    $db = mysql_pconnect(**) or die ("Could not connect to database");

    # mysql_select_db('models') or die ("Could not select database!"); 

	# this is processed when the form is submitted
	# back on to this page (POST METHOD)
	if ($_SERVER&#1111;'REQUEST_METHOD'] == "POST") 
        &#123;
		# escape data and set variables
 		mysql_select_db('models') or die ("Could not select database!");

		$P_Stock = stripslashes($_POST&#1111;"P_Stock"]);
		$P_Name = stripslashes($_POST&#1111;"P_Name"]);
 		$P_Cat = stripslashes($_POST&#1111;"P_Cat"]);
		$P_Scale = stripslashes($_POST&#1111;"P_Scale"]);
		$P_Length = stripslashes($_POST&#1111;"P_Length"]);	
		$P_Span = stripslashes($_POST&#1111;"P_Span"]);
		$P_CostPrice = stripslashes($_POST&#1111;"P_CostPrice"]);
		$P_Price = stripslashes($_POST&#1111;"P_Price"]);
	
  
	// grab foo and make sure it is in it's original state   
	if (get_magic_quotes_gpc())
	&#123;       
		$P_Desc = stripslashes($_POST&#1111;"P_Desc"]);  
	&#125;    
	else    
	&#123;        
		$P_Desc = $_POST&#1111;"P_Desc"];    
	&#125;    
	
	// now make it ready to be inserted in our database    
	$P_Desc = mysql_real_escape_string($P_Desc, $db);   
 	
            
	if (!empty($P_Stock) && !empty($P_Name)) 
	&#123; 
		$sql1 = "select * from planes where P_Stock = '$P_Stock'"; 
		$result1 = mysql_query($sql1,$db) or die("Execution failed: ".mysql_error());
	  
		if (!mysql_num_rows($result1))
		&#123; 
			$sql  = "INSERT INTO planes (P_Stock, P_Name, P_Cat, P_Scale, P_Length, P_Span, P_CostPrice, P_Price, P_Desc) VALUES ('$P_Stock','$P_Name','$P_Cat','$P_Scale','$P_Length','$P_Span','$P_CostPrice','$P_Price','$P_Desc')";
			$result = mysql_query($sql, $db) or die ("Execution failed: ".mysql_error());

			move_uploaded_file($_FILES&#1111;'file']&#1111;'tmp_name'], '/var/users/modelair/deskjetmodels.co.nz/htdocs/pics/'.$_FILES&#1111;'file']&#1111;'name']); 
			echo 'File has been stored in your uploads directory.';
        
			echo "<br /><br /> <strong>new aircraft added</strong> <br /><br />";
		
			echo realpath('.');
		&#125;
		else
		&#123; 
			echo "<br /><br /> <strong> Duplicate Stockcode</strong> <br /><br />"; 
		&#125; 
           
	&#125; 
	else 
	&#123; 
      		echo "<br /><br /> <strong>Make sure stock code AND name are filled out</strong>"; 
	&#125; 


        &#125;

?>

Posted: Tue Feb 08, 2005 1:40 am
by feyd
you're having one of those days huh?

compare the row call here:

Code: Select all

$P_Span = htmlentities( $row&#1111;'$P_Span'], ENT_QUOTES );
to here:

Code: Select all

$P_Length = $row&#1111;'P_Length'];

Posted: Tue Feb 08, 2005 2:25 am
by C_Calav
u are right feyd, i am having one of those nights, just spent the last hour rebooting my home pc.

i am now on a borrowed laptop! ha!

i cant see the difference, what am i ment to be looking at...

one does one thing and the other its own, no?
compare the row call here:
Code:
$P_Span = htmlentities( $row['$P_Span'], ENT_QUOTES );

to here:
Code:
$P_Length = $row['P_Length'];

Posted: Tue Feb 08, 2005 2:35 am
by feyd
speficically:
$row['$P_Span']
vs.
$row['P_Length']

Posted: Tue Feb 08, 2005 2:36 am
by C_Calav
ha ha good one feyd i think i might need glasses :oops: