Jump to content


Photo

A MySQL-Link ERROR


  • Please log in to reply
7 replies to this topic

#1 Neptunus Maris

Neptunus Maris
  • Members
  • PipPipPip
  • Advanced Member
  • 192 posts

Posted 08 October 2006 - 05:35 PM

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/rdrvisio/public_html/install.php on line 18


Thats the problem I cant figure out.  Here is the line of code.  Scroll down and you'll find where I noted line 18. (NOTE: its only a part of a script)

<?php

//this will install and populate tables in your database
include "config.php";
connect();

//start with the subscribers

$installsubs = <<<HERE
CREATE TABLE `subscribers` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL default '',
`email` varchar(100) NOT NULL default '',
`date_sub` datetime NOT NULL '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
);
HERE;
$result = mysql_query($installsubs, $dbconn) or die(mysql_error());    <----LINE 18
print "Subscriber table created!";

=====================================

I just cant figure it out at all...please help me.


Thank you in advance
Neptune

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 08 October 2006 - 06:09 PM

i think the problem is that your connect() function (which i assume is in your included config.php) is not connecting to the database.  check to make sure the path to config.php is correct. your include statement assumes it is in the same directory, because you do not have a path shown there. Is it really in the same directory? Also, check to make sure the connection info in connect() is correct. Is the host, user name, password, and db name correct?  Do you have mysql_error()'s attached to those function calls to report an error in connection?
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 Neptunus Maris

Neptunus Maris
  • Members
  • PipPipPip
  • Advanced Member
  • 192 posts

Posted 08 October 2006 - 06:26 PM

The connect() is correct and the code within it o connect to te database.  The included file "config.php" is i the same directory.  But as for the mysql_error() function, i thought that was a automatic function that was already made within PHP, if not I didnt know you had to make it.  It's just that in the books Ive read it said it was a pre-defined function for PHP.

This is what my connect() looks like in my config.php.

function connect() { //connects the database
global $servername, $username, $password, $dbname;
$dbconn = mysql_connect($servername, $username, $password) or die(mysql_error());
$select = mysql_select_db($dbname, $dbconn) or die(mysql_error());
} //end connect


Thanks
Neptune

#4 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 08 October 2006 - 06:36 PM

mysql_error() is a built in function.

okay your problem is that your $dbconn in your function is a local variable, so your connection does not apply to the rest of your script.

you need to return the variable and instead of doing just connect(); in your main script, do like

$connection = connect();

and then use $connection in your mysql_query
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#5 Neptunus Maris

Neptunus Maris
  • Members
  • PipPipPip
  • Advanced Member
  • 192 posts

Posted 08 October 2006 - 07:01 PM

Yeah that doesnt work either and then when I took the $dbconn(or what you told me $connection) out of the mysql_query.  I got this the next time around:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'unsigned NOT NULL '0000-00-00 00:00:00', PRIMARY KEY (`id`) )' at line 5

thats on line 5 of install.php, here are the first 19 lines of install.php;:

<?php

//this will install and populate tables in your database
include "config.php";
connect();

//start with the subscribers

$installsubs = <<<HERE
CREATE TABLE `subscribers` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL default '',
`email` varchar(100) NOT NULL default '',
`date_sub` datetime unsigned NOT NULL '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
);
HERE;
$result = mysql_query($installsubs) or die(mysql_error());
print "Subscriber table created!";

--------------------------
And this is my server info:

General server information:
Operating system Linux
Kernel version 2.6.17.1
Machine Type i686
Apache version 1.3.36 (Unix)
PERL version 5.8.7
Path to PERL /usr/bin/perl
Path to sendmail /usr/sbin/sendmail
Installed Perl Modules Click to View
PHP version 5.0.4
MySQL version 4.1.21-standard-log
cPanel Build 10.9.0-CURRENT 28
Theme cPanel X v2.5.0

#6 Neptunus Maris

Neptunus Maris
  • Members
  • PipPipPip
  • Advanced Member
  • 192 posts

Posted 08 October 2006 - 07:34 PM

In my last post I listed my server info...The operating system is Linux...does that have anything to do with it?

#7 Neptunus Maris

Neptunus Maris
  • Members
  • PipPipPip
  • Advanced Member
  • 192 posts

Posted 08 October 2006 - 08:59 PM

Does anyone know how to fix this?

#8 Neptunus Maris

Neptunus Maris
  • Members
  • PipPipPip
  • Advanced Member
  • 192 posts

Posted 09 October 2006 - 01:14 AM

Still no one can help me futher?


...please....I really need help




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users