Security issues related to php and mysql usage. How to make your code secure? Security measures and configurations? It's all in here!
Moderators: macek, egami, gesf
by gesf » Sat Feb 08, 2003 12:12 pm
Hi
Can anyone tell how can i show(print) a value from my db?
my field is int(10) and and using this code to show what is inside:
$test = mysql_query("SELECT myfield FROM mytable WHERE id = '1'");
echo "$test";
But it show '4' and not the value that is in that field.
I wanna know too, how can i show a value from the db with this format: 12.34567, using this code:
$test = number_format($test, 'something');
thanks
-

gesf
- Moderator

-
- Posts: 1718
- Joined: Sun Dec 29, 2002 5:03 am
- Location: Portugal
-
by Mixamajic » Tue Feb 11, 2003 5:45 am
- Code: Select all
$test = mysql_query("SELECT myfield FROM mytable WHERE id = 1");
$row=mysql_fetch_array($test);
echo $row["NameofIntField"]; //Leave the quotes in when you substitute the name of your DB field.
The 4 you are getting I think is a result resource. There are a couple other ways to do what you need, but this is the most flexible in my opinion.
-
Mixamajic
- New php-forum User

-
- Posts: 9
- Joined: Sun Feb 02, 2003 6:54 pm
- Location: Milwaukee
by gesf » Tue Feb 11, 2003 1:09 pm
Thanks a lot Mixamajic.
-

gesf
- Moderator

-
- Posts: 1718
- Joined: Sun Dec 29, 2002 5:03 am
- Location: Portugal
-
Return to PHP & MySQL Security
Who is online
Users browsing this forum: No registered users and 2 guests