mysql - How i can make automatic daily tip php? -
I want to make a "daily tip" on my website but I do not know how I think that I have PHP and mysql database But how can I create it? Or can I create a .txt file for example and type some fashion functions daily from the .txt file? I alredy tried this code:
& lt ;? Php function random_tip () {$ link = mysql_connect ("host", "user", "pass", "a2955851_SW") or die ("error". Mysql_error ($ link)); Mysql_select_db ("a2955851_SW"); $ Sql = "Select 'RandomTip' from Order RAND () Border 1 ()"; $ Line = mysql_query ($ sql, $ link) or die ("Error:" .mysql_error ($ link)); Mysql_free_result ($ line); Mysql_close ($ link); Return ($ line ['tip']); }? & Gt; But I get so many errors and someone says that you can try another style to do "daily tip".
Please help me; D
$ line = mysql_query ($ sql, $ link) ^^^ --- Statement Handle Return ($ line ['Tip']); ^^^^^^ --- handle the statement using it as if it was a line of result you should be
$ result = Msyql_query (...); $ Line = mysql_fetch_assoc ($ result); Echo ['tip'] per line; Instead
Note that mysql _ * () functions are obsolete / deprecated, and not used in any new code should go.
Comments
Post a Comment