View Full Version : mySQL help please?
rawritsluke
23-03-2008, 05:47 PM
Hey I need this file for one of my index pages to run but when I enter my database info it doesn't work :S
if ($sql_mode==2) {
$crishn = pg_connect("$localhost","5432","$sql_data");
} else if ($sql_mode==3) {
$crishn = mssql_connect($host, $sql_user, $changeme);
$crashn = mssql_select_db($sql_data);
} else if ($sql_mode==4) {
$crishn = odbc_connect($sql_data, $host, $changeme);
} else {
$crishn = mysql_connect($localhost, $host, $changeme);
$crashn = mysql_select_db($host);
}
I've put the database user and password as host and changeme due to me not wanting the database info being leaked :) And yes when I put in the correct database info it is the correct info.
+REP to whoever helps :)
Agnostic Bear
23-03-2008, 06:07 PM
Hey I need this file for one of my index pages to run but when I enter my database info it doesn't work :S
if ($sql_mode==2) {
$crishn = pg_connect("$localhost","5432","$sql_data");
} else if ($sql_mode==3) {
$crishn = mssql_connect($host, $sql_user, $changeme);
$crashn = mssql_select_db($sql_data);
} else if ($sql_mode==4) {
$crishn = odbc_connect($sql_data, $host, $changeme);
} else {
$crishn = mysql_connect($localhost, $host, $changeme);
$crashn = mysql_select_db($host);
}I've put the database user and password as host and changeme due to me not wanting the database info being leaked :) And yes when I put in the correct database info it is the correct info.
+REP to whoever helps :)
can you post the full script (obviously take out the details)
rawritsluke
23-03-2008, 06:23 PM
Hey, that is the full script, what it does is enable users to register and submit content, I forgot the includes tho
<?php
require "mysqlinfo.php";
require "actions.php";
if ($sql_mode==2) {
$crishn = pg_connect("$localhost","5432","$sql_data");
} else if ($sql_mode==3) {
$crishn = mssql_connect($sql_host, $sql_user, $sql_pass);
$crashn = mssql_select_db($sql_data);
} else if ($sql_mode==4) {
$crishn = odbc_connect($sql_data, $sql_user, $sql_pass);
} else {
$crishn = mysql_connect($db_host, $db_user, $db_pass);
$crashn = mysql_select_db($db_name);
}
?>I then include this code in the other pages example:
require "varfunctions.php";
Hypertext
23-03-2008, 06:26 PM
I don't understand what you're trying to do ;S It looks pointless..
rawritsluke
23-03-2008, 06:28 PM
Okay that script is for an install file. So when users download the cms they can install it. But I'm trying to get it to work. For them to install they need to input their database info but I've tried and it doesn't work.
The includes are for submitting content etc.
Hypertext
23-03-2008, 06:30 PM
LOL! I'm doing the EXACT thing now, and having troubles, I have so far:
//blablabla
elseif($_GET['step'] == "2") {
$sitename = $_POST['sitename'];
if(isset($_POST['submit'])) {
$host = $_POST['host'];
$username = $_POST['username'];
$password = $_POST['password'];
$database = $_POST['database'];
$contest = mysql_connect($host,$username,$password);
$dbtest = mysql_select_db($database);
$test = 0;
if(!$contest) {
$test = 0;
}
if(!$dbtest) {
$test = 0;
} else {
$test = 1;
}
if($test == "1") {
echo "Success! Click <a href=\"step=3\">here</a>";
} else {
echo "Some of your information is incorrect, please try again.";
?>
<form name="step1" method="post" action="?step=2">
<input type="hidden" name="sitename" value="<?php echo $sitename; ?>" />
<fieldset><legend>Host (Usually 'localhost')</legend>
<input type="text" maxlength="100" name="dbhost" id="dbhost" value="localhost" />
</fieldset>
<fieldset><legend>Username</legend>
<input type="text" maxlength="100" name="dbusername" id="dbusername" />
</fieldset>
<fieldset><legend>Password</legend>
<input type="text" maxlength="100" name="dbpass" id="dbpass" />
</fieldset>
<fieldset><legend>Database</legend>
<input type="text" maxlength="100" name="dbdatabase" id="dbdatabase" />
</fieldset>
<fieldset><legend>Next Step</legend>
<input type="submit" name="submit" id="submit" value="Next Step" />
</fieldset>
</form>
<?php
}
}
}
elseif($_GET['step'] == "3") { //blbalbalbalab
rawritsluke
23-03-2008, 06:40 PM
Lmao! it's so annoying isn't it :( See I built it so if they have the wrong information it says: You need to edit varfunctions.php with the correct database information!
And just re-directs them back to the install page :P
Hypertext
23-03-2008, 06:41 PM
When I put in right or wrong info mine echos it's error..
rawritsluke
23-03-2008, 06:57 PM
What this?
echo "Some of your information is incorrect, please try again.";
Hypertext
23-03-2008, 06:58 PM
if info is incorrect.
Hypertext
23-03-2008, 07:02 PM
LOL! I put in the wrong values... wow im dumb.
Crap forgot to edit sorry.
Hypertext
23-03-2008, 07:41 PM
just change the posts to the right values and it works =)
rawritsluke
23-03-2008, 08:24 PM
Haha works now, I forgot to include my installmysql.php file :)
Hypertext
23-03-2008, 08:26 PM
Grats :)
May I ask how did you install the mysql, just using the .sql or...?
Independent
24-03-2008, 01:02 AM
try execute it in something like phpMyadmin. (Open the .sql in notepad or some other good program, and paste the SQL in phpMyadmin SQL query executer)
Clever (:
Florx
24-03-2008, 01:09 AM
Hey,
Hate to break this to you but this is mssql not mysql.
Independent
24-03-2008, 01:18 AM
Hey,
Hate to break this to you but this is mssql not mysql.
lol -cry.
I can't believe it's not ''Butter' MySQL..
Bojangles
24-03-2008, 02:40 PM
Grats :)
May I ask how did you install the mysql, just using the .sql or...?
Yeah, just writing a plain .sql text file :)
Dentafrice
24-03-2008, 02:44 PM
Hey I need this file for one of my index pages to run but when I enter my database info it doesn't work :S
if ($sql_mode==2) {
$crishn = pg_connect("$localhost","5432","$sql_data");
} else if ($sql_mode==3) {
$crishn = mssql_connect($host, $sql_user, $changeme);
$crashn = mssql_select_db($sql_data);
} else if ($sql_mode==4) {
$crishn = odbc_connect($sql_data, $host, $changeme);
} else {
$crishn = mysql_connect($localhost, $host, $changeme);
$crashn = mysql_select_db($host);
}I've put the database user and password as host and changeme due to me not wanting the database info being leaked :) And yes when I put in the correct database info it is the correct info.
+REP to whoever helps :)
Okay that script is for an install file. So when users download the cms they can install it. But I'm trying to get it to work. For them to install they need to input their database info but I've tried and it doesn't work.
The includes are for submitting content etc.
Dude, you're going to need to figure out which database you are going to use!
pg_connect is postgreSQL.
mssql
odbc
MySQL
And from what I see, the quality of those code is awful, so why not stick with one? Just support MySQL, I am sure more people would prefer that.
Bojangles
24-03-2008, 02:53 PM
Dude, you're going to need to figure out which database you are going to use!
pg_connect is postgreSQL.
mssql
odbc
MySQL
And from what I see, the quality of those code is awful, so why not stick with one? Just support MySQL, I am sure more people would prefer that.
Hmm I could just use one. Yeah its poor but I'm new to all this as you can probably tell :)
Dentafrice
24-03-2008, 02:54 PM
Yeah, the coding hurts my eyes :P
Using just MySQL would be better.
Bojangles
24-03-2008, 02:55 PM
So shall I just code it so it connects to one database only?
Dentafrice
24-03-2008, 03:00 PM
Yeah, it should just connect to one type of database in my opinion, as your going to have a hell of a time throughout the script determining which function to use to query.
Bojangles
24-03-2008, 03:03 PM
<?php
$dbhost = 'localhost';
$dbuser = 'test';
$dbpass = 'changeme';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = 'changeme';
mysql_select_db($dbname);
?>
Better? :P
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.