解析错误:语法错误,C中意外的'$ num'(T_VARIABLE):如何解决这个问题 [英] Parse error: syntax error, unexpected '$num' (T_VARIABLE) in C: how to fix this

查看:96
本文介绍了解析错误:语法错误,C中意外的'$ num'(T_VARIABLE):如何解决这个问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





有这个错误,我需要知道我去了什么和哪里,它是空的,我是否必须使用和isset来修复它。错误是这个



解析错误:语法错误,意外'  $ num'(T_VARIABLE) in  C:





任何帮助将不胜感激。这是我的代码。



我尝试过:



< pre lang =PHP> < pre > <? php


$ db_host = ' localhost';
$ db_username = ' root';
$ db_password = ;
$ con = mysqli_connect($ db_host,$ db_username,$ db_password) die(mysqli_connect_error());

mysqli_select_db($ con,' food' die(mysqli_error($ con));
if(isset($ _ POST [' submit'])&& isset( $ _GET [' img_id']))
{
$ sql = < span class =code-string> SELECT * FROM tbl_images WHERE img_id = {$ img_id};
$ result = mysqli_query($ con,$ sql) die( 错误: .mysql_error($ con));
$ rowcount = mysqli_num_rows($ result);
}


?>
< html >
< ; 正文 >
< 表格 < span class =code-attribute> method = post enctype = multipart / form-data >
< br / >
< 输入 类型 = 文件 名称 = image >
< br / > < br / >
< input type = 提交 名称 = 提交 value = upload >
< / form >


<? php
if(isset($ _ POST [ ' submit'])&& isset($ _ FILES [' file']))
{
if( getimagesize($ _ FILES [' image'] [' tmp_name'])== false)
{
echo < span class =code-string> 请选择图像;
}
else
{

$ name = addslashes($ _ FILES [' image'] [' 名称]);
$ image = base64_encode(file_get_contents(addslashes($ _ FILES [' image'] [< span class =code-string>'
tmp_name'])));
saveimage($ name,$ image);
}
}

函数saveimage($ name,$ image)
{
$ con = mysqli_connect($ db_host,$ db_username,$ db_password, tbl_images);
$ sql = INSERT INTO tbl_images(name,image)value('$ name,'$ image' );
$ query = mysqli_query($ con,$ sql);

if($ query)
{
echo 成功;
}
其他
{
echo not Upload;
}

}
displayimage();
函数displayimage() // 此函数用于显示db中的图像
{
$ con = mysqli_connect($ db_host,$ db_username,$ db_password, tbl_images);
$ sql = SELECT * FROM tbl_images;
$ query = mysqli_query($ con,$ sql);
$ query = mysqli_query($ con,$ query)
$ num = mysqli_num_rows($ query);
for($ i = 0; $ i< $ num; $ i ++)
{
$ result = mysqli_fetch_array($ query);
$ img = $ result [' image'];
echo ' < img src = data:image; base64,'。$ img。' >';
}
mysqli_close($ con);
}

?>

< / body >
< / html >

解决方案

num'(T_VARIABLE) in C:





任何帮助将不胜感激。这是我的代码。



我尝试过:



< pre lang =PHP> < pre > <? php


db_host = ' localhost';


db_username = ' ;

hi

have this error and i need to know what and where did i gone ary, is it empty, do i have to use and isset to fix it. the error is this

Parse error: syntax error, unexpected '$num' (T_VARIABLE) in C:



any help would be appreciated. here is my codes.

What I have tried:

<pre><?php

		
		$db_host='localhost';
		$db_username='root';
		$db_password="";
		$con=mysqli_connect($db_host,$db_username, $db_password) or die (mysqli_connect_error());
		
		mysqli_select_db($con, 'food') or die (mysqli_error($con));
		if(isset($_POST['submit']) && isset($_GET['img_id']))
		{
			$sql= "SELECT * FROM tbl_images  WHERE img_id={$img_id}";
			$result=mysqli_query($con, $sql) or die("Error:" .mysql_error($con));
			$rowcount=mysqli_num_rows($result);
		}
		
			
?>
<html>
<body>	
		<form  method="post" enctype="multipart/form-data" >
			<br/>
				<input type="file" name="image">
				<br/><br/>
				<input type="submit" name="submit" value="upload">
		</form>
			
		
<?php		
		if(isset($_POST['submit'])&& isset($_FILES['file']))
		{
			if(getimagesize($_FILES['image']['tmp_name'])== false)
			{
				echo "Please select an image";
			}
			else
			{
				
				$name=addslashes($_FILES['image']['name']);
				$image=base64_encode(file_get_contents(addslashes($_FILES['image']['tmp_name'])));				
				saveimage($name, $image);
			}			
		}
	
	function saveimage($name,$image)
	{
			$con = mysqli_connect($db_host, $db_username, $db_password,"tbl_images");			
			$sql="INSERT INTO tbl_images(name,image) value('$name, '$image')";
			$query=mysqli_query($con, $sql);
			
			if($query)
			{
				echo "Success";
			}
			else
			{
				echo "not Upload";
			}
		
	}
	displayimage();	
	function displayimage()//this function is used to display the images from the db
	{
		$con = mysqli_connect($db_host, $db_username, $db_password,"tbl_images");			
		$sql="SELECT * FROM tbl_images";
		$query=mysqli_query($con, $sql);
		$query=mysqli_query($con, $query)
		$num=mysqli_num_rows($query);					
		for($i=0; $i<$num; $i++)
		{
			$result=mysqli_fetch_array($query);
			$img=$result['image'];
			echo'<img src="data:image;base64, '.$img. '">';
		}
		mysqli_close($con);
	}
			
?>		
		
</body>
</html>

解决方案

num' (T_VARIABLE) in C:



any help would be appreciated. here is my codes.

What I have tried:

<pre><?php


db_host='localhost';


db_username='root';


这篇关于解析错误:语法错误,C中意外的'$ num'(T_VARIABLE):如何解决这个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆