解析错误:语法错误,C:\inetpub\wwwroot\mci\admin模型中的意外“mysql_query”(T_STRING)。php在第21行

时间:2021-10-19 06:40:28

help me.. i get error

帮我. .我得到错误

after input in mysql to two query function Parse error: syntax error, unexpected 'mysql_query' (T_STRING) in C:\inetpub\wwwroot\mci\admin\model.php on line 21

在mysql中输入两个查询函数解析错误之后:语法错误,C:\inetpub\wwwroot\mci\admin model中的意外“mysql_query”(T_STRING)。php在第21行

<?php
session_start();
include "../koneksidb/koneksidb.php";
$module = isset($_GET['module']);
$act = isset($_GET['act']);


if ($module=='masterpc' AND $act=='input')
	(
		mysql_query("INSERT INTO masterpc(hostname,os,ip,user,section,location,keyos,keydown,keyoffice,datecreate,cH9,cH10,cH11,cH12) 
		VALUES('$_POST[host]',
				'$_POST[os]',
				'$_POST[ip]',
				'$_POST[user]',
				'$_POST[section]',
				'$_POST[location]',
				'$_POST[keyw1]-$_POST[keyw2]-$_POST[keyw3]-$_POST[keyw4]-$_POST[keyw5]',
				'$_POST[keyd1]-$_POST[keyd2]-$_POST[keyd3]-$_POST[keyd4]-$_POST[keyd5]',
				'$_POST[keyof1]-$_POST[keyof2]-$_POST[keyof3]-$_POST[keyof4]-$_POST[keyof5]',
				'NOW()','','','','')")
		mysql_query("INSERT INTO iphistory(ip,hostname,datecreate)
		VALUES('$_POST[ip]',
			   '$_POST[host]',		
				'NOW()'	
				)");
	) 
	


	
	?>

Parse error: syntax error, unexpected 'mysql_query' (T_STRING) in C:\inetpub\wwwroot\mci\admin\model.php on line 21

3 个解决方案

#1


1  

After if condition second bracket {} is required not first bracket. eg, if($con){....} not if($con)(....). Also there lack of ; after first query. Try this...

在if条件后,需要第二个括号{}而不是第一个括号。例如,如果(con){ ....}如果(con)美元(....)。也缺乏;在第一个查询。试试这个…

if ($module=='masterpc' AND $act=='input')
{
mysql_query("INSERT INTO masterpc(hostname,os,ip,user,section,location,keyos,keydown,keyoffice,datecreate,cH9,cH10,cH11,cH12) 
    VALUES('$_POST[host]',
            '$_POST[os]',
            '$_POST[ip]',
            '$_POST[user]',
            '$_POST[section]',
            '$_POST[location]',
            '$_POST[keyw1]-$_POST[keyw2]-$_POST[keyw3]-$_POST[keyw4]-$_POST[keyw5]',
            '$_POST[keyd1]-$_POST[keyd2]-$_POST[keyd3]-$_POST[keyd4]-$_POST[keyd5]',
            '$_POST[keyof1]-$_POST[keyof2]-$_POST[keyof3]-$_POST[keyof4]-$_POST[keyof5]',
            'NOW()','','','','')");
                                 ^^^
    mysql_query("INSERT INTO iphistory(ip,hostname,datecreate)
    VALUES('$_POST[ip]',
           '$_POST[host]',      
            'NOW()' 
            )");
 }

#2


0  

Blocks are denoted with braces ({ ... }), not parens (( ... )).

块用大括号表示({…),而不是parens(…)。

if (...)
{
   ...
}

#3


0  

the form post

的形式发布

<html>

<h2>Input Master PC</h2>
<form id=validasi method=POST action='model.php?module=masterpc&act=input'>
<table>
<tr><td>HOST NAME</td>
<td> : <input type=text name=host maxlength=12  size=13 class='required' title='nama Kelas harus diisi !'>
		<?php
		include('componentdata/data_host.php');
		?>
</td></tr>
<tr><td>OS</td>
<td> : <input type=text name=os class='required' title='nama Kelas harus diisi !'>
		<?php
		include('componentdata/data_os.php');
		?>
</td></tr>
<tr><td>IP</td>
<td> : <input type=text name=ip maxlength=15 size=30 class='required' title='nama Kelas harus diisi !'>
		<?php
		include('componentdata/data_ip.php');
		?>

</td></tr>
<tr><td>USER</td>
<td> : <input type=text name=user size=40 class='required' title='nama Kelas harus diisi !'>
		
</td></tr>

<tr><td>Section</td>
<td> : <input type=text name=section size=60 class='required' title='nama Kelas harus diisi !'>
		<?php
		include('componentdata/data_section.php');
		?>

</td></tr>
<tr><td>Location</td>
<td> : <input type=text name=location size=40 class='required' title='nama Kelas harus diisi !'>
		
</td></tr>
<tr><td>Product Key Windows</td>
<td> : <input type=text maxlength=5 name=keyw1 size=6 class='required' title='nama Kelas harus diisi !'>
		<input type=text maxlength=5 name=keyw2 size=6 class='required' title='nama Kelas harus diisi !'>
		<input type=text maxlength=5 name=keyw3 size=6 class='required' title='nama Kelas harus diisi !'>
		<input type=text maxlength=5 name=keyw4 size=6 class='required' title='nama Kelas harus diisi !'>
		<input type=text maxlength=5 name=keyw5 size=6 class='required' title='nama Kelas harus diisi !'>

</td></tr>
<tr><td>Product Key Downgrade</td>
<td> : <input type=text maxlength=5 name=keyd1 size=6 class='required' title='nama Kelas harus diisi !'>
		<input type=text maxlength=5 name=keyd2 size=6 class='required' title='nama Kelas harus diisi !'>
		<input type=text maxlength=5 name=keyd3 size=6 class='required' title='nama Kelas harus diisi !'>
		<input type=text maxlength=5 name=keyd4 size=6 class='required' title='nama Kelas harus diisi !'>
		<input type=text maxlength=5 name=keyd5 size=6 class='required' title='nama Kelas harus diisi !'>

</td></tr>
<tr><td>Product Key Office</td>
<td> : <input type=text maxlength=5 name=keyof1 size=6 class='required' title='nama Kelas harus diisi !'>
		<input type=text maxlength=5 name=keyof2 size=6 class='required' title='nama Kelas harus diisi !'>
		<input type=text maxlength=5 name=keyof3 size=6 class='required' title='nama Kelas harus diisi !'>
		<input type=text maxlength=5 name=keyof4 size=6 class='required' title='nama Kelas harus diisi !'>
		<input type=text maxlength=5 name=keyof5 size=6 class='required' title='nama Kelas harus diisi !'>

</td></tr>
<tr><td colspan=2><input type=submit value=Simpan>
<input type=button value=Batal onclick=self.history.back()>
</td></tr>
</table>
</form>

</html>

#1


1  

After if condition second bracket {} is required not first bracket. eg, if($con){....} not if($con)(....). Also there lack of ; after first query. Try this...

在if条件后,需要第二个括号{}而不是第一个括号。例如,如果(con){ ....}如果(con)美元(....)。也缺乏;在第一个查询。试试这个…

if ($module=='masterpc' AND $act=='input')
{
mysql_query("INSERT INTO masterpc(hostname,os,ip,user,section,location,keyos,keydown,keyoffice,datecreate,cH9,cH10,cH11,cH12) 
    VALUES('$_POST[host]',
            '$_POST[os]',
            '$_POST[ip]',
            '$_POST[user]',
            '$_POST[section]',
            '$_POST[location]',
            '$_POST[keyw1]-$_POST[keyw2]-$_POST[keyw3]-$_POST[keyw4]-$_POST[keyw5]',
            '$_POST[keyd1]-$_POST[keyd2]-$_POST[keyd3]-$_POST[keyd4]-$_POST[keyd5]',
            '$_POST[keyof1]-$_POST[keyof2]-$_POST[keyof3]-$_POST[keyof4]-$_POST[keyof5]',
            'NOW()','','','','')");
                                 ^^^
    mysql_query("INSERT INTO iphistory(ip,hostname,datecreate)
    VALUES('$_POST[ip]',
           '$_POST[host]',      
            'NOW()' 
            )");
 }

#2


0  

Blocks are denoted with braces ({ ... }), not parens (( ... )).

块用大括号表示({…),而不是parens(…)。

if (...)
{
   ...
}

#3


0  

the form post

的形式发布

<html>

<h2>Input Master PC</h2>
<form id=validasi method=POST action='model.php?module=masterpc&act=input'>
<table>
<tr><td>HOST NAME</td>
<td> : <input type=text name=host maxlength=12  size=13 class='required' title='nama Kelas harus diisi !'>
		<?php
		include('componentdata/data_host.php');
		?>
</td></tr>
<tr><td>OS</td>
<td> : <input type=text name=os class='required' title='nama Kelas harus diisi !'>
		<?php
		include('componentdata/data_os.php');
		?>
</td></tr>
<tr><td>IP</td>
<td> : <input type=text name=ip maxlength=15 size=30 class='required' title='nama Kelas harus diisi !'>
		<?php
		include('componentdata/data_ip.php');
		?>

</td></tr>
<tr><td>USER</td>
<td> : <input type=text name=user size=40 class='required' title='nama Kelas harus diisi !'>
		
</td></tr>

<tr><td>Section</td>
<td> : <input type=text name=section size=60 class='required' title='nama Kelas harus diisi !'>
		<?php
		include('componentdata/data_section.php');
		?>

</td></tr>
<tr><td>Location</td>
<td> : <input type=text name=location size=40 class='required' title='nama Kelas harus diisi !'>
		
</td></tr>
<tr><td>Product Key Windows</td>
<td> : <input type=text maxlength=5 name=keyw1 size=6 class='required' title='nama Kelas harus diisi !'>
		<input type=text maxlength=5 name=keyw2 size=6 class='required' title='nama Kelas harus diisi !'>
		<input type=text maxlength=5 name=keyw3 size=6 class='required' title='nama Kelas harus diisi !'>
		<input type=text maxlength=5 name=keyw4 size=6 class='required' title='nama Kelas harus diisi !'>
		<input type=text maxlength=5 name=keyw5 size=6 class='required' title='nama Kelas harus diisi !'>

</td></tr>
<tr><td>Product Key Downgrade</td>
<td> : <input type=text maxlength=5 name=keyd1 size=6 class='required' title='nama Kelas harus diisi !'>
		<input type=text maxlength=5 name=keyd2 size=6 class='required' title='nama Kelas harus diisi !'>
		<input type=text maxlength=5 name=keyd3 size=6 class='required' title='nama Kelas harus diisi !'>
		<input type=text maxlength=5 name=keyd4 size=6 class='required' title='nama Kelas harus diisi !'>
		<input type=text maxlength=5 name=keyd5 size=6 class='required' title='nama Kelas harus diisi !'>

</td></tr>
<tr><td>Product Key Office</td>
<td> : <input type=text maxlength=5 name=keyof1 size=6 class='required' title='nama Kelas harus diisi !'>
		<input type=text maxlength=5 name=keyof2 size=6 class='required' title='nama Kelas harus diisi !'>
		<input type=text maxlength=5 name=keyof3 size=6 class='required' title='nama Kelas harus diisi !'>
		<input type=text maxlength=5 name=keyof4 size=6 class='required' title='nama Kelas harus diisi !'>
		<input type=text maxlength=5 name=keyof5 size=6 class='required' title='nama Kelas harus diisi !'>

</td></tr>
<tr><td colspan=2><input type=submit value=Simpan>
<input type=button value=Batal onclick=self.history.back()>
</td></tr>
</table>
</form>

</html>