This forum is in archive mode. You will not be able to post new content.

Author Topic: Not Sure if Syntax Error or Otherwise With MySQL/PHP  (Read 1012 times)

0 Members and 1 Guest are viewing this topic.

Offline lucid

  • #Underground
  • Titan
  • **
  • Posts: 2683
  • Cookies: 243
  • psychonaut
    • View Profile
Not Sure if Syntax Error or Otherwise With MySQL/PHP
« on: November 06, 2012, 01:07:40 AM »
Ugh, I didn't want to post this here but I can't find the answer anywhere. It seems to be an incredibly noobish problem but Alas, I've never worked with MySQL or PHP before(Another one of my ADD induced changes of mind, decided to put C on the backburner). So here goes...

I've been following an online tutorial that ande had posted about a long time ago and currenty I'm at this part of it:

http://www.tizag.com/mysqlTutorial/mysqlconnection.php

Code: (php) [Select]
<?php mysql_connect("localhost""root""mypass") or die(mysql_error()); echo "Connected to MySQL<br />"?>

I create that first bit of code, of course with my own user and pass, save it in /srv/http(where these things go in Arch) and then go to http://localhost and click on the appropriate file to try to view it and I see nothing. Not even an error. Just a blank page. All of my other PHP scripts work fine. This is the only one that doesn't work and I simply can't figure out why. Embarrasingly enough I've been searching around for the answer for about two days with no results. :-[

EDIT: I also noticed that if I make some code that should produce some kind of error I always just get a blank page instead. Or something like this for example:

Code: (php) [Select]
<?php
include("noFileExistsHere.php");
echo 
"I'm Retarded!";
?>

Simply displays as

I'm Retarded! With no error in front of it. I'm sure this has something to do with it.

 
« Last Edit: November 08, 2012, 03:23:12 AM by lucid »
"Hacking is at least as much about ideas as about computers and technology. We use our skills to open doors that should never have been shut. We open these doors not only for our own benefit but for the benefit of others, too." - Brian the Hacker

Quote
15:04  @Phage : I'm bored of Python

Offline EmilKXZ

  • Peasant
  • *
  • Posts: 109
  • Cookies: 10
  • likes monies :p
    • View Profile
    • EmilKXZ
Re: Not Sure if Syntax Error or Otherwise With MySQL/PHP
« Reply #1 on: November 06, 2012, 03:41:14 AM »
I had the exact same problem whilst analysing Blackhole Exploit Kit... It did not execute at all, but whilst I knew something wasn't working fine, it didn't show anything.

You have to enable error reporting:
Quote
http://www.php.net/manual/en/function.error-reporting.php

Offline lucid

  • #Underground
  • Titan
  • **
  • Posts: 2683
  • Cookies: 243
  • psychonaut
    • View Profile
Re: Not Sure if Syntax Error or Otherwise With MySQL/PHP
« Reply #2 on: November 06, 2012, 03:51:49 AM »
I actually just fixed the problem. Only to cause a new one. I was able to view the proper display of the code I posted above for awhile but, In attempt to switch the Document_Root from /srv/http to a directory in my home folder I seem to have broken something else. Now when I try to view the page I see this error:

Code: [Select]
Fatal error: Call to undefined function mysql_connect() in /home/'user'/code/php/connect.php on line 2


And when I try to open phpMyAdmin I get this:

Code: [Select]
The mysqli extension is missing. Please check your PHP configuration. <a href="Documentation.html#faqmysql" target="documentation"><img src="themes/dot.gif" title="Documentation" alt="Documentation" class="icon ic_b_help" /></a>

 :-\
« Last Edit: November 06, 2012, 03:52:08 AM by lucid »
"Hacking is at least as much about ideas as about computers and technology. We use our skills to open doors that should never have been shut. We open these doors not only for our own benefit but for the benefit of others, too." - Brian the Hacker

Quote
15:04  @Phage : I'm bored of Python

Offline EmilKXZ

  • Peasant
  • *
  • Posts: 109
  • Cookies: 10
  • likes monies :p
    • View Profile
    • EmilKXZ
Re: Not Sure if Syntax Error or Otherwise With MySQL/PHP
« Reply #3 on: November 06, 2012, 03:58:29 AM »
You have to go to the PHP.INI en enable it (or add it), like this:
Code: [Select]
extension=mysqli.soBut go and google for the exact documentation on it, I'm just talking on what I can remember right now. Perhaps you don't have it at all. Can't tell you all  :)

Offline lucid

  • #Underground
  • Titan
  • **
  • Posts: 2683
  • Cookies: 243
  • psychonaut
    • View Profile
Re: Not Sure if Syntax Error or Otherwise With MySQL/PHP
« Reply #4 on: November 06, 2012, 04:19:40 AM »
I've already done that too. I've read the whole Arch Linux wiki and done all the required configurations and everything was working prior to me changing the Directory_Root where I put my files. Now even if I switch it back it still gives me the same errors.

UPDATE: Fixed the errors. It was a simple random syntax error in the /etc/php/php.ini file. Found it after running php -m. I can't believe I didn't try that sooner. *facepalm*

Now though I'm back to the issue I had in the first post of this thread. I don't understand why either. I have all errors enabled in /etc/php/php.ini. It simply won't display them
« Last Edit: November 08, 2012, 01:44:08 AM by lucid »
"Hacking is at least as much about ideas as about computers and technology. We use our skills to open doors that should never have been shut. We open these doors not only for our own benefit but for the benefit of others, too." - Brian the Hacker

Quote
15:04  @Phage : I'm bored of Python

 



Want to be here? Contact Ande, Factionwars or Kulverstukas on the forum or at IRC.