Raised This Month: $ Target: $400
 0% 

[Mysql - as allways]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PriceLess
Senior Member
Join Date: Sep 2012
Location: Jungle
Old 04-11-2013 , 12:04   [Mysql - as allways]
Reply With Quote #1

Well I'm working on a interface for a donation thingy for sourcemod. Anyways, started of with the install part.
The install where it creates tables and stuff is correct, it aswell as create table creates a config file located in the php root directory.

Next step is obviously creating a admin for the interface, there all the errors start. I got no typo error or variable errors or what ever like that.

Here is the line that does not work.
PHP Code:
$sql mysql_query("INSERT INTO '$table' (`username`, `password`, `email`, `steamid`, `admin`, `status`, `pending`) VALUES ('$admin_username', '$admin_password', '$admin_email', 1, 1, 0)") OR DIE ('Could not connect'); 
On the page it just prints out the error obviously, but I dont know where the error is, and everything else should be correcy, can provide more of the script if nessesary.

not sure if im allowed to post php 'help' if not just trash this and ill ask somewhere else, but its obviously going to work with a pawn script (that's the point).

Thanks upfront.
__________________
sincerely PriceLess

Last edited by PriceLess; 04-11-2013 at 12:06.
PriceLess is offline
4bdul
AlliedModders Donor
Join Date: Dec 2011
Location: United Kingdom
Old 04-11-2013 , 12:28   Re: [Mysql - as allways]
Reply With Quote #2

7 fields -> 6 values

You're missing a value.
__________________
4bdul is offline
PriceLess
Senior Member
Join Date: Sep 2012
Location: Jungle
Old 04-11-2013 , 12:56   Re: [Mysql - as allways]
Reply With Quote #3

Quote:
Originally Posted by 4bdul View Post
7 fields -> 6 values

You're missing a value.
Yes but now i got a new error

PHP Code:
$sql mysql_query("INSERT INTO '$table' (`steamid` ,
`username` ,
`password` ,
`email` ,
`status` ,
`admin` ,
`pending`
)
VALUES (
'
$admin_steamid', '$admin_username', MD5( '$admin_password' ) , '$admin_email', '1', '1', '0'
)"
); 
Error: 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 ''users' (`steamid` , `username` , `password` , `email` , `status` , `admin`' at line 1
__________________
sincerely PriceLess
PriceLess is offline
4bdul
AlliedModders Donor
Join Date: Dec 2011
Location: United Kingdom
Old 04-11-2013 , 13:19   Re: [Mysql - as allways]
Reply With Quote #4

Are you sure each and every field exists in the table - spelled the exact same too.
__________________
4bdul is offline
PriceLess
Senior Member
Join Date: Sep 2012
Location: Jungle
Old 04-11-2013 , 13:31   Re: [Mysql - as allways]
Reply With Quote #5

Quote:
Originally Posted by 4bdul View Post
Are you sure each and every field exists in the table - spelled the exact same too.
Yes, just copy pasted the table rows nothing wrong

PHP Code:
<?php
define
('ROOT'dirname(dirname(__FILE__))."/");
include 
ROOT.'config.php';

$admin_username $_POST['username'];
$admin_password $_POST['password'];
$admin_email $_POST['email'];
$admin_steamid $_POST['steamid'];
$con mysql_connect($host$username$password);

mysql_select_db($database);

$sql mysql_query("INSERT INTO '$table' (`steamid` ,
`username` ,
`password` ,
`email` ,
`status` ,
`admin` ,
`pending`
)
VALUES (
'
$admin_steamid', '$admin_username', MD5( '$admin_password' ) , '$admin_email', '1', '1', '0'
)"
);
?>
config file : auto created (works aswell)

PHP Code:
<?php
$host 
"localhost"//Mysql IP address

$username "root"//Mysql Username

$password "secret--"//Mysql Password

$database "premium"//Mysql Database

$table "users"//Mysql Table
?>
create table file. (works btw)
PHP Code:

mysql_query
("CREATE TABLE IF NOT EXISTS $mysql_table (user_id INT(11) auto_increment PRIMARY KEY, steamid VARCHAR(32), username VARCHAR(60), password VARCHAR(60), email VARCHAR(1024), status INT(11), admin INT(11), pending INT(11))"); 
the form
PHP Code:
        <form action="finish.php" method="post" name="form_name">
            <
div class="h3">
                <
h3>Install setupstep 2</h3>
            </
div>
                <
h5 class="input1">
                    
Admin Username:*<br
                    <
input type="text" name="username">
                </
h5>
                
                <
br>
                <
h5 class="input2">
                    
Admin Password:*<br>
                    <
input type="password" name="password">
                </
h5>
                    
                <
br>    
                <
h5 class="input3">
                    
Admin Email:*<br>
                    <
input type="email" name="email">
                </
h5>
                <
br>
                <
h5 class="input4">
                    
Admin Steamid:*<br>
                    <
input type="text" name="steamid" onKeyup="checkform()"/>
                </
h5>
                
                <
br>
                <
div class="submit"
                <
small>The fields marked with '*' is a required field.</small><br>
                <
input id="submitbutton" type="submit" action="submit" value="Finish" onsubmit="return validateForm()">
                </
div>
        </
form
__________________
sincerely PriceLess

Last edited by PriceLess; 04-11-2013 at 13:32. Reason: ups pass was out
PriceLess is offline
PriceLess
Senior Member
Join Date: Sep 2012
Location: Jungle
Old 04-11-2013 , 14:14   Re: [Mysql - as allways]
Reply With Quote #6

Fixed
PHP Code:
$sql mysql_query("INSERT INTO $database.$table (
`user_id`,
`steamid`,
`username`,
`password`,
`email`,
`status`,
`admin`,
`pending`
)
VALUES (
NULL, '
$admin_steamid', '$admin_username', MD5('$admin_password'), '$admin_email', '1', '1', '0'
)"
); 
__________________
sincerely PriceLess

Last edited by PriceLess; 04-12-2013 at 08:11.
PriceLess is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:42.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode