Web Development Questions That Don't Need Their Own Thread v2
3,079 replies, posted
KompoZer is quite out of date, BlueGriffon is based on the current Mozilla sources, and is done by one of the CSS managers
Shows just how incompetant i've become in PHP that I can't get this work.
[code]<?php
$url_f=$_POST['text'];
$thumb=$_POST['type'];
$urls=explode('\n',$url_f);
echo "<textarea rows='20' cols='40' readonly='1'>";
if($thumb=="img"){
$a=0;
while($a!=count($urls)){
echo "[img]".$urls[$a]."[/img]\n";
$a++;
}
}
echo "</textarea>";
?>[/code]
Instead of putting [img][/img ] before/after each input, it puts it infront of the first and after the last only.
snip--
[code]
function searchClicked()
{
var tagField = document.getElementById('tags');
var tags = tagField.value;
document.getElementById("videoResultsDiv").innerHTML =
'Loading YouTube videos ...';
var script = document.createElement('script');
script.setAttribute('id', 'jsonScript');
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', 'http://gdata.youtube.com/feeds/' +
'videos?vq='+tags+'&max-results=8&' +
'alt=json-in-script&callback=showMyVideos&' +
'orderby=relevance&sortorder=descending&format=5&fmt=18');
document.documentElement.firstChild.appendChild(script);
}
[/code]
this works if i remove +tags+ from
[code] videos?vq='+tags+'&max-results=8&' +[/code]
and enter something else. what's the problem?
Whoever rated me Programming King is a dick.
Try actually helping me. I know the code is extremely simple, but I can't get it to work after about 3 hours trying, even using foreach instead of a while loop. Same result.
[QUOTE=SataniX;32954359]Shows just how incompetant i've become in PHP that I can't get this work.
[code]-- snip --[/code]
Instead of putting [img][/img ] before/after each input, it puts it infront of the first and after the last only.[/QUOTE]
[php]
<?php
$url_f = isset($_POST['text']) ? $_POST['text'] : false;
$thumb = isset($_POST['type']) ? $_POST['type'] : false;
$urls = ($url_f) ? explode('\n',$url_f) : '';
?>
<textarea rows='20' cols='40' readonly='1'>
<?php
switch ($thumb){
case 'img':
for ($i = count($urls)-1; i >= 0; i--)
{
echo '[img]'. $urls[$a] ."[/img]\n";
}
break;
default:
break;
}
?>
</textarea>
[/php]
[editline]25th October 2011[/editline]
I think switch's look neat.
2000+ posts, not gonna be able to read it all.
Let's just throw it out there, starting from nothing, where should I go? I have programming experience in C++ and Python, but have never worked with web development before, don't even know HTML really.
[QUOTE=StealthArcher;32959169]2000+ posts, not gonna be able to read it all.
Let's just throw it out there, starting from nothing, where should I go? I have programming experience in C++ and Python, but have never worked with web development before, don't even know HTML really.[/QUOTE]
Then start with html?
[QUOTE=mobrockers2;32959219]Then start with html?[/QUOTE]
Some names bro, everytime I think I've found a nice tutorial site, within minutes I come across people on SA or FP saying it's bad and wrong and etc
Here's your bone: [url]http://htmldog.com/guides/[/url]
[QUOTE=jaybuz;32958862][php]
<?php
$url_f = isset($_POST['text']) ? $_POST['text'] : false;
$thumb = isset($_POST['type']) ? $_POST['type'] : false;
$urls = ($url_f) ? explode('\n',$url_f) : '';
?>
<textarea rows='20' cols='40' readonly='1'>
<?php
switch ($thumb){
case 'img':
for ($i = count($urls)-1; i >= 0; i--)
{
echo '[img]'. $urls[$a] ."[/img]\n";
}
break;
default:
break;
}
?>
</textarea>
[/php]
[editline]25th October 2011[/editline]
I think switch's look neat.[/QUOTE]
I expanded it to deal with the second case, thumb, but I get an error on line 15 - the first for loop.
Here's the code now, but I don't think my addition changed it.
[php]<?php
$url_f = isset($_POST['text']) ? $_POST['text'] : false;
$thumb = isset($_POST['type']) ? $_POST['type'] : false;
$urls = ($url_f) ? explode('\n',$url_f) : '';
?>
<textarea rows='20' cols='40' readonly='1'>
<?php
switch ($thumb){
case 'img':
for ($i = count($urls)-1; i >= 0; i--)
{
echo '[img]'. $urls[$a] ."[/img]\n";
}
break;
default:
break;
case 'thumb':
for ($i = count($urls)-1; i >= 0; i--)
{
echo '[thumb]'. $urls[$a] ."[/thumb]\n";
}
break;
}
?>
</textarea>[/php]
[editline]25th October 2011[/editline]
yup, it's the same with your code only - a T_DEC error, line 15.
[QUOTE=SataniX;32959652]I expanded it to deal with the second case, thumb, but I get an error on line 15 - the first for loop.
Here's the code now, but I don't think my addition changed it.
[editline]25th October 2011[/editline]
yup, it's the same with your code only - a T_DEC error, line 15.[/QUOTE]
[php=15,25]<?php
$url_f = isset($_POST['text']) ? $_POST['text'] : false;
$thumb = isset($_POST['type']) ? $_POST['type'] : false;
$urls = ($url_f) ? explode('\n',$url_f) : '';
?>
<textarea rows='20' cols='40' readonly='1'>
<?php
switch ($thumb){
case 'img':
for ($i = count($urls)-1; $i >= 0; $i--)
{
echo '[img]'. $urls[$a] ."[/img]\n";
}
break;
default:
break;
case 'thumb':
for ($i = count($urls)-1; $i >= 0; $i--)
{
echo '[thumb]'. $urls[$a] ."[/thumb]\n";
}
break;
}
?>
</textarea>[/php]
[QUOTE=Ac!dL3ak;32960093][php=15,25]<?php
$url_f = isset($_POST['text']) ? $_POST['text'] : false;
$thumb = isset($_POST['type']) ? $_POST['type'] : false;
$urls = ($url_f) ? explode('\n',$url_f) : '';
?>
<textarea rows='20' cols='40' readonly='1'>
<?php
switch ($thumb){
case 'img':
for ($i = count($urls)-1; $i >= 0; $i--)
{
echo '[img]'. $urls[$a] ."[/img]\n";
}
break;
default:
break;
case 'thumb':
for ($i = count($urls)-1; $i >= 0; $i--)
{
echo '[thumb]'. $urls[$a] ."[/thumb]\n";
}
break;
}
?>
</textarea>[/php][/QUOTE]
Can't see it for trying, that's fixed that issue.
Just outputs [thumb][/thumb ] or [img] [/img ] depending on what's selected.
[QUOTE=SataniX;32960188]Can't see it for trying, that's fixed that issue.
Just outputs [thumb][/thumb ] or [img] [/img ] depending on what's selected.[/QUOTE]
[php=17,27]
<?php
$url_f = isset($_POST['text']) ? $_POST['text'] : false;
$thumb = isset($_POST['type']) ? $_POST['type'] : false;
$urls = ($url_f) ? explode('\n',$url_f) : '';
?>
<textarea rows='20' cols='40' readonly='1'>
<?php
switch ($thumb){
case 'img':
for ($i = count($urls)-1; $i >= 0; $i--)
{
echo '[img]'. $urls[$i] ."[/img]\n";
}
break;
default:
break;
case 'thumb':
for ($i = count($urls)-1; $i >= 0; $i--)
{
echo '[thumb]'. $urls[$i] ."[/thumb]\n";
}
break;
}
?>
</textarea>
[/php]
[editline]25th October 2011[/editline]
anyone know the css selector to style the required input indicator?
[QUOTE=Ac!dL3ak;32960343][php=3,4]
<?php
$url_f = (isset($_POST['text'])) ? $_POST['text'] : false;
$thumb = (isset($_POST['type'])) ? $_POST['type'] : false;
$urls = ($url_f) ? explode('\n',$url_f) : '';
?>
<textarea rows='20' cols='40' readonly='1'>
<?php
switch ($thumb){
case 'img':
for ($i = count($urls)-1; $i >= 0; $i--)
{
echo '[img]'. $urls[$i] ."[/img]\n";
}
break;
default:
break;
case 'thumb':
for ($i = count($urls)-1; $i >= 0; $i--)
{
echo '[thumb]'. $urls[$i] ."[/thumb]\n";
}
break;
}
?>
</textarea>
[/php]
[editline]25th October 2011[/editline]
anyone know the css selector to style the required input indicator?[/QUOTE]
Don't know if it solves the problem, but you always have parentheses around your test condition when using the ternary operator.
Anyone know of act decent CSS3 shape generators?
Trying to create something similar to this;
[IMG]http://i.imgur.com/vDu63.png[/IMG]
Whoops, I've just noticed how dodgy that shadow looks.
[B]Never-mind! I done by hand.[/B]
[QUOTE=Ac!dL3ak;32960343][php=17,27]
<?php
$url_f = isset($_POST['text']) ? $_POST['text'] : false;
$thumb = isset($_POST['type']) ? $_POST['type'] : false;
$urls = ($url_f) ? explode('\n',$url_f) : '';
?>
<textarea rows='20' cols='40' readonly='1'>
<?php
switch ($thumb){
case 'img':
for ($i = count($urls)-1; $i >= 0; $i--)
{
echo '[img]'. $urls[$i] ."[/img]\n";
}
break;
default:
break;
case 'thumb':
for ($i = count($urls)-1; $i >= 0; $i--)
{
echo '[thumb]'. $urls[$i] ."[/thumb]\n";
}
break;
}
?>
</textarea>
[/php]
[editline]25th October 2011[/editline]
anyone know the css selector to style the required input indicator?[/QUOTE]
Now it's back to my original problem, outputs
[code]
[ thumb]test
test2
test3[/thumb ]
[/code]
[QUOTE=SataniX;32960594]Now it's back to my original problem, outputs
[code]
[ thumb]test
test2
test3[/thumb ]
[/code][/QUOTE]
it could be using \r newlines (or even \r\n)
i don't know dude
Put parentheses around the test condition in your ternary operators.
[php]$url_f = (isset($_POST['text'])) ? $_POST['text'] : false;
$thumb = (isset($_POST['type'])) ? $_POST['type'] : false;[/php]
[QUOTE=Octave;32960859]Put parentheses around the test condition in your ternary operators.
[php]$url_f = (isset($_POST['text'])) ? $_POST['text'] : false;
$thumb = (isset($_POST['type'])) ? $_POST['type'] : false;[/php][/QUOTE]
Made no difference at all, since that's not the problem.
The problem lies in the array or for loop, I believe.
[QUOTE=SataniX;32961355]Made no difference at all, since that's not the problem.
The problem lies in the array or for loop, I believe.[/QUOTE]Well, it's still good practice.
[QUOTE=SataniX;32960594]Now it's back to my original problem, outputs
[code]
[ thumb]test
test2
test3[/thumb ]
[/code][/QUOTE]
You need to use double quotes when working with special characters, so:
[php=5]
<?php
$url_f = isset($_POST['text']) ? $_POST['text'] : false;
$thumb = isset($_POST['type']) ? $_POST['type'] : false;
$urls = ($url_f) ? explode("\n",$url_f) : '';
[/php]
[QUOTE=jaybuz;32961494]You need to use double quotes when working with special characters, so:
[php=5]
<?php
$url_f = isset($_POST['text']) ? $_POST['text'] : false;
$thumb = isset($_POST['type']) ? $_POST['type'] : false;
$urls = ($url_f) ? explode("\n",$url_f) : '';
[/php][/QUOTE]
Aah, that somewhat works.
It still behaves slightly wierdly with newlines, but that's fixed it.
Thanks!
Why are you using for loops instead of foreach?
[editline]26th October 2011[/editline]
[php]<?php
$url_f = $_POST['text'];
$thumb = $_POST['type'];
$urls = explode("\n", $url_f);
?>
<textarea rows='20' cols='40' readonly='1'>
<?php
switch ($thumb){
case 'img':
foreach ($urls as $a)
{
echo '[img]'. $urls[$a] ."[/img]\n";
}
break;
default:
break;
case 'thumb':
foreach($urls as $a)
{
echo '[thumb]'. $urls[$a] ."[/thumb]\n";
}
break;
}
?>
</textarea>[/php]
I've gotten used to javascript. :v:
There is no foreach.
[editline]25th October 2011[/editline]
[php]<?php
$url_f = $_POST['text'];
$thumb = $_POST['type'];
$urls = explode("\n", $url_f);
?>
<textarea rows='20' cols='40' readonly='1'>
<?php
switch ($thumb){
case 'img':
foreach ($urls as $url)
{
echo '[img]'. $url ."[/img]\n";
}
break;
default:
break;
case 'thumb':
foreach($urls as $url)
{
echo '[thumb]'. $url ."[/thumb]\n";
}
break;
}
?>
</textarea>[/php]
could someone help me out with some directions
i'm trying to make this:
[img]http://dl.dropbox.com/u/6573388/4.5.png[/img]
actually work, but i'm not proficient in making an upload script at all (how would i even turn it into a .txt file)
and are there any good listing scripts out there i can use?
some basic directions to tutorials or whatever are fine unless you've got nothing else to do
[QUOTE=Elexar;32963613]could someone help me out with some directions
i'm trying to make this:
[img]http://dl.dropbox.com/u/6573388/4.5.png[/img]
actually work, but i'm not proficient in making an upload script at all (how would i even turn it into a .txt file)
and are there any good listing scripts out there i can use?
some basic directions to tutorials or whatever are fine unless you've got nothing else to do[/QUOTE]Well to turn it into a text file you just open a file in create-if-not-exist mode (w or w+ I think) and write it to the file.
[QUOTE=Octave;32963666]Well to turn it into a text file you just open a file in create-if-not-exist mode (w or w+ I think) and write it to the file.[/QUOTE]
file_put_contents?
[QUOTE=Ac!dL3ak;32963740]file_put_contents?[/QUOTE]Yes, that works as a shortcut.
I'm storing a date in a database which I'll want to output in the format of "Oct. 25, 2011". Which would be the best way to do it?
1. Use MySQL's CURDATE() and convert it to the above string via PHP before parsing.
2. Store the above string in the database and parse it directly.
[QUOTE=jetboy;32966708]I'm storing a date in a database which I'll want to output in the format of "Oct. 25, 2011". Which would be the best way to do it?
1. Use MySQL's CURDATE() and convert it to the above string via PHP before parsing.
2. Store the above string in the database and parse it directly.[/QUOTE]
Store the date in MySQL, make it human-readable with PHP. There's rarely a good reason to store concisely-formatted data, as at that point you're discarding flexibility.
Sorry, you need to Log In to post a reply to this thread.