if I set new PDO( array(PDO::ATTR_PERSISTENT => true) ), how do I check if a persistent connection is open before creating the next one, or does PHP handle that automatically?
@Dave well that's just redundant. Maybe those people don't understand that fetchAll will do the same thing without having to perform an additional loop and create an additional array.
@dave mysql_* was not capable of supporting mysql features llikestored procedures, transactiona etc, also using those func u have to worry about escaping, sanitizing the user inputs where in pdo u dun hav to wry
do a simpler test with a file on your own server first :
$file = 'example.txt';
$newfile = 'example.txt.bak';
if (!copy($file, $newfile)) {
echo "failed to copy $file...\n";
}
if you guys do this header("Content-Security-Policy: default-src 'self';"); does PHP/Apache convert the header name to lowercase? I know it doesn't matter, but I'm seeing that happening for me, so just curious if it's just me.
@AshKetchum Apple is all about eye candy products, and nothing about practicality or useful products. Reason why Android is light years ahead in features and abilities, and Apple computers with their bloated prices do not come even close to the specs of a PC prices half as much. You can polish a turd, but in the end it's still a turd and Apple is really good at making turds look like the next cool thing.
@crypticツ The reason I say that there is something wrong with that is because that's the only place where he is printing out the contents of the array.
Even if it isn't the part that's wrong, it should be a good place to start.
Well, then something must be wrong with the way you are pulling it or it might be the database itself. Have you checked if everything is exactly the same as what you have on your local server? Like every single thing?
Delete the file completelty off server, access it to make sure it 404s and is not present, make sure your local copy does not contain the var_dump. Then upload it, then try.
I use JS/AJAX with dataType: 'json' to post to a PHP script which echos json_encoded array of data and the JS keeps going to .fail even though I'm getting 200 and a responseText with data as expected. From what I have researched this is because of the Content-Type the PHP script has in it's header, but even with setting the content type in the php script and everything else I've seen in researching this it's still not working... what am I missing?
Like your database scheme. You apparently have a column named 1 in the user table.
You check for the existance of $_SESSION['userName']7 times using isset() you only need to do it once at top like so $userName = (isset($_SESSION['userName'])); and then do if ($userName) { everywhere else.
if( !( $_SESSION['userName'] && getRows($sql) ) ) you really should not be running a database query inside an if() statement. Put it inside the code block.
You shouldn't be using http://localhost/ in your URLs either use a relative URL or set the domain dynamically. Don't hardcode such things. Make migration to a live server or another server a pain.
Your file structure for your assets makes no sense. Why is a JS file in a folder called styles? Not very semantic when style is typically associated with CSS. If it for different themes, then you should rename it to that. Usually they just call it 'assets' as it's where images, JS, and CSS etc reside.
I just got to an interesting bit of my cms... I'm loading my plugins via ajax, so...I'm now in my php file with something like:
{
"plugin" : "nameHere",
"options" : {
"sampleOption" : "sample value"
}
}
Now I need to load the specified plugin with those options....but I can't figure out what that actually will look like.
anyone got ideas?
lol I could pass options to php from js all day....other way around is confusing me
@m59 That is a JSON strong, so you would do this: $options = json_decode($jsonString); You then can see the the options structure with print_r($options); and then load your plugin based on say if ($options['option']->sampleOption == 'some value')
@DaveChen Well, on a page, there is a textbox in which the user enters his hobbies as tags (achieved using bootstrap tags) and then those tags get input into a specific column ("Hobbies") for each user with a comma in between all of them.
The "hobbies" are stored in an array. Since I using foreach to go through the array and select each individual hobby to put into the database, should I put both the prepare and the execute PDO statements in the loop or just the execute statement?