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

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

Posted: Tue Feb 08, 2005 1:14 am
by C_Calav
still out putting a blank value
Code: Select all
$P_Scale = $rowї'P_Scale'];
$P_Length = $rowї'P_Length'];
$P_Span = htmlentities( $rowї'$P_Span'], ENT_QUOTES );
$P_CostPrice = $rowї'P_CostPrice'];
$P_Price = $rowї'P_Price'];
$P_Desc = $rowї'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ї'REQUEST_METHOD'] == "POST")
{
# escape data and set variables
mysql_select_db('models') or die ("Could not select database!");
$P_Stock = stripslashes($_POSTї"P_Stock"]);
$P_Name = stripslashes($_POSTї"P_Name"]);
$P_Cat = stripslashes($_POSTї"P_Cat"]);
$P_Scale = stripslashes($_POSTї"P_Scale"]);
$P_Length = stripslashes($_POSTї"P_Length"]);
$P_Span = stripslashes($_POSTї"P_Span"]);
$P_CostPrice = stripslashes($_POSTї"P_CostPrice"]);
$P_Price = stripslashes($_POSTї"P_Price"]);
// grab foo and make sure it is in it's original state
if (get_magic_quotes_gpc())
{
$P_Desc = stripslashes($_POSTї"P_Desc"]);
}
else
{
$P_Desc = $_POSTї"P_Desc"];
}
// 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))
{
$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))
{
$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ї'file']ї'tmp_name'], '/var/users/modelair/deskjetmodels.co.nz/htdocs/pics/'.$_FILESї'file']ї'name']);
echo 'File has been stored in your uploads directory.';
echo "<br /><br /> <strong>new aircraft added</strong> <br /><br />";
echo realpath('.');
}
else
{
echo "<br /><br /> <strong> Duplicate Stockcode</strong> <br /><br />";
}
}
else
{
echo "<br /><br /> <strong>Make sure stock code AND name are filled out</strong>";
}
}
?>
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ї'$P_Span'], ENT_QUOTES );
to here:
Code: Select all
$P_Length = $rowї'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
