Problems with the PHP database storage

Source: Internet
Author: User
I am small white, just started to learn ...
$query = "INSERT into Movie (rating) VALUES (' $num 3 ')";
$result =mysql_query ($query);

The result of a separate printout of $NUM3 is 9.2, but why does it become 0 when it is stored in the database? Field rating is of type float
and $query= "insert into Movie" VALUES (' $m [0][$i +5] '); Separate print out $m[0][$i +5] is ASDFG
But into the database becomes array[1+5] this. The field title is of type char.
Is there a problem with my statement?


Reply to discussion (solution)

PHP code?12$query= "INSERT into Movie (rating) VALUES ('". $num 3. "')"; $query = "INSERT into Movie (') VALUES ('". $m [0][$i +5]. "')";
It's still not working.

$query = "INSERT into Movie (rating) VALUES (' $num 3 ')";
This won't be a problem, you can write.
$query = "INSERT into Movie (rating) values ($num 3)";
Look

$query = "INSERT INTO Movie" VALUES (' $m [0][$i +5] ');
Should write
$query = "INSERT INTO Movie" values (' {$m [0][$i +5]} ');

$query = "INSERT into Movie (rating) VALUES (' $num 3 ')";
This won't be a problem, you can write.
$query = "INSERT into Movie (rating) values ($num 3)";
Look

$query = "INSERT INTO Movie" VALUES (' $m [0][$i +5] ');
......
Endoche, the second one's written wrong.
Only to find out that I made a bigger mistake. My variables are the content of the page crawled through regular expressions, and the characters are printed out, but the real content also contains the tags, so the first one can not be saved in any way ....

$query = "INSERT into Movie (rating) VALUES (' $num 3 ')";
This won't be a problem, you can write.
$query = "INSERT into Movie (rating) values ($num 3)";
Look

$query = "INSERT INTO Movie" VALUES (' $m [0][$i +5] ');
......
But how to get from a string of strings
9.2
Extract the intermediate 9.2 separately and convert it to float type a

 $s =<<< txt9.2txt;preg_match_all ('/> ([. \d]+) '!--', $s, $r);p rint_r ($r [ 1]);  Array 
(
[0] = = 9.2
)

PHP code?12345$s =<<< TXT9. 2txt;preg_match_all ('/> ([. \d]+) '!--', $s, $r);p rint_r ($r [1]); Array
(
[0] = 9.2
)


Ah ah thank you thank you, again weak weak ask me if I extract this?
Redemption (1994)
Extracting redemption How to use regular expressions to not include labels on both sides

 $s =<<<  Txtredemption (1994) Txt;preg_match_all (' # (? <=a) [^>]+> ([^<]+) Array 
(
[0] = = Redemption

don't know how to thank ... It seems that I still have to study hard, good people all the life of peace ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.