tp5 如何查询mysql中json数据


        例:表 so_custom

        id           custom_id                   content

        1            1                          {"buy":"2","sell":"3","stock":"1,2,3"}       
        2            4                          {"buy":"2","sell":"3","stock":"1,4"}  
        3            6                          {"buy":"2","sell":"3","stock":"1,22,3"}  
        4            7                          {"buy":"2","sell":"3","stock":"1"}  

        现在只知道 stock中有3,如何通过这个条件去找出相应的custom_id,tp5的查询写法是什么?
        这种写法($this->model->json(['content'])->where('content->stock',3)->select())只能在stock =3 的数据,无法找出 stock 包含 1,2,3 的数据,


使用like进行查询,你这属于模糊匹配 使用等于肯定查询不到数据

Csdn user default icon
php tp5数据表中信息拼接json字符串

表一:activity ![图片说明]( 表二:standard ![图片说明]( activity-id 是两表关联字段 两表内容动态改变,现在需要利用tp5写一个方法,前端调用,然后返回一个json串,json串格式如下: ![图片说明]( 主要就是把standard中activityid一致的放到对应activity的childMenus中 用的tp5,该怎么写?


比如这样 表1![图片说明]( 表2![图片说明]( 表1 item和表2item_id关联外键了已经 要怎么写才能输出类似json这种数据![图片说明]( 老哥们指导一下.


<div class="post-text" itemprop="text"> <p>Im getting json data from another server and need thouse data to be saved on mysql.I tryed this code but theres a problem when i run this code i get : Illegal string offset for each VALUES. I hope I made things clear if there's anything I didn't explain please do tell.</p> <pre><code> &lt;?php require('db.php'); $url = 'xxxxx'; $data =json_encode(array('xxx' =&gt; 'xxxx', 'xxxx' =&gt; 'xxxxx', 'xxxx' =&gt;'xxxx', 'xxxx' =&gt;'xxxx', 'xxxx' =&gt;'xxxx') ); $options = array( 'http' =&gt; array( 'header' =&gt; "Content-type: application/json", 'method' =&gt; 'POST', 'content' =&gt; $data ) ); $context= stream_context_create($options); $result = file_get_contents($url, false, $context); if ($result === FALSE) { } echo $result ; foreach ((array)$result as $row) { $table="INSERT INTO table_name(xxx,xxx,xx,xxx,xx,xxx,xxx,xxxx,xxx) VALUES('".$row["xxxx"]."','".$row["xxx"]."','".$row["xxx"]."','".$row["xxx"]."','".$row["xxx"]."','".$row["xxx"]."','".$row["xxx"]."','".$row["xxx"]."','".$row["xxxx"]."')"; if ($conn-&gt;query($table ) === TRUE) { echo "Record added Successfully&lt;br&gt;"; } else { echo "Error: " . $insert_value . "&lt;br&gt;" . $con-&gt;error; } } ?&gt; </code></pre> </div>


<div class="post-text" itemprop="text"> <p>I want to save this json array that my fb-login returns to a database. However I don't really know how to convert that into a string using php.</p> <pre><code>[{"id":"108124505876479","name":"Wakeboarding"},{"id":"112003352149145","name":"Bouldering"},{"id":"110008522357035","name":"Handball"}] </code></pre> <p>I have tried this code below but I am even not quite sure anymore whether what the fb login return is a json array or not.</p> <pre><code>$json = '{"id":"108124505876479","name":"Wakeboarding"},{"id":"112003352149145","name":"Bouldering"},{"id":"110008522357035","name":"Handball"}'; var_dump(json_decode($json)); </code></pre> <p>How would I be able to save the different sports to my database in a string?</p> <p>Any help would be much appreciated.</p> <p>Thanks.</p> <p>EDIT: The upper part returns NULL.</p> <hr> <p>SECOND EDIT:</p> <pre><code>if (array_key_exists('sports', $me)){ $json = '$me['sports']'; PROBLEM IS HERE $data = json_decode($json, true); $sports = array(); foreach ($data as $item) { $sports[] = $item['name']; } $user-&gt;fb_sports = $sports; } </code></pre> </div>

PHP / MySQL:SyntaxError:JSON.parse:JSON数据第1行第1列的意外字符

<div class="post-text" itemprop="text"> <p>I have this MySQL table:</p> <pre><code>mysql&gt; select * from members; +-------+-----------+-----------+ | memid | firstname | lastname | +-------+-----------+-----------+ | 1 | billal | begueradj | | 2 | bill | gates | | 3 | steve | jobs | +-------+-----------+-----------+ 3 rows in set (0.00 sec) </code></pre> <p>I have this code:</p> <pre><code>&lt;?php $output = array('error' =&gt; false); $members = array(); try { $db = new PDO('mysql:host=localhost;dbname=bill;charset=utf8', 'root', '' ); } catch(Exception $e) { die('Error in connecting to DB: &lt;br/&gt;'.$e-&gt;getMessage()); } $response = $db-&gt;query('SELECT * FROM members'); while($row = $response-&gt;fetch()){ echo $row['firstname'].' '; echo $row['lastname'].'&lt;br/&gt;'; array_push($members, $row); } $output['members'] = $members; $response-&gt;closeCursor(); $json = json_encode($out); echo $json; // outputs correctly header("Content-type: application/json"); // error here die(); ?&gt; </code></pre> <p>And I am getting this error message when I run the PHP file containing the PHP code above:</p> <blockquote> <p>SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data</p> </blockquote> <p>Why this happens?</p> <p>P.S. Of course, when I comment this line: <code>//header("Content-type: application/json");</code> the error message disappears</p> <p><strong>EDIT: New code version following the comments below:</strong></p> <pre><code>&lt;?php header("Content-type: application/json"); $output = array('error' =&gt; false); $members = array(); try { $db = new PDO('mysql:host=localhost;dbname=bill;charset=utf8', 'root', '' ); } catch(Exception $e) { die('Error in connecting to DB: &lt;br/&gt;'.$e-&gt;getMessage()); } $response = $db-&gt;query('SELECT * FROM members'); while($row = $response-&gt;fetch()){ array_push($members, $row); } $output['members'] = $members; $response-&gt;closeCursor(); $json = json_encode($out); //echo $json; ?&gt; </code></pre> <p>Still getting the same error message</p> </div>




<div class="post-text" itemprop="text"> <p>I am trying to workout how to format the brackets that are wrapping my JSON array. I am pulling the data for my array out of my database using this code.</p> <pre><code> $result = mysqli_query($con,"SELECT * FROM table"); $column = array(); while ($row = mysqli_fetch_array($result)) { $column[] = array(array($row[0],$row[1],$row[2],$row[3],$row[4],$row[5]),$row[3],$row[2],$row[0]); } </code></pre> <p>Once converted to JSON the Array prints to the screen in this format. I need the first square brackets to remain but need to swap the second set of brackets for (\').</p> <pre><code>var myVar = [ [["22","mike"," 151.1272","-33.9324","learning to fish","08\/14\/13"],"-33.93024"," 151.12896172","22"], [["23","mike"," -2.09875","51.44501","learning french","08\/04\/13"],"51.44501"," -2.09775","23"], [["24","mike"," -2.16375","51.44823019014051","Programming","08\/05\/13"],"51.451"," -2.1675","24"], ]; </code></pre> <p>So the Array should look more like this.</p> <pre><code>var myVar = [ ['"22","mike"," 151.12","-33.934","learning to fish","08\/14\/13"',"-33.94"," 151.12","22"], ['"23","mike"," -2.095","51.41","learning french","08\/04\/13"',"51.41"," -2.095","23"], ['"24","mike"," -2.165","51.41","Programming","08\/05\/13"',"51.44851"," -2.1675","24"], ]; </code></pre> <p>The reason I need the Array in this format is so that I can pass the data into Google Maps function which expects the Array to have 4 columns.</p> <p>I have worked out I can remove the brackets with a function like this, but the problem is it removes all the brackets and I need the external brackets;</p> <pre><code>$js_array = str_replace(array('[', ']'), '\'', htmlspecialchars(json_encode($column), ENT_NOQUOTES)); </code></pre> <p>How would I keep the external brackets and simply remove the internal brackets? If I have not given enough information or I should add any more details let me know.</p> <p>Thanks</p> </div>


/usr/local/src/mysql-8.0.15/sql/ 在函数‘Json_dom_ptr merge_doms(Json_dom_ptr, Json_dom_ptr)’中: /usr/local/src/mysql-8.0.15/sql/ 错误:无法将左值‘Json_object_ptr {aka std::unique_ptr<Json_object>}’绑定到‘std::unique_ptr<Json_object>&&’ return left_object; ^ In file included from /usr/local/include/c++/4.8.4/memory:81:0, from /usr/local/src/mysql-8.0.15/sql/json_dom.h:29, from /usr/local/src/mysql-8.0.15/sql/ /usr/local/include/c++/4.8.4/bits/unique_ptr.h:169:2: 错误:以初始化‘std::unique_ptr<_Tp, _Dp>::unique_ptr(std::unique_ptr<_Up, _Ep>&&) [with _Up = Json_object; _Ep = std::default_delete<Json_object>; <template-parameter-2-3> = void; _Tp = Json_dom; _Dp = std::default_delete<Json_dom>]的实参 1 unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept ^ /usr/local/src/mysql-8.0.15/sql/ 错误:无法将左值‘Json_array_ptr {aka std::unique_ptr<Json_array>}’绑定到‘std::unique_ptr<Json_array>&&’ return left_array; ^ In file included from /usr/local/include/c++/4.8.4/memory:81:0, from /usr/local/src/mysql-8.0.15/sql/json_dom.h:29, from /usr/local/src/mysql-8.0.15/sql/ /usr/local/include/c++/4.8.4/bits/unique_ptr.h:169:2: 错误:以初始化‘std::unique_ptr<_Tp, _Dp>::unique_ptr(std::unique_ptr<_Up, _Ep>&&) [with _Up = Json_array; _Ep = std::default_delete<Json_array>; <template-parameter-2-3> = void; _Tp = Json_dom; _Dp = std::default_delete<Json_dom>]’实参 1 unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept ^ /usr/local/src/mysql-8.0.15/sql/ 在成员函数‘virtual Json_dom_ptr Json_object::clone() const’中: /usr/local/src/mysql-8.0.15/sql/ 错误:无法将左值‘Json_object_ptr {aka std::unique_ptr<Json_object>}’绑定到‘std::unique_ptr<Json_object>&&’ return o; ^ In file included from /usr/local/include/c++/4.8.4/memory:81:0, from /usr/local/src/mysql-8.0.15/sql/json_dom.h:29, from /usr/local/src/mysql-8.0.15/sql/ /usr/local/include/c++/4.8.4/bits/unique_ptr.h:169:2: 错误:以初始化‘std::unique_ptr<_Tp, _Dp>::unique_ptr(std::unique_ptr<_Up, _Ep>&&) [with _Up = Json_object; _Ep = std::default_delete<Json_object>; <template-parameter-2-3> = void; _Tp = Json_dom; _Dp = std::default_delete<Json_dom>]的实参 1 unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept ^ /usr/local/src/mysql-8.0.15/sql/ 在成员函数‘virtual Json_dom_ptr Json_array::clone() const’中: /usr/local/src/mysql-8.0.15/sql/ 错误:无法将左值‘Json_array_ptr {aka std::unique_ptr<Json_array>}’绑定到‘std::unique_ptr<Json_array>&&’ return vv; ^ In file included from /usr/local/include/c++/4.8.4/memory:81:0, from /usr/local/src/mysql-8.0.15/sql/json_dom.h:29, from /usr/local/src/mysql-8.0.15/sql/ /usr/local/include/c++/4.8.4/bits/unique_ptr.h:169:2: 错误:以初始化‘std::unique_ptr<_Tp, _Dp>::unique_ptr(std::unique_ptr<_Up, _Ep>&&) [with _Up = Json_array; _Ep = std::default_delete<Json_array>; <template-parameter-2-3> = void; _Tp = Json_dom; _Dp = std::default_delete<Json_dom>]’实参 1 unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept ^ /usr/local/src/mysql-8.0.15/sql/ 在函数‘Json_dom_ptr merge_doms(Json_dom_ptr, Json_dom_ptr)’中: /usr/local/src/mysql-8.0.15/sql/ 警告:在有返回值的函数中,控制流程到达函数尾 [-Wreturn-type] } ^ /usr/local/src/mysql-8.0.15/sql/ 在成员函数‘virtual Json_dom_ptr Json_object::clone() const’中: /usr/local/src/mysql-8.0.15/sql/ 警告:在有返回值的函数中,控制流程到达函数尾 [-Wreturn-type] } ^ /usr/local/src/mysql-8.0.15/sql/ 在成员函数‘virtual Json_dom_ptr Json_array::clone() const’中: /usr/local/src/mysql-8.0.15/sql/ 警告:在有返回值的函数中,控制流程到达函数尾 [-Wreturn-type] } ^ make[2]: *** [sql/CMakeFiles/sql_main.dir/] 错误 1 make[1]: *** [sql/CMakeFiles/sql_main.dir/all] 错误 2 make: *** [all] 错误 2

从数据库取出来的格式是 json我怎么把他们放到

mySql 表中字段是 add_level 值是{"1":10,"2":30,"3":40} "1"代表是等级,10,代表的是人数,我怎么获取出来转换成JSONObject x对应等级,y代表人数,


{"Products":[{"years":"2006","proCode":"BYQ","throughput":"1","unit":"2","yield":"3","unit2":"4","totalHour" :"5"},{"years":"2006","proCode":"","throughput":"11","unit":"22","yield":"33","unit2":"44","totalHour" :"55"}],"Material":[{"years":"2006","matCode":"BYQ","consump":"111","unit":"222"}],"EnerConsu":[{"years" :"2006","energyCode":"BYQ","consump":"1111","unit":"2222","useMaterial":"3333","unit2":"4444"}]} 请大神帮解析这个json然后封装到对象.一共是三个对象

thinkphp中想把数据库中取出的数据 和利用count统计出的数字合并到一个数组中

```数组a Array ( [0] => Array ( [paper_id] => 2 [student] => 小丸子 [subject] => 信息技术 [sj_title] => 信息考试 [paper_createtime] => 2015-10-14 13:39:08 ) [1] => Array ( [paper_id] => 2 [student] => 小丸子 [subject] => 信息技术 [sj_title] => 信息考试 [paper_createtime] => 2015-10-14 13:39:08 ) ) 数组b Array ( [0] => Array ( [num] => 2 ) [2] => Array ( [num] => 1 ) ) 想要的结果: Array ( [0] => Array ( [paper_id] => 2 [student] => 小丸子 [subject] => 信息技术 [sj_title] => 信息考试 [paper_createtime] => 2015-10-14 13:39:08 [num] => 2 ) [1] => Array ( [paper_id] => 2 [student] => 小丸子 [subject] => 信息技术 [sj_title] => 信息考试 [paper_createtime] => 2015-10-14 13:39:08 [num] => 1 ) ) ``` 试了数组合并array_merge_recursive 和array_merge貌似都不行,应该如何实现?


<div class="post-text" itemprop="text"> <p>I have the following php file working fine on a webhost.</p> <pre><code>&lt;?php $dbhost = 'dbhost'; $dbuser = 'dbuser'; $dbpass = 'pass'; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die('Could not connect'.mysql_error()); } $sql = "SELECT FIELD1, FIELD2, FIELD3, FIELD4 FROM `TABLE` WHERE FIELD1 = 'VALUE1' "; mysql_select_db('MyDB'); $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('Could not get data: ' . mysql_error()); } while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) { echo "FIELD1" :{$row['FIELD1']} &lt;br&gt; ". "FIELD2 : {$row['FIELD2']} &lt;br&gt; ". "FIELD3 : {$row['FIELD3']} &lt;br&gt; "; $output[] = $row; } print(json_encode($row)); mysql_close($conn); ?&gt; </code></pre> <p>Link is here <a href="" rel="nofollow"></a></p> <p>Now, I would like to show this content in a TextView and I am unseccessfully using the following code</p> <pre><code>JSONObject object=getJSONObject(“result”); //comes from the print(json_encode ($result)); JSONArray arr=object.getJSONArray(“Value1”); //transforms the object Value1 in array for(int i=0;i&lt;arr.length;i++){ JSONObject obj1=arr.getJSONObject(i); String Value1=obj1.getString("Value1"); TextView.setText(Value1); //set TextView’s content to the String Value1 } </code></pre> <p>The manifest has permission to navigate the internet, the text view is in the layout etc, but STILL I can't put the PHP output in the TextView. What is wrong in my code?</p> </div>

Warning: Illegal string offset

出现Warning: Illegal string offset的解决方法


我要做一个(多语言或者多站点)+(自定义模型字段)的程序, 数据库该如何设计更高效和易拓展? 看别人程序是以 content 为主表 为模型附加一个 content+模型名称 的表 还有人说就做一个content的表,就做两个字段一个类型一个值,类似: ID 字段名 字段值 ------------------------------------ 1 title test 2 content 内容 这种方式来,那么请问,是以上两种方式哪种效率高, 有没有其他方式在保证高效的情况下实现,易拓展,易维护? 不要说用MANGO数据库,就MYSQL 也不要说序列化和JSON储存,太不安全


<div class="post-text" itemprop="text"> <p>I trying to print array value in php.Here i share my codes</p> <p><code>upload.php</code></p> <pre><code>$postdata = file_get_contents("php://input"); if(isset($postdata)){ $request = json_decode($postdata, true); var_dump($request); $artist_name = $request['testname']; if($artist_name != ""){ $con = mysqli_connect("localhost", "root", "upload", "ampache"); // Check connection if(mysqli_connect_errno()){ // echo "Failed to connect to MySQL: " . mysqli_connect_error(); } else{ $sql = "INSERT INTO album_details(artist_name) VALUES('$artist_name')"; $stmt = mysqli_query($con, $sql) or die ("MySQL Error:".mysqli_error($con)); } } } </code></pre> <p>when I tried this, I got <code>null</code> in view page,at the same time in console network(Response) it shows :</p> <pre><code>array(1) { ["testname"]=&gt; string(7) "vignesh" } </code></pre> <p>How to print <code>testname</code> in view page</p> <p>Full Code of <code>upload.php</code> file</p> <pre><code>&lt;?php header("Access-Control-Allow-Origin: *"); $connection = mysqli_connect("localhost", "root", "upload", "ampache"); // Establishing $postdata = file_get_contents("php://input"); if(isset($postdata)){ $request = json_decode($postdata, true); echo $postdata; $artist_name = $request['testname']; if($artist_name != ""){ $con = mysqli_connect("localhost", "root", "upload", "ampache"); // Check connection if(mysqli_connect_errno()){ // echo "Failed to connect to MySQL: " . mysqli_connect_error(); } else{ $sql = "INSERT INTO album_details(artist_name) VALUES('$artist_name')"; $stmt = mysqli_query($con, $sql) or die ("MySQL Error:".mysqli_error($con)); } } } $catalog = 1; $enabled = 1; $channels = 2; $update_time = 0; $user_upload = 1; $bitrate = 192000; $rate = 44100; $mode = "cbr"; echo $postdata; $use = 12; if(isset($_POST['submit'])){ // Fetching variables of the form which travels in URL $name = $_POST['name']; $query1 = mysqli_query($connection, "insert into album(name) values ('$name')"); $lastid = mysqli_insert_id($connection); $album_id = $lastid; } if(isset($_FILES['files'])){ $i = 0; foreach($_FILES['files']['tmp_name'] as $key =&gt; $tmp_name){ $i++; $a = 'C:\\\xampp\\\htdocs\\\ampache-3.8.6_all\\\songs\\\admin\\\ '; $b = $name; $mp3 = $_FILES['files']['name'][$key]; $path = "C:/xampp/htdocs/ampache-3.8.6_all/songs/"."/".$name."/"; $song = $path.$mp3; mkdir($path); if(move_uploaded_file($tmp_name, "$path/{$_FILES['files']['name'][$key]}")){ echo "file moved"; } else{ echo "file not moved"; } $filename = $song; $size = filesize($filename); $c = "\\\ ".$mp3; $file = $a.$b.$c; $query = mysqli_query($connection, "insert into song(title, catalog, enabled, channels, update_time, user_upload, mode, bitrate, rate, file, album, size) values ('$mp3', '$catalog', '$enabled', '$channels', '$update_time', '$user_upload', '$mode', '$bitrate', '$rate', '$file', '$album_id', '$size')"); } } mysqli_close($connection); // Closing Connection with Server ?&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt;&lt;/head&gt; &lt;body&gt; &lt;div class="signup-form" style="text-align:center;"&gt; &lt;form method="post" enctype="multipart/form-data"&gt; &lt;h2&gt;Upload Songs&lt;/h2&gt; &lt;p class="hint-text"&gt;Please upload your album&lt;/p&gt; &lt;div class="form-group"&gt; &lt;label for='name' class="color"&gt;Album Name&lt;/label&gt; &lt;input type="text" name="name" class="form-control"&gt; &lt;/div&gt; &lt;label for='file' class="color"&gt;upload&lt;/label&gt; &lt;input type="file" name="files[]" multiple="multiple"&gt; &lt;input type="submit" name="submit" value="submit" style="color: black;position: relative;left: 137px;bottom: 24px;"&gt; &lt;/form&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> </div>

使用PHP将Ajax POST数据保存到文件

<div class="post-text" itemprop="text"> <p>I am posting some data to a PHP file using ajax and saving it to a MySQL database. This works fine, but I also want to save one of the data elements to a text file (which should be created) on the server but I can't get it to save to a file.</p> <p>This is how my code looks:</p> <p><strong>jQuery</strong> (snippet)</p> <pre><code> var uid = "1"; var name = "bruno"; var number = "0889-123-123"; var location = "{"locationInfo":[{"title":"home","lat":-16.450902223672625,"lng":10.6103515625,"speed":""},{"title":"work","lat":-14.94621907436008,"lng":17.99560546875,"speed":""}]}" $.ajax({ type: "POST", url: "process.php", data: {uid:uid, name:name, number:number, location:location}, dataType: 'json', cache: false, }) </code></pre> <p><strong>PHP - process.php</strong></p> <pre><code>&lt;?php $inputvalues = $_POST; $errors = false; $result = false; $mysqli = new mysqli('localhost', "root", "", "tp"); if (mysqli_connect_errno()) { printf("Connect failed: %s ", mysqli_connect_error()); exit(); } foreach ($inputvalues as $key =&gt; $value) { if(isset($value) &amp;&amp; !empty($value)) { $inputvalues[$key] = $mysqli-&gt;real_escape_string( $value ); } else { $errors[$key] = 'The field '.$key.' is empty'; } } if( !$errors ) { $mysqli-&gt;query(" INSERT INTO `table`(`uid`, `name`, `number`) values ('".$inputvalues['uid']."', '".$inputvalues['name']."', '".$inputvalues['number']."'); "); file_put_contents('saved/file.txt', file_get_contents('".$inputvalues['location']."')); } mysqli_close($mysqli); $returnResult ="success"; echo json_encode(['result' =&gt; $returnResult, 'errors' =&gt; $errors]); exit; ?&gt; </code></pre> </div>


<div class="post-text" itemprop="text"> <p>I have created a page for drag n drop in which the elements are cloned in draggable space and are then stored in database.I'm storing the id,height,width,x_pos,y_pos. all this work is done in .js file. How should I retrieve the data in javascript page n check whether element was dropped previously. When I reload page,its starts from the beginning, means have to drag the element. Can anyone give some idea.</p> <pre><code>// JavaScript Document $(document).ready(function () { var x = null; //Make element draggable $(".drag").draggable({ helper: 'clone', cursor: 'move', tolerance: 'fit' }); var i=1,j=0; var x1,x2,y1,y2; var sf=pf; //this is the scalig factor var tmp; var fty=ft; // this is the floor_type i'm getting from php page var fd=fid; $("#droppable").droppable({ drop: function(e, ui) { var attr=ui.helper.attr('id'); // document.write(attr); if(typeof attr == typeof undefined || attr == false) { ui.helper.attr('id',"id"+i); } x = ui.helper.clone().bind("click",'img',function(){ alert("clicked"+ ui.helper.attr('id') ); var cor=window.prompt("Enter coordinates width*height"); tmp=ui.helper.attr('id'); //document.write("position"); var leftpos=($(this).offset().left) - 210; var toppos=($(this).offset().top); //document.write("position" + leftpos+" " + toppos); var c=cor.split("*"); var wt=c[0]; var ht=c[1]; var w=wt*sf; var h=ht*sf; $(this).width(w); $(this).height(h); var leftpos=($(this).offset().left)-241; var toppos=($(this).offset().top); alert("position"+ leftpos + toppos); window.location.href="roomdata.php?id="+tmp+"&amp;"+"width="+w+"&amp;"+"height="+h+"&amp;"+"leftpos="+leftpos+"&amp;"+"toppos="+toppos+"&amp;"+"floor_type="+fty+"&amp;"+"floor_id="+fd; }); x.draggable({ helper: 'original', containment: '#droppable', tolerance: 'fit' }); x.appendTo('#droppable'); ui.helper.remove(); i++; } }); }); //ROOMDATA.PHP &lt;?php include("config.php"); $rid=$_GET['id']; $wth=$_GET['width']; $hgt=$_GET['height']; $lp=$_GET['leftpos']; $tp=$_GET['toppos']; $ft=$_GET['floor_type']; $fid=$_GET['floor_id']; //echo "hello". $rid." ".$wth." ".$hgt." ".$lp." ".$tp." ".$ft." "; $sql="Insert into room_m(floor_id,room_as_id,width,height,start_x,start_y)values('".$fid."','".$rid."','".$wth."','".$hgt."','".$lp."','".$tp."')"; $result=mysqli_query($con,$sql); if($result) { //echo "done"; header("location:rooms.php"); } else echo "error"; ?&gt; </code></pre> <p>here is the code for html side.I'm using php also for getting the data from another page i.e floor id and then generating a floor on the basis of the data which I get. I'm also using session as if I have selected floor id=0 then that will remain same for the time being until the user finishes adding rooms to the floor. If its new that it will generate new rooms,If it is already there then it will get data from the database and then show the div tag.But I don't know how to display the div tag,I'm getting the data from database.</p> <pre><code> &lt;html&gt; &lt;head&gt; &lt;script src="" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript" &gt; google.load("jquery", "1.6.3"); google.load("jqueryui", "1.8.16"); &lt;/script&gt; &lt;link rel="stylesheet" type="text/css" href="jqueryui1.css"/&gt; &lt;!--&lt;link rel="stylesheet" type="text/css" href=""/&gt;--&gt; &lt;script src="dragndrop.js" type="text/javascript"&gt;&lt;/script&gt; &lt;link rel="stylesheet" href="jqueryui-ruler/css/jquery.ui.ruler.css"&gt; &lt;script src="external/jquery-1.11.1.min.js"&gt;&lt;/script&gt; &lt;script src="external/jquery-ui.min.js"&gt;&lt;/script&gt; &lt;script src="jqueryui-ruler/js/jquery.ui.ruler.js"&gt;&lt;/script&gt; &lt;script language="JavaScript"&gt; $(document).ready(function () { $('#droppable').ruler(); }); &lt;/script&gt; &lt;style type="text/css"&gt; .col{ float:left; padding: 5px 5px 5px 5px; margin: 5px 5px 5px 5px; } #col1{ width:200px; height:500px; border:1px solid black; } .drag{ width:100px; border:1px solid black; height:40px; position:relative; background-color:red; background-image:url(restaurant/8793_532242100147879_270911928_n.jpg); } #droppable{ padding-top:18px; padding-left:18px; padding-right:20px; border:1px solid black; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;?php require("config.php"); $id=$_SESSION['restid']; if(isset($_SESSION['ft'])){ $ft=$_SESSION['ft']; $query="select floor_id,width,height from floor_m where floor_type='".$ft."' and rest_id='".$id."'"; $res1=mysqli_query($con,$query); $row1=mysqli_fetch_row($res1); $fd=$row1[0]; $w=$row1[1]; $h=$row1[2]; echo $fd; $query2="select room_as_id,width,height,start_x,start_y from room_m where floor_id='".$fd."'"; $res2=mysqli_query($con,$query2); $row2=mysqli_fetch_row($res2); $rai=$row2[0]; $ww=$row2[1]; $hh=$row2[2]; $xx=$row2[3]; $yy=$row2[4]; echo $rai,$ww,$hh,$xx,$yy; $wd=500/$w; $_SESSION['wd']=$wd; $_SESSION['ft']=$ft; $_SESSION['fid']=$fd; echo '&lt;script&gt;var pf = '.json_encode($_SESSION['wd']).'; var ft='.json_encode($_SESSION['ft']).'; var fid='.json_encode($_SESSION['fid']).';&lt;/script&gt;'; $ht=$h*$wd; } else{ $ft=$_POST['fl_type']; //echo $ft; $sql="select width,height,floor_id from floor_m where floor_type='".$ft."' and rest_id='".$id."'"; //echo $sql; $res=mysqli_query($con,$sql); $row=mysqli_fetch_row($res); $w=$row[0]; $h=$row[1]; $fid=$row[2]; $wd=500/$w; $_SESSION['wd']=$wd; $_SESSION['ft']=$ft; $_SESSION['fid']=$fid; echo '&lt;script&gt;var pf = '.json_encode($_SESSION['wd']).'; var ft='.json_encode($_SESSION['ft']).'; var fid='.json_encode($_SESSION['fid']).';&lt;/script&gt;'; $ht=$h*$wd; } //echo $wd,$ht; ?&gt; &lt;div id="wrapper"&gt; &lt;div class = "col" id="col1"&gt; &lt;img src="" id="drag1" class="drag"&gt; &lt;/div&gt; &lt;div class="col" id="droppable" style="width:500px;position:relative; height:&lt;?php echo $ht;?&gt;"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> </div>


<div class="post-text" itemprop="text"> <p>I've got this problem I'm having with <code>bind_param</code> and I have no clue what's going wrong:</p> <pre><code>&lt;?php $mysqli = new mysqli("$host","$user","$pass","$db"); if(isset($_GET['catName'])) { $category = "%" . $_GET['catName'] . "%"; } //setup query $catSearch = $mysqli-&gt;stmt_init(); //search values $catQuery = "SELECT lister_id, logo_file_name, listing_name, street_address, city, state, zip FROM listers INNER JOIN listings ON listers.lister_id = listings.lister_id WHERE listings.listing_category LIKE ?"; $catSearch-&gt;prepare($catQuery); $catSearch-&gt;bind_param('s', $category); $catSearch-&gt;bind_result($id, $imgfile, $name, $address, $city, $state, $zip); $catSearch-&gt;execute(); $catSearch-&gt;store_result(); $mainRows = $catSearch-&gt;num_rows(); ?&gt; </code></pre> <p>The warning I'm getting is:</p> <pre><code>Warning: mysqli_stmt::bind_param(): invalid object or resource mysqli_stmt in C:\wamp\www\RP\catSearch.php on line 29 </code></pre> <p>And what's killing me is this exact syntax is holding together 7 or 8 other documents just like it, but for some reason this one keeps breaking. I've checked each of the tables, and they're good (which was the problem the last time this happened). I'm making sure I'm declaring my <code>stmt_init()</code> well before everything else (had a problem with that before, too). I've got echo <code>$_GET['catName']</code> printed all over the sheet, so it's coming through (had a problem there once as well).</p> <p>Also, a more meta question, but I've been told using bind_param is the best way to prevent SQL injection; is this really all the security I need? (I mean, within reason, I'm sure there's more security, but this is a small yellow pages type of site).</p> </div>


错误界面 ![图片说明]( html ``` <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content=""> <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! --> <meta name="description" content=""> <meta name="author" content=""> <link rel="icon" href=""> <title>泡车堂登录</title> <!-- Bootstrap core CSS --> <link href="/carProject/Public/css/bootstrap.min.css" rel="stylesheet"> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> <![endif]--> </head> <body> <div class="container" id="d1"> <div class="row"> <div class="col-sm-6 col-sm-offset-3 form-box"> <div class="form-top"> <h2>泡车堂商户PAD版</h2> </div> <div class="form-bottom"> <form role="form" method="post" class="login-form"> <div class="form-group"> <label class="sr-only" >用户名</label> <input type="text" name="username" placeholder="请输入您的用户名" class="form-control" required> </div> <div class="form-group"> <label class="sr-only" >密码</label> <input type="password" name="password" placeholder="请输入您的密码" class="form-control" required> </div> <button type="button" class="btn btn-primary btn-block" onclick="login.check()">登录</button> </form> </div> </div> </div> </div> <script type="text/javascript"> function autoHeight(){ var winHeight=0; if (window.innerHeight) winHeight = window.innerHeight; else if ((document.body) && (document.body.clientHeight)) winHeight = document.body.clientHeight; if (document.documentElement && document.documentElement.clientHeight) winHeight = document.documentElement.clientHeight; document.getElementById("d1").style.marginTop= winHeight/3 +"px"; } autoHeight(); window.onresize = autoHeight; </script> <script src="/carProject/Public/js/jquery.js"></script> <script src="/carProject/Public/js/dialog/layer.js"></script> <script src="/carProject/Public/js/dialog.js"></script> <script src="/carProject/Public/js/admin/login.js"></script> <!-- IE10 viewport hack for Surface/desktop Windows 8 bug --> </body> </html> ``` login.js ``` var login = { check : function() { // 获取登录页面中的用户名 和 密码 var username = $('input[name="username"]').val(); var password = $('input[name="password"]').val(); if(!username) { dialog.error('用户名不能为空'); } if(!password) { dialog.error('密码不能为空'); } var url = "/carProject/index.php?m=admin&c=login&a=check"; var data = {'username':username,'password':password}; // 执行异步请求 $.post $.post(url,data,function(result){ if(result.status == 0) { return dialog.error(result.message); } if(result.status == 1) { return dialog.success(result.message, ''); } },'JSON'); } } ``` AdminModel.class.php ``` <?php namespace Common\Model; use Think\Model; class AdminModel extends Model { private $_db = ''; public function __construct() { $this->_db = M('Admin'); } public function getAdminByUsername($username='') { $res = $this->_db->where('name="'.$username.'"')->find(); return $res; } } ``` LoginController.class.php ``` <?php namespace Admin\Controller; use Think\Controller; /** * use Common\Model 这块可以不需要使用,框架默认会加载里面的内容 */ class LoginController extends Controller { public function index(){ $this->display(); } public function check() { $username = $_POST['username']; $password = $_POST['password']; if(!trim($username)) { return show(0,'用户名不能为空'); } if(!trim($password)) { return show(0,'密码不能为空'); } print_r(C('DB_TYPE')); //导入当前项目下面的Model/AdminModel.class.php文件,然后实例化AdminModel类 $ret = D('Admin')->getAdminByUsername($username); print_r($ret); /* if(!$ret) { return show(0,'该用户不存在'); } if($ret['pwd'] != getMd5Password($password)) { return show(0,'密码错误'); } session('adminUser', $ret); return show(1,'登录成功');*/ } } ``` # 对数据库的配置 config.php ``` <?php return array( //'配置项'=>'配置值' //URL地址不区分大小写 'URL_CASE_INSENSITIVE' =>true, 'URL_MODEL'=>0, 'LOAD_EXT_CONFIG' => 'db', 'MD5_PRE' => 'sing_cms', 'HTML_FILE_SUFFIX' => '.html', ); ``` db.php ``` <?php return array( 'DB_TYPE' => 'mysql', 'DB_HOST' => '', 'DB_USER' => 'root', 'DB_PWD' => '111111', 'DB_PORT' => 3366, 'DB_NAME' => 'demo', 'DB_CHARSET' => 'utf8', 'DB_PREFIX' =>'t_', ); ```


大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...


今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...


文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...



技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

Linux 会成为主流桌面操作系统吗?

整理 |屠敏出品 | CSDN(ID:CSDNnews)2020 年 1 月 14 日,微软正式停止了 Windows 7 系统的扩展支持,这意味着服役十年的 Windows 7,属于...


loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...








提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...




关注、星标公众号,不错过精彩内容作者:黄工公众号:strongerHuang最近ST官网悄悄新上线了一款比较强大的工具:STM32CubeMonitor V1.0.0。经过我研究和使用之...






私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

冒泡排序动画(基于python pygame实现)

本项目效果初始截图如下 动画见本人b站投稿: 本项目对应github地址: python版本:3.6,pygame版本:1.9.3。(python版本一致应该就没什么问题) 样例gif如下 ======================= 大爽歌作,mad


Redis核心原理与应用实践 在很多场景下都会使用Redis,但是到了深层次的时候就了解的不是那么深刻,以至于在面试的时候经常会遇到卡壳的现象,学习知识要做到系统和深入,不要把Redis想象的过于复杂,和Mysql一样,是个读取数据的软件。 有一个理解是Redis是key value缓存服务器,更多的优点在于对value的操作更加丰富。 安装 yum install redis #yum安装 b...

现代的 “Hello, World”,可不仅仅是几行代码而已

作者 |Charles R. Martin译者 | 弯月,责编 | 夕颜头图 |付费下载自视觉中国出品 | CSDN(ID:CSDNnews)新手...


即将毕业的应届毕业生一枚,现在只拿到了两家offer,但最近听到一些消息,其中一个offer,我这个组据说客户很少,很有可能整组被裁掉。 想问大家: 如果我刚入职这个组就被裁了怎么办呢? 大家都是什么时候知道自己要被裁了的? 面试软技能指导: BQ/Project/Resume 试听内容: 除了刷题,还有哪些技能是拿到offer不可或缺的要素 如何提升面试软实力:简历, 行为面试,沟通能...


如果世界上都是这种不思进取的软件公司,那别说大部分程序员只会写 3 年代码,恐怕就没有程序员这种职业。

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...


阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...


不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...




虽然大公司并不是人人都能进,但我仍建议还未毕业的同学,尽力地通过校招向大公司挤,但凡挤进去,你这一生会容易很多。 大公司哪里好?没能进大公司怎么办?答案都在这里了,记得帮我点赞哦。 目录: 技术氛围 内部晋升与跳槽 啥也没学会,公司倒闭了? 不同的人脉圈,注定会有不同的结果 没能去大厂怎么办? 一、技术氛围 纵观整个程序员技术领域,哪个在行业有所名气的大牛,不是在大厂? 而且众所...




本文作者用对比非常鲜明的两个开发团队的故事,讲解了敏捷开发之道 —— 如果你的团队缺乏统一标准的环境,那么即使勤劳努力,不仅会极其耗时而且成果甚微,使用...