Daniel0
Staff Alumni-
Posts
11,885 -
Joined
-
Last visited
Everything posted by Daniel0
-
That's called a ternary statement. So if you have something of the form cond ? ifTrue : ifFalse then ifTrue will be returned if cond evalutes to true, and ifFalse will be returned otherwise. You could rewrite it to the following: if ($row[4]) { return sprintf($html, $row[3], htmlentities( $row[1] ) ); } else { return sprintf($html_disabled, htmlentities( $row[5] ), htmlentities( $row[1] ) ); }
-
[SOLVED] Need help explaining the . in a query?
Daniel0 replied to runnerjp's topic in PHP Coding Help
It's just a way of expressing the full name, so friends.friendname is referring to the field called friendname in the table called friends. -
2003 - Can't connect to MySQL server on 'localhost' (10061)
Daniel0 replied to mraza's topic in MySQL Help
So did you check the error log like it suggested? -
Notice: Undefined index: HTTPS in H:\...\slideshow.php on line 17
Daniel0 replied to killermark91's topic in PHP Coding Help
Oh sorry, I didn't notice there was two questions. I'm not sure which link you're talking about though. -
Notice: Undefined index: HTTPS in H:\...\slideshow.php on line 17
Daniel0 replied to killermark91's topic in PHP Coding Help
You're welcome. I've marked your topic as solved. There is a little button on the bottom left corner (almost right above Quick Reply) you can use yourself as well. -
2003 - Can't connect to MySQL server on 'localhost' (10061)
Daniel0 replied to mraza's topic in MySQL Help
Right, so now MySQL is listening to the correct port at least. I'm not sure why phpmyadmin would show a blank page. Probably some sort of error occurred (that's a typical reason why you would get an unexpected blank page). Try making sure that error_reporting is set to E_ALL in php.ini and that display_errors is set to on. Remember to restart Apache after doing that. When you've done that, try to see if there is any error printed to the screen in phpmyadmin. -
Notice: Undefined index: HTTPS in H:\...\slideshow.php on line 17
Daniel0 replied to killermark91's topic in PHP Coding Help
$_SERVER['HTTPS'] is only set if you're running on HTTPS, so you could do $protocol = isset($_SERVER['HTTPS']) ? 'https' : 'http'; instead. -
I would put the values in an array (if they exist) and then use join to combine them into a string. I.e. something like this: $values = array(); foreach (array('production_year', 'character_role', /* etc */) as $field) { if (!empty($credit[$field])) { $values[] = $credit[$field]; } } $foo = join(', ', $values);
-
2003 - Can't connect to MySQL server on 'localhost' (10061)
Daniel0 replied to mraza's topic in MySQL Help
Well, it's not listening to the correct port then. Try running netstat -bn to figure out what port it is listening to. If mysqld.exe doesn't even show up when you do that, then something is very wrong. -
Hmm... I'm not actually sure that [imath]\frac{dV}{dt}=10t[/imath]. The assignment says "sand is falling off of a conveyor and onto a conical pile at a rate of 10 cubic feet per minute". I take this to mean "each minute, 10 ft3 are added to the file, so this means that [imath]V_1(t)=10t[/imath]. We'll say that [imath]V_2(h) = \frac{3\pi}{4} \cdot h^3[/imath], so we know that when the file is 15 ft high, then the volume must be [imath]V_2(15) = \frac{10125\cdot\pi}{4} \approx 7952.16[/imath]. Thus [math]V_1(t) = \frac{10125\cdot\pi}{4} \Rightarrow t = \frac{2025\cdot\pi}{8} \approx 795.216[/math] This means that the pile must be 15 ft high after [imath]t = \frac{2025\cdot\pi}{8}[/imath] minutes. If we have [imath]h=\sqrt[3]{\frac{4V}{3\pi}}[/imath] then we can just plug in our [imath]V_1[/imath] function to express the height by the time. [math]h(t) = \sqrt[3]{\frac{4\cdot V_1(t)}{3\pi}} = \sqrt[3]{\frac{4 \cdot 10t}{3\pi}} = \sqrt[3]{\frac{40t}{3\pi}}[/math] If we differentiate that we get: [math]h'(t) = \frac{2\cdot 5^{\frac{1}{3}} \cdot 3^{\frac{2}{3}}}{9\cdot \pi^{\frac{1}{3}} \cdot t^{\frac{2}{3}}}[/math] So now we just plug in the time at which the height is 15: [math]h'\left( \frac{2025\cdot\pi}{8} \right) = \frac{8}{405\cdot\pi} \approx 0.006288[/math] Hmm... is that right? I suppose you can go over it and check if I made any errors. It's your homework after all
-
I don't think I've ever seen a URL that's a kilobyte long though, so you can safely decrease the size to something more realistic.
-
The statement count($num) evaluates to true if and only if count($num) > 0 evaluates to true, so the two statements are equivalent. In a boolean context, the statements isset($var) and $var are not equivalent. Specifically, if you set $var = false; then the first will evaluate to true, but the second one to false. The same thing will happen if you set $var = 0;. If the variable $var is not even set, then the first one will evaluate to false and so will the second one, but the second one will raise an error of level E_NOTICE.
-
Use a numeric primary key, or make it shorter than 767 bytes.
-
I was talking about this part: You don't need to do that. It's just redundant.
-
Not if it's a numeric value.
-
preg_match('#\(([^)]+)\)#', $string, $matches); Should do it. See the contents of $matches.
-
Are you sure your query runs? If it fails, mysql_query() will return false, which is not a valid MySQL resource.
-
Hmm... oh well. I supposed I should have read the fucking manual.
-
Really? So you explicitly convert between all types always? $var1 = 1; $var2 = 1.6; echo (string) ((float) $var1 + $var2); Or do you just rely on PHP's automatic type inference and conversion? echo $var1 + $var2;
-
2003 - Can't connect to MySQL server on 'localhost' (10061)
Daniel0 replied to mraza's topic in MySQL Help
Are you sure the MySQL server is running and listening to the correct port? Try running netstat -an | find "3306" | find "LISTENING" from the command line and see what it returns. -
VARCHAR fields also cannot be longer than 255.
-
0 evaluates to false in a boolean context, any other integer evaluate to true. PHP is weakly typed language.
-
PHP already knows how to parse XML: <?php $xml = new SimpleXMLElement('http://gdata.youtube.com/feeds/videos?vq=Gitano%20corazon&start-index=1&max-results=10', null, true); $xml->registerXPathNamespace('m', 'http://search.yahoo.com/mrss/'); foreach ($xml->xpath('//m:player') as $player) { parse_str(parse_url($player['url'], PHP_URL_QUERY), $query); $thumbnail = 'http://i.ytimg.com/vi/' . $query['v'] . '/2.jpg'; echo '<img src="' . $thumbnail . '">'; }
-
You can't do it like that. I would just generate the text for the first parameter, assign it to a variable and then pass it to the function. $text = "Download: <b>$kwd</b>"; if (count($info['results'])) { $text .= '<div align="center" class="info"><b>'.$info['total_results_count'].'</b> results found, page '.$info['curpage'].' from '.$info['total_pages'].'</div>'; } $text .= '<br />'; createBar($text, '100%');
-
Uh... Like this? $RowCnt += 20000;