Page 1 of 1

PHP gone wrong: BIG TIME!

Posted: Sun Oct 19, 2008 3:15 am
by yoji
I have got MANY probz with my php. I didn't know where to post so i just posted here... The problems are these:
first off my php doesn't show any errors whatsoever. Even though setting for showing errors is E_ALL without any exceptions. whenever there is any error the page turns blank.

second I can't get mysql and php connected. I have tried every single code out there.. Nothing is working. I have even tried the W3C's tutorial. Mysql in my computer doesn't have any pass.. Default user is root.

Code: Select all

 
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
if (mysql_query("CREATE DATABASE my_db",$con))
  {
  echo "Database created";
  }
else
  {
  echo "Error creating database: " . mysql_error();
  }
mysql_close($con);
?>
 
This doesn't work... Even if I remove everything just echo that it is connected... The page turns blank and that in terms of my strange php means an error... HELP OUT!!! I am using latest versions of everything.. Apache, mysql and php.

Re: PHP gone wrong: BIG TIME!

Posted: Sun Oct 19, 2008 3:49 am
by jaoudestudios
When you say you are using E_ALL, is that in your php code or in the php.ini file?

You have a empty line before your opening php tag! This will send headers and might be causing a problem and if not it will do in the future if you ever try to send headers from your php code. So I would start with removing this!

Is your MySql server definitely running?

Re: PHP gone wrong: BIG TIME!

Posted: Sun Oct 19, 2008 3:52 am
by requinix
display_errors need to be set to 1/true as well. You can do that in php.ini or with ini_set.

Re: PHP gone wrong: BIG TIME!

Posted: Sun Oct 19, 2008 4:04 am
by VladSun
Check your error log file in Apache /logs directory.

Re: PHP gone wrong: BIG TIME!

Posted: Sun Oct 19, 2008 4:30 am
by yoji
Well that one blank line was only here not in the original code... Plus That E_ALL is in the php.ini file.. THANK YOU SO MUCH !! Now my php is showing errors just fine.. I have used php 4 i don't remember doing this everytime I installed php..I meant that show_error setting. My mysql is working just fine...Its process is in the task manager->processes. I have tried it in the command prompt.. It works fine. I even tried using phpmyadmin. It was working fantastically but then I removed it because I thought it might be the root cause.. NO DIFFERENCE.
Now when I am trying a code to connect to
"Fatal error: Call to undefined function mysql_connect() in *(file location) on line 2"
*file location removed..

Anyways guys any ideas?

Re: PHP gone wrong: BIG TIME!

Posted: Sun Oct 19, 2008 4:35 am
by requinix
Make sure you followed all the installation instructions.
Specifically the bit about the php_mysql.dll extension. For all I know phpMyAdmin uses MySQLi or PDO.

Re: PHP gone wrong: BIG TIME!

Posted: Sun Oct 19, 2008 6:56 am
by yoji
Ok so I finally got everything in place... I am telling you I am going to write an article on how to set up apache, mysql and php. I got my prob write just because of a tiny insignificant comment on a php site