iwalkonstars Posted July 31, 2011 Share Posted July 31, 2011 I am a recent grad who has worked with SQL a bit, so I have my simple table all set with some sample data filled in. I am doing my first bit of coding "in real life" for a start-up business. I know I need PHP to display the information. It's simple - a table showing the info from the four columns in the MySQL table. PHP is something I haven't worked with, but I did have a little practice with programming [in general - the logic, etc.] in college. I would really appreciate some direction on how I go about doing this. All I need it a little success with my results... I've Googled away and nothing works for me. I've done my best, but I'm spending hours and getting nowhere. My process: Type code in notepad --> FTP to server --> test in browser I haven't installed anything on my PC... should I? This would be pretty big for my career, so thank you to anyone that can help Quote Link to comment Share on other sites More sharing options...
voip03 Posted July 31, 2011 Share Posted July 31, 2011 what you want? :confused: Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted July 31, 2011 Share Posted July 31, 2011 This site is geared more toward helping people with code they've already written, not teaching php from step one. You'd seriously be better off to buy a book and start going through it rather than attempting to learn by whatever bits and pieces of information you'd get on a forum or from a tutorial on the internet. At least a book would start with what you need to know first and build on it so you can actually understand what you're doing. Quote Link to comment Share on other sites More sharing options...
iwalkonstars Posted August 1, 2011 Author Share Posted August 1, 2011 This site is geared more toward helping people with code they've already written, not teaching php from step one. You'd seriously be better off to buy a book and start going through it rather than attempting to learn by whatever bits and pieces of information you'd get on a forum or from a tutorial on the internet. At least a book would start with what you need to know first and build on it so you can actually understand what you're doing. I have been playing around with it, and the PHP codes I use seem to work fine. But when trying to connect to my MySQL database, I get a blank page. I guess that is my primary issue. I have a block of code that *should* be working right, but I'm stuck. I suppose the better question would be "how do I know if I'm connecting to my database?" I have been doing my best to find the info myself though online tutorials, I'm hesitant to buy books at their costs with no idea of how well the content will match my needs. Could you at least recommend a good site for MySQL/PHP? Quote Link to comment Share on other sites More sharing options...
AndrewFerrara Posted August 1, 2011 Share Posted August 1, 2011 If you get no errors with this code you are connected to your database. <?php mysql_connect('localhost', 'username', 'password') or die (mysql_error()); mysql_select_db('database') or die (mysql_error()); ?> Quote Link to comment Share on other sites More sharing options...
voip03 Posted August 1, 2011 Share Posted August 1, 2011 http://www.tizag.com/mysqlTutorial/ http://www.w3schools.com/php/php_mysql_intro.asp Quote Link to comment Share on other sites More sharing options...
iwalkonstars Posted August 1, 2011 Author Share Posted August 1, 2011 If you get no errors with this code you are connected to your database. <?php mysql_connect('localhost', 'username', 'password') or die (mysql_error()); mysql_select_db('database') or die (mysql_error()); ?> I didn't get any errors - all I got was a blank page. This is the same thing I get when I try connecting. PHP in general is working fine for me, so it would seem that this is an issue with connecting to MySQL specifically. For the record, I used a sample database and block of PHP code to try it out, and I got the same error. If it's not syntax related, is there anything else that would be causing the connection issue? Quote Link to comment Share on other sites More sharing options...
the182guy Posted August 1, 2011 Share Posted August 1, 2011 Your host should provide you with access to the error log file, where you will find clues to the problem. Also try adding this to top of your script to show errors directly on the page for debugging: error_reporting(E_ALL); ini_set('display_errors', '1'); Quote Link to comment Share on other sites More sharing options...
iwalkonstars Posted August 1, 2011 Author Share Posted August 1, 2011 Your host should provide you with access to the error log file, where you will find clues to the problem. Also try adding this to top of your script to show errors directly on the page for debugging: error_reporting(E_ALL); ini_set('display_errors', '1'); Thanks - I finally got something on the page: Fatal error: Call to undefined function mysql_connect() in /var/www/html/test.php.txt on line 13 Link 13 reads: mysql_connect('localhost', 'myusername', 'mypass') or die (mysql_error()); Looking into this, I concluded that I needed to check phpinfo, which I did. I found '--without-mysql' and, from what I read, this is incorrect. The explanations I could find for changing this was a little vague - do I change it through putty? Thanks for all the help so far Quote Link to comment Share on other sites More sharing options...
the182guy Posted August 1, 2011 Share Posted August 1, 2011 Is it your dedicated server? What OS is it running, and how is your PHP installed? Did you complile from source? Quote Link to comment Share on other sites More sharing options...
iwalkonstars Posted August 1, 2011 Author Share Posted August 1, 2011 The server belongs to the IT consultation firm that I am working with. Any PHP installation was done prior to my involvement. It is a Linux server, and I'm not sure about the installation, and the server owner is tinkering now trying to get it to with mysql. If you have any ideas on how to do this, we would appreciate it Quote Link to comment Share on other sites More sharing options...
iwalkonstars Posted August 1, 2011 Author Share Posted August 1, 2011 Nevermind guys, we got it. Now that php is operating with MySQL, the code I had worked perfect. Thanks for all your help!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.