I'm moving my website from one server to another. I have exported the old php database and imported it to the new server. database name and login stayed the same (for now). There are 2 tables currently in the database. For one my php request works perfectly fine, for one it does not and I have no idea what might be wrong. The login files do not throw errors so they seem to work fine. Can anyone help? here is the code that does NOT work:
<?php
ini_set('display_errors', 1);
//phpinfo();
require '.ht-loginWriting.php';
$myquery="SELECT ID, title, shortDescription, text,date, referenceProject, workshop, otherTag FROM writings";
$query=mysql_query($myquery);
if(! $myquery){
echo mysql_error();
die;
}
$data=array();
for($x=0; $x < mysql_num_rows($query); $x++){
$data[]=mysql_fetch_assoc($query);
}
echo json_encode($data);
?>
.ht-loginWriting.php
<?php
$dbhost = 'localhost:3036';
$dbuser = 'username';
$dbpass = 'pw';
$database= 'urbanalphabets';
$table = 'writings';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
$db_found = mysql_select_db($database);
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
and this is the code that works:
<?php
ini_set('display_errors', 1);
//phpinfo();
require '.ht-loginChangeLog.php';
$myquery="SELECT ID, title, time, text, tag_iOS, tag_web, tag_android, tag_other FROM changeLog";
$query=mysql_query($myquery);
if(! $myquery){
echo mysql_error();
die;
}
$data=array();
for($x=0; $x < mysql_num_rows($query); $x++){
$data[]=mysql_fetch_assoc($query);
}
echo json_encode($data);
?>
.ht-loginChangeLog.php
<?php
$dbhost = 'localhost:3036';
$dbuser = 'username';
$dbpass = 'pw';
$database= 'urbanalphabets';
$table = 'changeLog';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
$db_found = mysql_select_db($database);
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
after using the function suggested to convert to utf-8 the follwing ajax request throws an error:
$.ajax ( {
url: theURL,
dataType: "json",
success: function ( data, textStatus, jqXHR ) {
console.log(data);
console.log("sucess");
receivedData=data;
console.log(receivedData[0].ID, receivedData[0].title, receivedData[0].shortDescription, receivedData[0].text, receivedData[0].date, "length", receivedData.length);
initialize();
},
error:function( jqXHR, textStatus, errorThrown ){
console.log("failing");
console.log(jqXHR);
console.log(errorThrown);
console.log(textStatus);
}
} );
error:
Object {readyState: 4, getResponseHeader: function, getAllResponseHeaders: function, setRequestHeader: function, overrideMimeType: function…}
abort: function (e){var t=e||w;return u&&u.abort(t),k(0,t),this}
always: function (){return i.done(arguments).fail(arguments),this}
complete: function (){if(l){var t=l.length;(function i(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=l.length:r&&(s=t,c(r))}return this}
done: function (){if(l){var t=l.length;(function i(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=l.length:r&&(s=t,c(r))}return this}
error: function (){if(l){var t=l.length;(function i(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=l.length:r&&(s=t,c(r))}return this}
fail: function (){if(l){var t=l.length;(function i(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=l.length:r&&(s=t,c(r))}return this}
getAllResponseHeaders: function (){return 2===b?a:null}
getResponseHeader: function (e){var t;if(2===b){if(!c){c={};while(t=Tn.exec(a))c[t[1].toLowerCase()]=t[2]}t=c[e.toLowerCase()]}return null==t?null:t}
overrideMimeType: function (e){return b||(p.mimeType=e),this}
pipe: function (){var e=arguments;return x.Deferred(function(n){x.each(t,function(t,o){var a=o[0],s=x.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&x.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+"With"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()}
progress: function (){if(l){var t=l.length;(function i(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=l.length:r&&(s=t,c(r))}return this}
promise: function (e){return null!=e?x.extend(e,r):r}
readyState: 4
responseText: "14[{"ID":"17","title":"Christmas Mlab demo day","shortDescription":"first ever public presentation of the prototype","text":"Unfortunately I was not there myself so there is not much I can say about it.","date":"2012-12-19 14:10:26","referenceProject":"1","workshop":"1","otherTag":"1"},{"ID":"22","title":"the App was born","shortDescription":"During the Multitouch Interaction Course at Media Lab Helsinki the very first prototype of the Urban Alphabets App was programmed using Open Frameworks.","text":"","date":"2012-12-10 12:18:28","referenceProject":"0","workshop":"0","otherTag":"0"},{"ID":"34","title":"
MUCH MORE CONTENT HERE
","date":"2014-04-07 11:20:54","referenceProject":"0","workshop":"0","otherTag":"0"}]"
setRequestHeader: function (e,t){var n=e.toLowerCase();return b||(e=v[n]=v[n]||e,y[e]=t),this}
state: function (){return n}
status: 200
statusCode: function (e){var t;if(e)if(2>b)for(t in e)m[t]=[m[t],e[t]];else C.always(e[C.status]);return this}
statusText: "OK"
success: function (){if(l){var t=l.length;(function i(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=l.length:r&&(s=t,c(r))}return this}
then: function (){var e=arguments;return x.Deferred(function(n){x.each(t,function(t,o){var a=o[0],s=x.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&x.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+"With"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()}
__proto__: Object
projectBlog.php:122
SyntaxError {stack: (...), message: "Unexpected token ["}
message: "Unexpected token ["
stack: (...)
get stack: function () { [native code] }
set stack: function () { [native code] }
__proto__: Error
projectBlog.php:123
parsererror