Hello all. I'm working through PHP tutorials & trying to integrate MySql(open and manipulate MySQL db's). The problem is whenever I try to open a database and output results I just get blank pages. I suspect it is something to do with the 'mysql_connect("localhost")' not being able to connect but I'm not sure. I'm using PHP & MySql versions 5. I also suspect there's something that should be in the php.ini file that isn't but I don't know what it is. As you can tell I'm a real newbie! Any & all help to connect to MySQL would be greatly appreciated!
Post your code. Or try setting these lines on top of the code and see if you get any more errors. error_reporting(E_ALL); ini_set('display_errors', '1'); PHP: And add this at the end of your mysql_connect(): mysql_connect('localhost') OR die(mysql_error()); PHP:
Are you getting just blank pages, or there errors outputted on the pages? If you are getting no errors and just a blank page, then maybe you aren't actually fetching the rows and outputting them? that would be a newbie thing to do
Thanks Nico_swd & HotSauce! HotSauce, I had been getting nothing but blank pages to this time. Nico_Swd, your suggestion gave me at least something I can work with namely this: Fatal error: Call to undefined function mysql_connect() in C:\www\webroot\query1.php on line 3 I'm still pluggin' away and more suggestions are definitely welcome! Thx FC
BTW here is the problem code: <?php error_reporting(E_ALL); ini_set('display_errors', '1'); $db = mysql_connect("localhost") OR die(mysql_error()); mysql_select_db("menagerie", $db); $query = "select * from animals"; $result = mysql_query($query); $table = mysql_fetch_assoc($result); echo $table; ?> So I guess my question at this point is this: is the error saying mysql_connect() is undefined & if so why; or is something else going on? Thx again FC
You didn't install MySQL right, or it's not running. Did you install PHP and MySQL yourself? Or are you using something like XAMPP? (Which I'd suggest to use)
I installed MySQL & PHP myself using WAMP. I am able to use the MySql Command Line just fine. That's how I learned MySql. So advise me on XAMPP(I just downloaded it)? I'm still having the same problem. Thx FC
Hmm, I thought MySQL support was built into recent versions of PHP. Are you using it on Apache or IIS? Windows or Linux?