Previous Thread
Next Thread
Print Thread
Rate Thread
#104131 05/11/2001 2:30 PM
Joined: Sep 2000
Posts: 71
Member
Member
Offline
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???


vBulletin Team
[email protected]
Sponsored Links
#104132 05/12/2001 6:14 AM
Joined: Feb 1999
Posts: 1,379
cal Offline
Programmer
Programmer
Offline
Joined: Feb 1999
Posts: 1,379
try this:
Code
code:
then call the page as page.php?filename=whatever

Just a thought smile

#104133 05/14/2001 4:09 AM
Joined: Sep 2000
Posts: 71
Member
Member
Offline
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.


vBulletin Team
[email protected]
#104134 05/14/2001 8:54 AM
Joined: Mar 2000
Posts: 615
Member
Member
Offline
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)

#104135 05/15/2001 2:32 PM
Joined: Sep 2000
Posts: 71
Member
Member
Offline
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.

Code
code:


vBulletin Team
[email protected]
Sponsored Links

Link Copied to Clipboard
Donate Today!
Donate via PayPal

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.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)