ManiacDan
Staff Alumni-
Posts
2,604 -
Joined
-
Last visited
-
Days Won
10
Everything posted by ManiacDan
-
Obviously it's not XML, that's problem #1. Since we don't have the actual XML file's location, that's all we can tell you.
-
Define "xml's tag." Show what you're getting and what you're expecting. Did you view the source?
-
Ok, I didn't know that part. Interesting. I generally use ORM models anyway so all of this is done in code so it's explicit. Still interesting though. -Dan
-
Object of class player could not be converted to string
ManiacDan replied to Vel's topic in PHP Coding Help
1) Turn error reporting all the way up in PHP.ini and leave it there. 2) Yes, that code is preferable because you have all your objects in one variable and you can delete/modify that whole array when you need to rather than attempting to use variables that may or may not exist. -Dan -
Wait...I didn't mean trigger cascade I meant the actual ON DELETE CASCADE command which you place on a foreign key for referential integrity. It's still fraught with danger but it's not at all a trigger. If I have a table called ITEMS and another called ATTRIBUTES I can make attributes.item_id be a foreign key to items.id ON DELETE CASCADE. If the item is deleted, the attributes are deleted automatically. -Dan
-
Works just fine for me, copied and pasted and made $cost a random number. -Dan
-
Assuming that your server has allow_url_fopen enabled, which many shared hosts do not. -Dan
-
Object of class player could not be converted to string
ManiacDan replied to Vel's topic in PHP Coding Help
$this-kit Typo right there. Also, if you were working with errors turned on, it would have told you "undefined constant 'kit'" and you could have spotted this right away. Also also, you're doing this wrong. Don't use variable variables. Put them in an array -Dan -
The answer was there for two hours before you posted
-
What are you actually trying to do? Why are you destroying the names of your columns, and why are you selecting 7 empty columns for no reason? Just from glancing at these queries, you should run them separately.
-
Removing a $_SESSION entity if values = X
ManiacDan replied to Freedom-n-Democrazy's topic in PHP Coding Help
You'll have to use a loop to check all these keys one at a time, deleting the item and BREAKing out of the loop when you find a match. -
Put a DISTINCT inside each COUNT() call: COUNT(DISTINCT employees.userid)
-
echo "<td style='background-color: " . ( $val < 0 ? 'red' : 'white' ) . ";'>{$val}</td>";
-
Very true! I never really had problems with it "back in the day" but I always did it on very simple systems like a common attribute-value system or whatever. 17 tables all inter-linking with cascading deletes might be a big problem. Indexing your tables properly is probably the best bet. Try to SELECT all this data. Does it come back in a reasonable amount of time? What about an UPDATE? Maybe it would be best to add a "deleted" column to these tables so you can "soft delete" the records instead of locking the tables to perform an actual delete. -Dan
-
You can't append to a PDF file anyway, so you may want to abandon this whole line. To answer your direct question: I don't believe IIS can go through virtual directories. See if you can view the files using glob() or exec() just as a test. Disclaimer: I haven't worked on an IIS server in 8 years. -Dan
-
You can have multiple MySQL connections open at the same time. See the mysql_connect and mysql_query pages in the manual You use variables inside functions by passing them in. See the "variable scope" chapter in the manual. $conn1 = mysql_connect('server1.yourdomain.com', 'root', 'password'); $conn2 = mysql_connect('server2.yourdomain.com', 'root', 'password'); function checkBannedUsers( $userId, $conn1, $conn2 ) { $rs = mysql_query("SELECT * FROM users WHERE userId = '" . mysql_real_escape_string($userId) . "'", $conn1); $row = mysql_fetch_array($rs); if ( $row['banned'] == 1 ) { mysql_query("UPDATE bannedUsers SET loginAttempts = loginAttempts + 1 WHERE userId = '" . mysql_real_escape_string($userId) . "'", $conn2); } }
-
echo human_time_diff(get_the_time('U'), current_time('timestamp')) That appears to print the human-readable time difference (hence the function name). Go into that function and translate its output properly. -Dan
-
What...what are you talking about?
-
gristoi, he has DATA in MySQL he wants to graph, he doesn't want to graph his MySQL traffic. torontob, you can certainly use RRD, but I have used JPGraph in the past for this exact solution. -Dan
-
You can create ON DELETE CASCADE foreign keys in these tables, so when you delete the user record MySQL handles deleting the records from the 16 other tables. Generally problems like this are solved with proper indexing. -Dan
-
Your line doesn't work because you need to return the value of a function call to something. This is a working version of your function with test code. There's one special case that I could have gotten around with fancy logic but it would have been confusing so it's hard-coded. <?php function set_url_params( $get, $allowed = null ) { $allowed = array( 'l' => 'l', // Redirect key (e.g http://example.com?l=a1dFd7) 'utm_campaign' => 'campaign', 'campaign' => 'campaign', 'utm_source' => 'source', 'source' => 'source', 'utm_medium' => 'medium', 'medium' => 'medium', 'utm_term' => 'term', 'term' => 'term', 'keyword' => 'keyword', 'kw' => 'keyword', ); $url_params = array(); foreach ( $allowed as $key => $destination ) { if ( !isset( $url_params[$destination] ) && isset($get[$key]) ) { $url_params[$destination] = trim(strip_tags(urldecode($get[$key]))); } } //one more check for kw: if ( !isset( $url_params['keyword'] ) && isset($get['term']) ) { $url_params['keyword'] = trim(strip_tags(urldecode($get['term']))); } return $url_params; } //test it: $_GET = array( 'kw' => 'foo', 'l' => 'http://example.com?l=a1dFd7', 'source' => '456xyz', 'utm_campaign' => 'abc123Google', 'campaign' => 'abc123', 'utm_source' => '456xyzGoogle', 'utm_medium' => 'oilOnGoogle', 'medium' => 'oilOnPaper', 'utm_term' => 'phpGoogle', 'term' => 'php', 'keyword' => 'fooBar', ); print_r(set_url_params($_GET)); $_GET = array( 'l' => 'http://example.com?l=a1dFd7', 'utm_campaign' => 'abc123Google', 'utm_medium' => 'oilOnGoogle', 'utm_term' => 'phpGoogle', 'term' => 'php', 'keyword' => 'fooBar', ); print_r(set_url_params($_GET)); $_GET = array( 'l' => 'http://example.com?l=a1dFd7', 'source' => '456xyz', 'utm_campaign' => 'abc123Google', 'campaign' => 'abc123', 'medium' => 'oilOnPaper', 'utm_term' => 'phpGoogle', 'term' => 'php', ); print_r(set_url_params($_GET)); $_GET = array( 'kw' => 'foo', 'l' => 'http://example.com?l=a1dFd7', 'source' => '456xyz', 'campaign' => 'abc123', 'medium' => 'oilOnPaper', 'term' => 'php', 'keyword' => 'fooBar', ); print_r(set_url_params($_GET));
-
strip_tags(urldecode(trim($value))); That line does nothing. global $url_params; Don't use globals, pass arguments in and return the data you want. Use if(isset()) for this. If the UTM is set, use it. Otherwise, use your own. There's less confusing ways to do what you're doing, but this code is valid. -Dan
-
You will have to clarify your question. XML files are already files. What do you have, and what do you want?
-
Remvoing an object from $_SESSION
ManiacDan replied to Freedom-n-Democrazy's topic in PHP Coding Help
1) None of those are proper syntax. use a regular foreach loop and print_r the row inside the loop so you know what you're dealing with. 2) Don't feed the trolls. AK would have left you alone if you had ignored him. He's a troll. If someone honestly has nothing better to do than be a dick on the internet, let them be a dick somewhere else.