I have had my webpages in diferents hostings, and in all this hosting it was working fine, a few days a go, I bought one hosting in godaddy, I made the backup of the database, and then I put it in the hosting of godaddy, but I have a problem, when I am trying to put de data of my query into an array to convert it in a json, it didnt show something. in the other hosting and localhost it is working fine.  $sql1 = "SELECT * FROM table Where somthing='$something'"; $ejecutar_sql1=mysqli_query($con,$sql1);  if (mysqli_num_rows($ejecutar_sql1) &gt; 0){     $rawdata = array();      $i=0;     while($row = mysqli_fetch_array($ejecutar_sql1))     {         $rawdata[$i] = $row;         $i++;     }     echo json_encode($rawdata); }    If I put echo mysqli_num_rows($ejecutar_sql1); its show me 270.  If I put echo $row["id"]; inside the while, it show me all the id.  If I put echo count($rawdata); its show me 270.  But the echo json_encode($rawdata); it didnt show something.   thanks for the help
326
I'm setting up a new server and want to support UTF-8 fully in my web application. I have tried this in the past on existing servers and always seem to end up having to fall back to ISO-8859-1.  Where exactly do I need to set the encoding/charsets? I'm aware that I need to configure Apache, MySQL, and PHP to do this — is there some standard checklist I can follow, or perhaps troubleshoot where the mismatches occur?  This is for a new Linux server, running MySQL 5, PHP, 5 and Apache 2.
47900
In my little age with WordPress, I've seen WordPress itself and its friendly plugins are using PHP serialize() in storing data into db in many cases. But in a recent search I found a serious community support for the json_encode() over the serialize().     And I personally tested an associative array with both of 'em, that shows:  serialize() stores 342 chars json_encode() stores 285 chars  Why I'm asking this? I'm on a project while I'm going to store repeating meta fields to a post. Where:  Data would be basically in English, but sometimes can be Bengali Data would be associative array, 3 level deep (I hope I understood levels correctly):   array(     1 =&gt; array(         'key'=&gt;'value',         'key2'=&gt;'value'     ),     2 =&gt; array(         'key'=&gt;'value',         'key2'=&gt;'value'     ) )  I've checked the postmeta table's meta_value field it's a longtext,  a length of 4,294,967,295 chars (4GB). So I need a robust solution into storing things.
78016
For the last couple of days I've been getting the following error:     Fatal error: Undefined class constant 'MYSQL_ATTR_USE_BUFFERED_QUERY' in /home/mydomain/public_html/drupal/includes/database/mysql/database.inc on line 46   This comes after my Hosting did an upgrade and PHP is now version 5.2.17.  From what they have told me, I think I have to enable a PDO MySQL extension in php.ini.  The problem is I'm on a shared hosting and I don't have access to the file; also, my Hosting said they can't change it either.  My info.php shows:     PDO      PDO support enabled      PDO drivers sqlite, sqlite2        pdo_sqlite      PDO Driver for SQLite 3.x enabled      PECL Module version (bundled) 1.0.1 $Id: pdo_sqlite.c 293036 2010-01-03 09:23:27Z   sebastian $      SQLite Library 3.3.7     I tried modifying the .htaccess file and/or adding my own php.ini file to the root directory per some suggestions I found, but nothing I've tried has worked yet.  Can anyone please suggest what else I could do?  EDIT:  Once again I asked the Hosting to enable PDO_MySQL extension and their answer was that they could not, that cPanel (to which they migrated from Plesk, causing this whole problem) had this extension disabled by default and changing it would affect their servers.  Their solution?  That I would change my programming to adjust to these new features, which I wouldn't even know how to go about.  Are they right requesting that I do this? Is there any other way?
119956
How can I move MySQL tables from one physical server to another?  Such as this exact scenario:  I have a MySQL server that uses innodb table and is about 20GB size.  I want to move it to a new server, what's the most efficient way to do this?
26631
I flagged a question, , as "low quality" but a moderator declined it. I thought that the post was a low quality one and would like to know why the moderator did not.  Hopefully shedding light on this matter will avail me of the knowledge to be a better flagger in future.  My logic was that mysql-fetch-row is not supposed to return an array of results. If it does than its name would be mysql-fetch-rows.  What's your take on the situation?
40506
I am writing a function that adds an ID number to an array and puts the array in the usermeta. $_GET['auction'] is the post_id.  Below is the function:  $reminders = get_user_meta( $current_user-&gt;ID, "reminders" ); print_r( $reminders ); if( in_array( $_GET['auction'], $reminders ) ) {     echo "Failed: Auction already in list"; } else {     array_push( $reminders, intval( $_GET['auction'] ) );     if ( update_user_meta( $current_user-&gt;ID, "reminders", $reminders ) ) {         echo "Success";     } else {         echo "Failed: Could not update user meta";     } } print_r( $reminders );   Here is the output after adding one auction:  Array ( )  Success Array ( [0] =&gt; 7 )    Here is the output after adding two auctions:  Array ( [0] =&gt; Array ( [0] =&gt; 7 ) )  Success Array ( [0] =&gt; Array ( [0] =&gt; 7 ) [1] =&gt; 73 )   And here is the output after adding three auctions:  Array ( [0] =&gt; Array ( [0] =&gt; Array ( [0] =&gt; 7 ) [1] =&gt; 73 ) )  Success Array ( [0] =&gt; Array ( [0] =&gt; Array ( [0] =&gt; 7 ) [1] =&gt; 73 ) [1] =&gt; 0 )   Notice that adding a new element to the array using array_push works fine. But when the array is stored in the usermeta then retrieved again, the last element in the array has been put into an array of its own, creating an infinitely dimensional array. I'd prefer to keep this array one dimensional.  Is there a way I can run update_user_meta and get_user_meta without it changing the structure of my array?
97704
I just visited  and for me it shows no results. Has something broken?   The problem occurs for me , but oddly not on some other sites I've tried, such as  or .   I have tried pressing Ctrl+F5 many times, but as yet no success in solving this. This has now been broken for days, leading me to believe that caching is not the culprit.  I've since noticed that the problem goes away if I add some tags as favourites (e.g. ). But I prefer to have no favourite tags, so the problem remains for me. What's odd is that I don't use favourite tags anywhere on the network, so the fact that the ServerFault and Programmers tab works for me is a mystery.
87186
For the following pretty straightforward task: query a list of products from a DB and present it on a webpage, consider 2 setups:  Setup1: PHP script queries. All content is built on the server and the entire page is served back to the client.  Setup2: Static HTML "page skeleton" requesting content using AJAX. Received content is parsed on the client side using Javascript and rendered using innerHTML or similar.  Of course the second setup only makes sense when you have pages, categories and tags for the client user to choose from.  I need to compare these two, at least by means of:   time it will take content to be served user experience (setup1 is delivered as a whole, setup2 is delivered in "two parts") scalability - how do the setups compare when I have 100,000 queries daily   Any thoughts on the issue will be much appreciated.
122136
I've called GoDaddy a few different times and they said that it looks like it is a problem with my HTML file.  Except, my HTML file is the basic outline of a webpage, nothing fancy at all.    Chrome still says that the webpage is, "Not Secure" with the big red x over it.    I'm not sure what to do to fix it, I don't have any personal information on the site nor am I collecting any information from visitors (it's sort of an information site).  I shouldn't need an SSL certificate because I am not hosting anything privately.
5230
Here's my attempt at it:  $query = $database-&gt;prepare('SELECT * FROM table WHERE column LIKE "?%"');  $query-&gt;execute(array('value'));  while ($results = $query-&gt;fetch())  {     echo $results['column']; }
96046
I am having a few issues when people are trying to access a MySQL database and they are trying to update tables with the same information.  I have a webpage written using PHP. In this webpage is a query to check if certain data has been entered into the database. If the data hasn't, then i proceed to insert it. The trouble is that if two people try at the same time, the check might say the data has not been entered yet but when the insert takes place it has been by the other person.  What is the best way to handle this scenario? Can i lock the database to only process my queries first then anothers?
98275
If I go to e.g.  while logged in at Data.SE, the ##UserId## parameter isn't populated like it usually is. This was originally only happening for some sites, but now it seems to be happening for all of them.
73
If user input is inserted without modification into an SQL query, then the application becomes vulnerable to , like in the following example:  $unsafe_variable = $_POST['user_input'];   mysql_query("INSERT INTO `table` (`column`) VALUES ('$unsafe_variable')");   That's because the user can input something like value'); DROP TABLE table;--, and the query becomes:  INSERT INTO `table` (`column`) VALUES('value'); DROP TABLE table;--')   What can be done to prevent this from happening?
106137
If we have 2 tables  **user** +----+------+------+-----------+ | id | user | pass | gender_id | +----+------+------+-----------+ | 1  | lisa | good |     11    | | 2  | jack | pass |     10    | | 3  | paul | 5555 |     10    | | 4  | rich | none |     10    | +----+------+------+-----------+  **gender** +----+--------+ | id | gender | +----+--------+ | 11 | female | | 10 | male   | +----+--------+   If we join  them like so  SELECT user.id, user.user, user.pass, user.gender_id, gender.gender FROM `user` JOIN `gender` on user.gender_id   The result of query  array(4) {   [0]=&gt;   array(4) {     ["id"]=&gt;     string(3) "2"     ["type"]=&gt;     string(6) "jack"     ["pass"]=&gt;     string(11) "pass"     ["gender"]=&gt;     string(1) "male"     }   [1]=&gt;   array(4) {     ["id"]=&gt;     string(3) "3"     ["type"]=&gt;     string(6) "paul"     ["pass"]=&gt;     string(11) "5555"     ["gender"]=&gt;     string(1) "male"     }   [2]=&gt;   array(4) {     ["id"]=&gt;     string(3) "4"     ["type"]=&gt;     string(6) "rich"     ["pass"]=&gt;     string(11) "none"     ["gender"]=&gt;     string(1) "male"     }   [3]=&gt;   array(4) {     ["id"]=&gt;     string(3) "1"     ["type"]=&gt;     string(6) "lisa"     ["pass"]=&gt;     string(11) "good"     ["gender"]=&gt;     string(1) "female"     }   The order has now changed even though we did not specify this.(user lisa is last) If we change lisa gender_id to 11, and run the same query, the result will be  array(4) {   [0]=&gt;   array(4) {     ["id"]=&gt;     string(3) "1"     ["type"]=&gt;     string(6) "lisa"     ["pass"]=&gt;     string(11) "good"     ["gender"]=&gt;     string(1) "male"     }   [1]=&gt;   array(4) {     ["id"]=&gt;     string(3) "2"     ["type"]=&gt;     string(6) "jack"     ["pass"]=&gt;     string(11) "pass"     ["gender"]=&gt;     string(1) "male"     }   [2]=&gt;   array(4) {     ["id"]=&gt;     string(3) "3"     ["type"]=&gt;     string(6) "paul"     ["pass"]=&gt;     string(11) "5555"     ["gender"]=&gt;     string(1) "male"     }   [3]=&gt;   array(4) {     ["id"]=&gt;     string(3) "4"     ["type"]=&gt;     string(6) "rich"     ["pass"]=&gt;     string(11) "none"     ["gender"]=&gt;     string(1) "male"     }   This result is how the rows are positioned in the table(user lisa first), which is represented correctly in the results as we did not specify any order.  Why is the first result set being ordered when we are not specifying this. It does not seem correct, I want the results to be pulled exactly how they are positioned in the table.  Thanks
33938
I have one of those "I swear I didn't touch the server" situations. I honestly didn't touch any of the php scripts. The problem I am having is that php data is not being saved across different pages or page refreshes. I know a new session is being created correctly because I can set a session variable (e.g. $_SESSION['foo'] = "foo" and print it back out on the same page just fine. But when I try to use that same variable on another page it is not set! Is there any php functions or information I can use on my hosts server to see what is going on?  Here is an example script that does not work on my hosts' server as of right now:  &lt;?php session_start(); if(isset($_SESSION['views']))     $_SESSION['views'] = $_SESSION['views']+ 1; else     $_SESSION['views'] = 1;  echo "views = ". $_SESSION['views']; echo '&lt;p&gt;&lt;a href="page1.php"&gt;Refresh&lt;/a&gt;&lt;/p&gt;'; ?&gt;   The 'views' variable never gets incremented after doing a page refresh. I'm thinking this is a  problem on their side, but I wanted to make sure I'm not a complete idiot first.  Here is the phpinfo() for my hosts' server (PHP Version 4.4.7):
60004
Is it possible to convert a timestamp to a date format in a query?  This is the code I am using.  $query = db_select('my_submissions', 's'); $query-&gt;fields('s', array('sid','name','company','email','phone','is_customer','submitted','count')); $entries = $query-&gt;execute();  $rows = array(); foreach ($entries as $entry) {   $row = array_map('check_plain', (array) $entry);   $row['submitted'] = $row['submitted'] ? date('d.m.Y H:i', $row['submitted']) : "";   $rows[] = $row; }
1833
Recently I started getting an error every time I try and add a content no matter what type.  This is the error that shows up in the browser:     Additional uncaught exception thrown while handling exception.        Original   PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT COUNT(cid) FROM {comment} WHERE status = :status; Array ( [:status] =&gt; 0 ) in comment_count_unpublished() (line 313 of /Applications/MAMP/htdocs/modules/comment/comment.module).        Additional      PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: INSERT INTO {watchdog} (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] =&gt; 1 [:db_insert_placeholder_1] =&gt; php [:db_insert_placeholder_2] =&gt; %type: !message in %function (line %line of %file). [:db_insert_placeholder_3] =&gt; a:6:{s:5:&quot;%type&quot;;s:12:&quot;PDOException&quot;;s:8:&quot;!message&quot;;s:154:&quot;SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT COUNT(cid) FROM {comment} WHERE status = :status; Array ( [:status] =&amp;gt; 0 ) &quot;;s:9:&quot;%function&quot;;s:27:&quot;comment_count_unpublished()&quot;;s:5:&quot;%file&quot;;s:56:&quot;/Applications/MAMP/htdocs/modules/comment/comment.module&quot;;s:5:&quot;%line&quot;;i:313;s:14:&quot;severity_level&quot;;i:3;} [:db_insert_placeholder_4] =&gt; 3 [:db_insert_placeholder_5] =&gt; [:db_insert_placeholder_6] =&gt; ; [:db_insert_placeholder_7] =&gt;  [:db_insert_placeholder_8] =&gt; 127.0.0.1 [:db_insert_placeholder_9] =&gt; 1338336955 ) in dblog_watchdog() (line 154 of /Applications/MAMP/htdocs/modules/dblog/dblog.module).   I also get the following error in my php error file:     PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2006 MySQL server has gone away' in /Applications/MAMP/htdocs/includes/database/database.inc:2136        Stack trace:   0 /Applications/MAMP/htdocs/includes/database/database.inc(2136): PDOStatement->execute(Array)   1 /Applications/MAMP/htdocs/includes/database/database.inc(664): DatabaseStatementBase->execute(Array, Array)   2 /Applications/MAMP/htdocs/includes/database/database.inc(2315): DatabaseConnection->query('SELECT expire, ...', Array, Array)   3 /Applications/MAMP/htdocs/includes/lock.inc(167): db_query('SELECT expire, ...', Array)   4 /Applications/MAMP/htdocs/includes/lock.inc(146): lock_may_be_available('theme_registry:...')   5 /Applications/MAMP/htdocs/includes/theme.inc(447): lock_acquire('theme_registry:...')   6 /Applications/MAMP/htdocs/includes/bootstrap.inc(427): ThemeRegistry->set(Array)   7 [internal function]: DrupalCacheArray->__destruct()   8 {main}         thrown in /Applications/MAMP/htdocs/includes/database/database.inc on line 2136   I am having a little trouble deciphering these error messages. Could anyone help me understand what's going on here?