Help - Search - Members - Calendar
Full Version: MySQL error/ PHP fix
Pixel2Life Forum > Help Section > PHP, ASP, MySQL, JavaScript and other Web/Database Programming Help
mjs
I found a tutorial here for an PHP hit counter. http://www.pixel2life.com/forums/index.php?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. smile.gif

derek.sullivan
provide us with the full source (excluding your database information), cause what you posted kind of confused me.
dotbart
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:
CODE
$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

In this image, the databasename is 'hosthorn' if you catch my drift :-)



Bart
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.