Jump to content


MySQL error/ PHP fix


2 replies to this topic

#1 mjs

    Young Padawan

  • Members
  • Pip
  • 2 posts

Posted 23 July 2009 - 08:50 PM

I found a tutorial here for an PHP hit counter. http://www.pixel2lif...showtopic=26113
I need this type of counter because My site is SSL secured. Anyway, I am a newb when it comes to working with PHP and my SQL, so I first want to know if I'm doing this correctly since there are no newb steps in that tutorial.
After adding the MySQL info in the config.php, I ran it through myphpadmin and got a warning. I then ran the other php sections though there and got errors for all of them. I posted the first warning in that thread just yesterday, but since it's so old I doubt I'd ever get a reply.

I ran the table code first and I noticed this at the top:

MySQL returned an empty result set (i.e. zero rows)
ran it again and got an error saying data already exists which tells me that at least the php was in the database.

For the config, I get this:

#1064 - you have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntaxto use near '<?php
$connect = mysql_connect ( 'localhost', 'myusername', 'mypassword' )' at line 1

For the stats, I get this:

ERROR: Unknown Punctuation String @ 1
STR: <?
SQL: <?php

require_once 'config.php';<?php (X11 times below) (just doing this to save space)

require_once 'config.php';

SQL says
same #1064 message
require_once 'config.php' ' at line 1

lastly for the hit, I get this:

This error looks almost exctly as the one I get for the stats, but it only has 5 rows of
require_once 'config.php';<?php

MySQL says the same thing



Basically all I edited from all of this is the username and password and database in the config script, and yes I did do through all the //comments.
Are you supposed to edit all the areas in orange on the script??

Any help would be greatly appreciated. I'm new here, but this looks like a great site for lots of things. Thanks in advance to everyone participating in these forums. :)

#2 derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 341 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 23 July 2009 - 11:05 PM

provide us with the full source (excluding your database information), cause what you posted kind of confused me.

#3 dotbart

    Young Padawan

  • Members
  • Pip
  • 141 posts
  • Gender:Male
  • Location:Diepenbeek
  • Interests:Webdesign, Webdeveloppement, DJ, ...

Posted 24 July 2009 - 03:57 AM

Looking at the errors, it looks like you're running PHP code through MySQL...

Don't run the PHP scripts in PHPMyAdmin, place them in your webroot and go to them in Firefox or smething so they get run by a PHP interpreter.

To answer your other question: The areas in orange are comments, these don't matter if you edit them or not. The only things you should edit from the looks of it are these:
$connect = mysql_connect( 'localhost', 'DATABASE USERNAME', 'DATABASE PASSWORD' ) or die(mysql_error());
mysql_select_db( 'DATABASE NAME' );

In the above you change 'DATABASE USERNAME' and 'DATABASE PASSWORD' to the user you log into phpmyadmin with.
Change 'DATABASE NAME' to the name of your database
Posted Image
In this image, the databasename is 'hosthorn' if you catch my drift :-)



Bart





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users