Pages: [1]   Go Down
Send this topic | Print
Author Topic: MySQL Problems  (Read 708 times)
MTGap
Authority Member
****
Offline Offline

Posts: 625



WWW
« on: May 08, 2008, 06:17:52 AM »

Well first of all one reason I think there might be a problem is the fact that I have the MySQL activated on another account and not this one. (This is for a school project so MySQL will be used on this site for only 1 week, I know that this 110mb doesn't want this, please make exception.) I'm making a quiz for students to enter in their names and then have that submitted to a table as well as their grade afterwards. I'm just beginning to test out parts of it which aren't working.

Code:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'database username'@'localhost' (using password: YES) in /www/110mb.com/b/i/o/q/u/i/z/_/bioquiz/htdocs/insert.php on line 2
Could not connect: Access denied for user 'database username'@'localhost' (using password: YES)

So here is what is on insert:
Code:
<?php
$con
= mysql_connect("localhost","username","password");
if (!
$con)
  {
  die(
'Could not connect: ' . mysql_error());
  }

mysql_select_db("table", $con);

$sql="INSERT INTO person (FirstName, LastName, Age)
VALUES
('$_POST[firstname]','$_POST[lastname]','$_POST[grade]')"
;

if (!
mysql_query($sql,$con))
  {
  die(
'Error: ' . mysql_error());
  }
echo
"1 record added";

mysql_close($con)
?>


Some information such as usernames and passwords not provided in code, I have taken those out for the forums. I'm quite sure they are created because I did make it on the 110dbmanager and I believe all the information is right. Could this just be happening because of some security thing on 110mb so that I can't use that mysql?
Logged



I'm finally getting good at GIMP, just made my avatar and signature.
RBCFAQS
110MB Dreamweaver Expert and
Loyal 110MB Member
*******
Offline Offline

Posts: 2833


IM Me for anything. That's what I'm here for. :D


WWW
« Reply #1 on: May 08, 2008, 06:20:40 AM »

Why not set it up with a flatfile database?
Code:
<?php
$con
= sqlite_connect("FULL SERVER PATH/DATABASENAME.DB");
if (!
$con)

Not sure if that will work, as I'm not a pro at php, but it might. Someone else can advise...
Logged

MTGap
Authority Member
****
Offline Offline

Posts: 625



WWW
« Reply #2 on: May 08, 2008, 06:23:52 AM »

I'd rather stick to what I know... have only a week to get this working.
Logged



I'm finally getting good at GIMP, just made my avatar and signature.
RBCFAQS
110MB Dreamweaver Expert and
Loyal 110MB Member
*******
Offline Offline

Posts: 2833


IM Me for anything. That's what I'm here for. :D


WWW
« Reply #3 on: May 08, 2008, 06:27:54 AM »

I know another solution. You say you have another site on 110mb that has MySQL enabled? Put your php script on that site, and embed it using an Iframe where you want it on this site.

Code:
<iframe height="580" width="1200" scrolling="auto" src="http://site.110mb.com/page.php" name="MAIN"></iframe>

Make sure the links on that php page on the remote site have target="MAIN" in them so that they will target that same Iframe.
Logged

MTGap
Authority Member
****
Offline Offline

Posts: 625



WWW
« Reply #4 on: May 08, 2008, 06:32:14 AM »

Uh I've never used iframes before please explain again lol  grin
Logged



I'm finally getting good at GIMP, just made my avatar and signature.
RBCFAQS
110MB Dreamweaver Expert and
Loyal 110MB Member
*******
Offline Offline

Posts: 2833


IM Me for anything. That's what I'm here for. :D


WWW
« Reply #5 on: May 08, 2008, 06:41:07 AM »

An Iframe is basically just a method of embedding a webpage into another webpage. Look at the source code for my site: http://rbcfaqs.110mb.com/index.html

It's nothing more than an I-frame of another page on my site. (I'm tweaking it right now, bare with the goofs in sizing)

Use the exact code I posted only changing the source URL to that of the page you are wanting to embed, and thats all the code you need on the page, other than if you have a favicon code, which goes in between your <head> tags.

I hope this explains better... but if not I'll try to do better.
Logged

Ğaz
Web Master & Coder for Life
Loyal 110MB Member
*******
Offline Offline

Posts: 3219

Gone with the wind.


WWW
« Reply #6 on: May 11, 2008, 06:23:36 AM »

Firstly, I'd like to mention the fact that I've never seen or used mysql_query the way you do;
"if (!mysql_query($sql,$con))" I would use "if (!mysql_query($sql))"

The same with mysql_select_db. Try "mysql_select_db("table")"
Logged

Personal site: http://matt-shaffer.com
Currently being eaten alive by school and attempting to make a half decent game.

Adios. Contact info is in profile. Might want to email me any IM details first, or I won't add you.
MTGap
Authority Member
****
Offline Offline

Posts: 625



WWW
« Reply #7 on: May 11, 2008, 07:06:44 AM »

I tried it like that and same error... I'm pretty sure password and stuff is right. It is localhost correct?
Logged



I'm finally getting good at GIMP, just made my avatar and signature.
RBCFAQS
110MB Dreamweaver Expert and
Loyal 110MB Member
*******
Offline Offline

Posts: 2833


IM Me for anything. That's what I'm here for. :D


WWW
« Reply #8 on: May 11, 2008, 07:08:51 AM »

Correct. It is localhost or 127.0.0.0 but I'd suggest using localhost instead. Also, if you're still wanting to do the iframe thing, let me know.
Logged

Ğaz
Web Master & Coder for Life
Loyal 110MB Member
*******
Offline Offline

Posts: 3219

Gone with the wind.


WWW
« Reply #9 on: May 11, 2008, 07:09:56 AM »

Yeah localhost is correct; are you sure you're using a table named "table"? Are you sure that table exists already? Also change this:
"mysql_select_db("table", $con);"

To this:
"mysql_select_db("table", $con) or die(mysql_error());"

..and it might help to leave it how I said earlier; without the ", $con"s
Logged

Personal site: http://matt-shaffer.com
Currently being eaten alive by school and attempting to make a half decent game.

Adios. Contact info is in profile. Might want to email me any IM details first, or I won't add you.
MTGap
Authority Member
****
Offline Offline

Posts: 625



WWW
« Reply #10 on: May 11, 2008, 07:24:06 AM »

Okay here is a picture: http://bioquiz.110mb.com/mysql.PNG

Now for the coding:
Code:
<?php
$con
= mysql_connect("localhost","username","password");
if (!
$con)
  {
  die(
'Could not connect: ' . mysql_error());
  }

mysql_select_db("lego-engineering_bio");

$sql="INSERT INTO Quizgrades (FirstName, LastName, Age)
VALUES
('$_POST[firstname]','$_POST[lastname]','$_POST[grade]')"
;

if (!
mysql_query($sql))
  {
  die(
'Error: ' . mysql_error());
  }
echo
"1 record added";

mysql_close($con)
?>


Does that look right based on the 110dbmanager?
Logged



I'm finally getting good at GIMP, just made my avatar and signature.
Pages: [1]   Go Up
Send this topic | Print
Jump to: