MGProjects Posted September 24, 2011 Report Share Posted September 24, 2011 (edited) bem estava tentando fazer uma conexão com o sql 2005 com o php do apache..estou com esse erro quando abro a pagina Notice: Use of undefined constant sql_host - assumed 'sql_host' in C:\wamp\www\_inc\config.php on line 9Notice: Use of undefined constant sql_user - assumed 'sql_user' in C:\wamp\www\_inc\config.php on line 9Notice: Use of undefined constant sql_pass - assumed 'sql_pass' in C:\wamp\www\_inc\config.php on line 9Notice: Use of undefined constant sql_db - assumed 'sql_db' in C:\wamp\www\_inc\config.php on line 13codigo da conexão<?php$cfg['sql_host'] = "ZULU631\SQLEXPRESS";$cfg['sql_user'] = "sa";$cfg['sql_pass'] = "A0168t21";$cfg['sql_db'] = "SRO_VT_ACCOUNT";$sqlLink = mssql_connect($cfg[sql_host],$cfg[sql_user],$cfg[sql_pass]); if(!$sqlLink) die("MSSQL server is not accessable, why should we try to select database ?"); else { mssql_select_db($cfg[sql_db],$sqlLink); }?>codigo do index.<?php/* Simple registration page for silkroad server, by Chernobyl * Settings are at _inc/config.php * If you get an mssql connection error, while defining totally correct data * Just use older ntwdblib.dll for your webserver*/require_once('_inc/security.class.php');require_once('_inc/config.php');if(!isset($_POST['submit'])) { echo "<table border=1'> <form method='post'> <td>Username</td><td><input type='text' name='username' maxlength='16'></td><tr/> <td>Password[1]</td><td><input type='password' name='pw1' maxlength='32'></td><tr/> <td>Password[2]</td><td><input type='password' name='pw2' maxlength='32'></td><tr/> <td></td><td><input type='submit' name='submit' value='Register'></td> </form> </table>"; } else { if(strlen($_POST['username]) < 3) $msg[] = "Username too short"; if(strlen($_POST['username']) > 16)$msg[] = "Username too long"; if(strlen($_POST['pw1']) < 6) $msg[] = "Password [1] too short"; if(strlen($_POST['pw1']) > 32)$msg[] = "Password [1] too long"; if(strlen($_POST['pw2']) < 6) $msg[] = "Password [2] too short"; if(strlen($_POST['pw2']) > 32) $msg[] = "Password [2] too long"; if($_POST['pw1'] != $_POST['pw2']) $msg[] = "Passwords are not the same"; $sec = new security(); if($sec->is_secure($_POST['username']) == false) $msg[] = "Username contains forbidden symbols"; if($sec->is_secure($_POST['pw1']) == false) $msg[] = "Password [1] contains forbidden symbols"; if($sec->is_secure($_POST['pw2']) == false) $msg[] = "Password [2] contains forbidden symbols"; if(count($msg) > 0) { for($i = 0; $i < count($msg); $i++) { echo $msg[$i]."<br/>"; } return; } else { //checking damn mssql stuff $accountExists = mssql_num_rows(mssql_query("select StrUserID from TB_User where StrUserID=$_POST[username]'")); if($accountExists > 0) echo "Account with such username already exists<br/>"; else { $pwd = md5($_POST['pw1]); mssql_query("insert into TB_User(StrUserID,password,sec_primary,sec_content) values('$_POST[username]','$pwd','3','3')"); echo "Account successfully created<br/>"; } } }?> ai quando eu do ok para add na tabela ele aparecePassword [1] too shortPassword [2] too shortmais não add nada na dbo Edited September 24, 2011 by MGProjects Quote Link to comment Share on other sites More sharing options...
0 Willian Gustavo Veiga Posted September 25, 2011 Report Share Posted September 25, 2011 Notice: Use of undefined constant XXX - assumed 'XXX' in C:\wamp\www\_inc\config.php on line XEste erro indica que você esqueceu de colocar aspas ou apóstrofo na chave do array, dessa maneira o PHP assumiu que você estava utilizando uma constante.Um abraço. Quote Link to comment Share on other sites More sharing options...
Question
MGProjects
bem estava tentando fazer uma conexão com o sql 2005 com o php do apache..
estou com esse erro quando abro a pagina
Notice: Use of undefined constant sql_host - assumed 'sql_host' in C:\wamp\www\_inc\config.php on line 9
Notice: Use of undefined constant sql_user - assumed 'sql_user' in C:\wamp\www\_inc\config.php on line 9
Notice: Use of undefined constant sql_pass - assumed 'sql_pass' in C:\wamp\www\_inc\config.php on line 9
Notice: Use of undefined constant sql_db - assumed 'sql_db' in C:\wamp\www\_inc\config.php on line 13
codigo da conexão
<?php
$cfg['sql_host'] = "ZULU631\SQLEXPRESS";
$cfg['sql_user'] = "sa";
$cfg['sql_pass'] = "A0168t21";
$cfg['sql_db'] = "SRO_VT_ACCOUNT";
$sqlLink = mssql_connect($cfg[sql_host],$cfg[sql_user],$cfg[sql_pass]);
if(!$sqlLink) die("MSSQL server is not accessable, why should we try to select database ?");
else
{
mssql_select_db($cfg[sql_db],$sqlLink);
}
?>
codigo do index.
<?php
/* Simple registration page for silkroad server, by Chernobyl
* Settings are at _inc/config.php
* If you get an mssql connection error, while defining totally correct data
* Just use older ntwdblib.dll for your webserver
*/
require_once('_inc/security.class.php');
require_once('_inc/config.php');
if(!isset($_POST['submit']))
{
echo "<table border=1'>
<form method='post'>
<td>Username</td><td><input type='text' name='username' maxlength='16'></td><tr/>
<td>Password[1]</td><td><input type='password' name='pw1' maxlength='32'></td><tr/>
<td>Password[2]</td><td><input type='password' name='pw2' maxlength='32'></td><tr/>
<td></td><td><input type='submit' name='submit' value='Register'></td>
</form>
</table>";
}
else
{
if(strlen($_POST['username]) < 3) $msg[] = "Username too short";
if(strlen($_POST['username']) > 16)$msg[] = "Username too long";
if(strlen($_POST['pw1']) < 6) $msg[] = "Password [1] too short";
if(strlen($_POST['pw1']) > 32)$msg[] = "Password [1] too long";
if(strlen($_POST['pw2']) < 6) $msg[] = "Password [2] too short";
if(strlen($_POST['pw2']) > 32) $msg[] = "Password [2] too long";
if($_POST['pw1'] != $_POST['pw2']) $msg[] = "Passwords are not the same";
$sec = new security();
if($sec->is_secure($_POST['username']) == false) $msg[] = "Username contains forbidden symbols";
if($sec->is_secure($_POST['pw1']) == false) $msg[] = "Password [1] contains forbidden symbols";
if($sec->is_secure($_POST['pw2']) == false) $msg[] = "Password [2] contains forbidden symbols";
if(count($msg) > 0)
{
for($i = 0; $i < count($msg); $i++)
{
echo $msg[$i]."<br/>";
}
return;
}
else
{
//checking damn mssql stuff
$accountExists = mssql_num_rows(mssql_query("select StrUserID from TB_User where StrUserID=$_POST[username]'"));
if($accountExists > 0) echo "Account with such username already exists<br/>";
else
{
$pwd = md5($_POST['pw1]);
mssql_query("insert into TB_User(StrUserID,password,sec_primary,sec_content) values('$_POST[username]','$pwd','3','3')");
echo "Account successfully created<br/>";
}
}
}
?>
ai quando eu do ok para add na tabela ele aparece
Password [1] too short
Password [2] too short
mais não add nada na dbo
Edited by MGProjectsLink to comment
Share on other sites
1 answer to this question
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.