PHP gone wrong: BIG TIME!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
yoji
Forum Commoner
Posts: 25
Joined: Sun Oct 19, 2008 3:09 am

PHP gone wrong: BIG TIME!

Post 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.
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: PHP gone wrong: BIG TIME!

Post 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?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: PHP gone wrong: BIG TIME!

Post by requinix »

display_errors need to be set to 1/true as well. You can do that in php.ini or with ini_set.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: PHP gone wrong: BIG TIME!

Post by VladSun »

Check your error log file in Apache /logs directory.
There are 10 types of people in this world, those who understand binary and those who don't
yoji
Forum Commoner
Posts: 25
Joined: Sun Oct 19, 2008 3:09 am

Re: PHP gone wrong: BIG TIME!

Post 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?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: PHP gone wrong: BIG TIME!

Post 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.
yoji
Forum Commoner
Posts: 25
Joined: Sun Oct 19, 2008 3:09 am

Re: PHP gone wrong: BIG TIME!

Post 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
Post Reply