Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP

Issue with setting up php mysql database

So Im following this tutorial http://www.youtube.com/watch?v=ZDhX9FMIcYc and Im trying to create a table in my sql database. I've uploaded all the files including the mysql.php and tables.php file, but when I go to phpmyadmin in the cpanel and go to the database it doesn't show that a table has been created.

Whenever I go to http://langfx.com/joshkblog/tables.php it shows Parse error: syntax error, unexpected T_STRING in /home/langfx/public_html/joshkblog/mysql.php on line 2

Heres the code for mysql.php file:

<?php
$con = mysql_connect(localhost, langfx_admin, 0p9o8i7u6y);
mysql_select_db(langfx_joshkblog,$con);
?>

heres the code for the tables.php file:

<?PHP 

include "mysql.php";

$table= "ENTRIES";
mysql_query ("CREATE TABLE IF NOT EXISTS '$table' ('ID' INT NOT NULL AUTO_INCREMENT , PRIMARY KEY ( 'id ) )");
mysql_query ("ALTER TABLE '$table' ADD 'TITLE' TEXT NOT NULL");
mysql_query ("ALTER TABLE '$table' ADD 'SUMMARY' TEXT NOT NULL");
mysql_query ("ALTER TABLE '$table' ADD 'CONTENT' TEXT NOT NULL");

I dont get it, I followed the instructions exactly, whats wrong with my second line in the sql file?

I notice theres a "create" table option in phpmyadmin. Should I just use that instead of doing this manually? Im trying to create a blog similar to www.chanceraps.com

Or maybe instead of doing any of this manually I should just download a simple php blog script? Something like this? http://sourceforge.net/projects/php-blog-insert/

2 Answers

Hmm, instead of doing that I might just do this tutorial instead actually, seems to be on the level that I want the blog to be on http://maxoffsky.com/code-blog/tutorial-creating-a-blog-in-laravel-from-scratch-part-1-overview/

Just want to know if Im going in the right direction?

Randy Hoyt
Randy Hoyt
Treehouse Guest Teacher

If you want to build your own blogging engine, I would definitely recommend using a framework. Go for it!

James Barnett
James Barnett
39,199 Points

Now might be a good time to brush up on some SQL in the Database Foundations course here on Treehouse