|
|
Joined: Sep 2000
Posts: 71
Member
|
Member
Joined: Sep 2000
Posts: 71 |
My plan was to store some of my content in a MySQL Database. I was wondering if the following code will work.
$filename = $QUERY_STRING; $server = "localhost"; $db_user = "root"; $db_pass = "password"; $database = "projects"; mysql_connect($server, $db_user, $db_pass) or die ("Database Connect Error"); $sql = "SELECT content FROM pages WHERE filename = '$filename' LIMIT 1"; $content_results = mysql_query($sql); $content = mysql_fetch_array($content_results); $str = $content[content]; mysql_close(); Print($str); ?>
The database is projects table is pages and the columns are filename char(20) content text || blob
I have placed index in the filename column and a HTML page in the content column.
Does anyone see any problems with this code???
|
|
|
|
Joined: Feb 1999
Posts: 1,379
Programmer
|
Programmer
Joined: Feb 1999
Posts: 1,379 |
try this: then call the page as page.php?filename=whatever Just a thought 
|
|
|
|
Joined: Sep 2000
Posts: 71
Member
|
Member
Joined: Sep 2000
Posts: 71 |
i got it working using mysql_fetch_row
i don't plan to have more than one with the same filename so i don't need to use array.
does anyone have an idea of a free MySQL forums, i need one to customise the site with but the UBB is flatfile.
|
|
|
|
Joined: Mar 2000
Posts: 615
Member
|
Member
Joined: Mar 2000
Posts: 615 |
Err... mysql_fetch_row returns a numbered array of the fields, mysql_fetch_array returns an array of the fields with the field name as the array key.
I.E. a table with the fields fieldid, title, and body
with fetch_row: 0 = (fieldid) 1 = (title) 2 = (body)
with fetch_array: fieldid = (fieldid) title = (title) body = (body)
|
|
|
|
Joined: Sep 2000
Posts: 71
Member
|
Member
Joined: Sep 2000
Posts: 71 |
If you could see any improvements please tell me. the include.php contains the db info, layout and the functions for calculating the speed.
|
|
|
Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.
Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
|
|
Posts: 87
Joined: December 2001
|
|
Forums63
Topics37,575
Posts293,931
Members13,824
|
Most Online6,139 Sep 21st, 2024
|
|
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
|
|
|
|
|