在文件之间传递PHP变量并将变量插入SQL表(Passing PHP variable between files and inserting the variable into a SQL table)
我有一个PHP文件,通过$ _GET通过URL获取值。 代码是$ thisID = $ _GET ['blog_id'];
现在在同一个文件中,我正在收集用户的条目并将其传递给带有post的HTML表单,该文件将数据输入到SQL表中。 我还想将blog_id输入数据库。
这是我正在使用的代码:
<form action="comment.php" method="POST"> Your name: <input type="text" name="display_name" size="25"><br> Your email: <input type="text" name="email" size="30"><br> Your comment: <input type="text" name="comment" size="40"><br> <input type="hidden" name="blog_id" value="<?php echo $_POST['$thisID']; ?>"> <input type="submit" value="Submit">
这就是我将值输入SQL表的方法
$command = "insert into $table_name values('','".$db->real_escape_string($_POST['comment'])."', '".$db->real_escape_string($_POST['blog_id'])."', '".$db->real_escape_string($_POST['display_name'])."', '".$db->real_escape_string($_POST['email'])."',now() );";
代码执行,我没有得到任何错误,但没有输入变量(blog_id),数据库中的字段为空。 正确输入所有其他字段。 是否有可能交出这样的PHP变量?
I have a PHP file that is getting a value through the URL through $_GET. The code is $thisID = $_GET['blog_id'];
Now in the same file, I am collecting entries from a user and passing it through an HTML form with post to a file that enters the data into a SQL table. I also want to enter the blog_id into the database.
This is the code I am using:
<form action="comment.php" method="POST"> Your name: <input type="text" name="display_name" size="25"><br> Your email: <input type="text" name="email" size="30"><br> Your comment: <input type="text" name="comment" size="40"><br> <input type="hidden" name="blog_id" value="<?php echo $_POST['$thisID']; ?>"> <input type="submit" value="Submit">
This is how I am entering the values into the SQL table
$command = "insert into $table_name values('','".$db->real_escape_string($_POST['comment'])."', '".$db->real_escape_string($_POST['blog_id'])."', '".$db->real_escape_string($_POST['display_name'])."', '".$db->real_escape_string($_POST['email'])."',now() );";
The code is executed, I don't get any errors but the variable (blog_id) is not entered, the field in the database is null. All other fields are entered correctly. Is it even possible to hand over a PHP variable like that?
原文:https://stackoverflow.com/questions/27222545
最满意答案
ID#site-title在顶部设置了大量填充。 如果减少它会收紧空间。
尝试这个:
#site-title { padding: 2.306em 0 0; }
The ID #site-title has a lot of padding set at the top. If you reduce that it will tighten up the space.
Try this:
#site-title { padding: 2.306em 0 0; }
相关问答
更多-
赞助商标志二十一(Sponsor logo twenty eleven)[2021-01-13]
创建一个包含图像的div并使用css定位它: CSS: #imgdiv { position:absolute; top:20px; left:-40px; } HTML: 注意:您需要调整“顶部”和“左侧”的值,以使其显示在您需要的位置。 Create a div with your image in it and position it using css: CSS: #imgdiv { ... -
在循环内获取摘录 - 二十六个主题Wordpress(Getting excerpt in loop within loop – Twenty sixteen theme Wordpress)[2022-09-30]
要获取标题,内容和精选图片等帖子详情,您可以使用以下代码: $latestPost = new WP_Query( array( 'post_type' => 'posts', 'posts_per_page' =>-1,'order' => 'ASC') ); while ( $latestPost->have_posts() ) : $latestPost->the_post(); $sTitle = the_title(); $sContent ... -
将徽标与文本对齐 - 二十一个孩子主题(Wordpress)(Align logo with text - Twenty Eleven child theme (Wordpress))[2022-09-15]
在Wordpress中添加到CSS页面: #site-title > span > a { line-height: 105px; } 这将使用img将文本拉到中心(如果它不是您想要的,请调整line-height ) 快乐编码:) Adding to your CSS page in Wordpress: #site-title > span > a { line-height: 105px; } This will pull your text down to center with ... -
ID#site-title在顶部设置了大量填充。 如果减少它会收紧空间。 尝试这个: #site-title { padding: 2.306em 0 0; } The ID #site-title has a lot of padding set at the top. If you reduce that it will tighten up the space. Try this: #site-title { padding: 2.306em 0 0; }
-
你有一个示例网站吗? 每个小部件都应该拥有自己的ID。 使用这些来设置它们使用CSS http://twentyelevendemo.wordpress.com/ - 这是一个二十一的演示。 在你的页脚中 do you have an example site? every widget should have it's own ID. Use those to style them using css http://twentyelevendemo.wordpress.com/ - here is a d ...
-
为什么不使用自定义标题上传新图像? (外观>标题) http://yourdomain.com/wp-admin/themes.php?page=custom-header如果您希望图像具有SEO友好性,您可以转到MEDIA并为备用文本添加标题图片。 Wow Thanks very much found the answer here http://wordpress.org/support/topic/how-to-move-menu-below-header-image-in-twenty-twelve ...
-
这由/navigation.js脚本处理。 对此负责的是: