Neptunus Maris Posted October 8, 2006 Share Posted October 8, 2006 Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/rdrvisio/public_html/install.php on line 18Thats 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 databaseinclude "config.php";connect();//start with the subscribers$installsubs = <<<HERECREATE 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 18print "Subscriber table created!";=====================================I just cant figure it out at all...please help me.Thank you in advanceNeptune Quote Link to comment https://forums.phpfreaks.com/topic/23366-a-mysql-link-error/ Share on other sites More sharing options...
.josh Posted October 8, 2006 Share Posted October 8, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/23366-a-mysql-link-error/#findComment-105946 Share on other sites More sharing options...
Neptunus Maris Posted October 8, 2006 Author Share Posted October 8, 2006 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.[sub]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[/sub]ThanksNeptune Quote Link to comment https://forums.phpfreaks.com/topic/23366-a-mysql-link-error/#findComment-105950 Share on other sites More sharing options...
.josh Posted October 8, 2006 Share Posted October 8, 2006 mysql_error() [i]is[/i] 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 Quote Link to comment https://forums.phpfreaks.com/topic/23366-a-mysql-link-error/#findComment-105952 Share on other sites More sharing options...
Neptunus Maris Posted October 8, 2006 Author Share Posted October 8, 2006 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 5thats on line 5 of install.php, here are the first 19 lines of install.php;:<?php//this will install and populate tables in your databaseinclude "config.php";connect();//start with the subscribers$installsubs = <<<HERECREATE 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 LinuxKernel version 2.6.17.1Machine Type i686Apache version 1.3.36 (Unix)PERL version 5.8.7Path to PERL /usr/bin/perlPath to sendmail /usr/sbin/sendmailInstalled Perl Modules Click to ViewPHP version 5.0.4MySQL version 4.1.21-standard-logcPanel Build 10.9.0-CURRENT 28Theme cPanel X v2.5.0 Quote Link to comment https://forums.phpfreaks.com/topic/23366-a-mysql-link-error/#findComment-105955 Share on other sites More sharing options...
Neptunus Maris Posted October 8, 2006 Author Share Posted October 8, 2006 In my last post I listed my server info...The operating system is Linux...does that have anything to do with it? Quote Link to comment https://forums.phpfreaks.com/topic/23366-a-mysql-link-error/#findComment-105970 Share on other sites More sharing options...
Neptunus Maris Posted October 8, 2006 Author Share Posted October 8, 2006 Does anyone know how to fix this? Quote Link to comment https://forums.phpfreaks.com/topic/23366-a-mysql-link-error/#findComment-105986 Share on other sites More sharing options...
Neptunus Maris Posted October 9, 2006 Author Share Posted October 9, 2006 Still no one can help me futher?...please....I really need help Quote Link to comment https://forums.phpfreaks.com/topic/23366-a-mysql-link-error/#findComment-106048 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.