premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
Better to use an array for this but yea... for($i=0;$i<5;$i++){ $newvar = "varibl0" . $x; echo $$newvar; //where "x" is $i - is there a way to do this? } Not sure if that will work, I think it will but yea...
-
Maybe, not sure, try increasing that to 112M and see what happens.
-
Do this: if ($max-$old == 0) { die("Error these two equal 0 Max: " . $max . " Old: " . $old . " Equals: " . ($max - $old)); }else { $percent = round((($rankp-$old)/($max-$old))*100, 1); } And see what displays/report back. I bet that $max and $old are not hitting any of the if statements, thus they do not have a value which in return would give the division by zero error. If you can have a default value for $max and $old I would set that in your script before the if's or set it as an else at the end of the if's so this error does not happen if the $currank is not apart of any of the if's.
-
It should be page.php?id=1&alpha=downloads. Unclear on what your actual question is, but show some actual code if that does not answer your question.
-
header( "Content-Disposition: attachment; filename=mysitename.com." . $file_info['file_name'] . "\r\n" ); That should do the trick...
-
It definitely is not that, it is something with the implode function or how the form is being posted to the script. It is getting skewed cause the value isn't imploding properly to convert it to a string instead of an array.
-
You cannot divide by zero...basic math. What is held in $max and $old...? When they are subtracted it equals 0, thus your error...
-
They both work...mysql_numrows
-
For the paragraphs, you could just cut if off after the 3rd \n given that your DB has the raw data. So this would work: $content = split("\n", $post['content']); $i=0; foreach ($content as $value) { if ($i == 2) { $content_show .= $value; }else { $content_hide .= $value; } $i++; } Should do it. If you want to do the substr method I found this on the php.net site under substr <?php /* An advanced substr but without breaking words in the middle. Comes in 3 flavours, one gets up to length chars as a maximum, the other with length chars as a minimum up to the next word, and the other considers removing final dots, commas and etcteteras for the sake of beauty (hahaha). This functions were posted by me some years ago, in the middle of the ages I had to use them in some corporations incorporated, with the luck to find them in some php not up to date mirrors. These mirrors are rarely being more not up to date till the end of the world... Well, may be am I the only person that finds usef not t bre word in th middl? Than! (ks) This is the calling syntax: snippet(phrase,[max length],[phrase tail]) snippetgreedy(phrase,[max length before next space],[phrase tail]) */ function snippet($text,$length=64,$tail="...") { $text = trim($text); $txtl = strlen($text); if($txtl > $length) { for($i=1;$text[$length-$i]!=" ";$i++) { if($i == $length) { return substr($text,0,$length) . $tail; } } $text = substr($text,0,$length-$i+1) . $tail; } return $text; } // It behaves greedy, gets length characters ore goes for more function snippetgreedy($text,$length=64,$tail="...") { $text = trim($text); if(strlen($text) > $length) { for($i=0;$text[$length+$i]!=" ";$i++) { if(!$text[$length+$i]) { return $text; } } $text = substr($text,0,$length+$i) . $tail; } return $text; } // The same as the snippet but removing latest low punctuation chars, // if they exist (dots and commas). It performs a later suffixal trim of spaces function snippetwop($text,$length=64,$tail="...") { $text = trim($text); $txtl = strlen($text); if($txtl > $length) { for($i=1;$text[$length-$i]!=" ";$i++) { if($i == $length) { return substr($text,0,$length) . $tail; } } for(;$text[$length-$i]=="," || $text[$length-$i]=="." || $text[$length-$i]==" ";$i++) {;} $text = substr($text,0,$length-$i+1) . $tail; } return $text; } /* echo(snippet("this is not too long to run on the column on the left, perhaps, or perhaps yes, no idea") . "<br>"); echo(snippetwop("this is not too long to run on the column on the left, perhaps, or perhaps yes, no idea") . "<br>"); echo(snippetgreedy("this is not too long to run on the column on the left, perhaps, or perhaps yes, no idea")); */ ?>
-
I am not sure why you are only pulling 2 images when you have 5 ids, but the array seems fine. implode should work on it. Why it is not I have no clue.... Weird stuff....I could be missing something cause I am tried, but yea. Hopefully someone can see the error and help ya.
-
Are you running mysql_query on the query? Or you checking if it errors out? You should really do mysql_real_escape_string on $_GET['sports'] as if you have a ' in that get statement it will cause an error. And it leaves you open to SQL Injection.
-
Try using this...the array_pop will get rid of the extra data that does not get parsed. <?php $var = '<td><img src="../images/med_1.gif" height=24 width=31></td> <td><img src="../images/med_2.gif" height=24 width=31></td> <td><img src="../images/med_3.gif" height=24 width=31></td> <td><img src="../images/med_4.gif" height=24 width=31></td> <td><img src="../images/med_1.gif" height=24 width=31></td> <td><img src="../images/med_1.gif" height=24 width=31></td> '; $vars = split("</td>", $var); array_pop($vars); $row = array(); foreach ($vars as $var) { list($x,$var) = split('src="', $var); list($var) = split('"', $var); $row[] = $var; } print_r($row); ?>
-
Do a print_r on the $deleted_items1 value. Maybe try using implode instead of join (doubt it matters but yea). It should join them together, not sure why it isn't without seeing the actual form...
-
Ah, sorry mis-read. $query = mysql_query("DELETE FROM userimg WHERE id IN ($deleted_items1)"); Use the IN() operator.
-
I am sure you can do with regex, but yea this should work too. <?php $var = '<td><img src="../images/med_1.gif" height=24 width=31></td> <td><img src="../images/med_2.gif" height=24 width=31></td> <td><img src="../images/med_3.gif" height=24 width=31></td> <td><img src="../images/med_4.gif" height=24 width=31></td> <td><img src="../images/med_1.gif" height=24 width=31></td> <td><img src="../images/med_1.gif" height=24 width=31></td> '; $vars = split("</td>", $var); foreach ($vars as $var) { list(,$var) = split('src="', $var); list($var) = split('"', $var); $row[] = $var; } print_r($row); ?> Should work, unless I got the split function parameters mixed up. But yea.
-
To unlink and item, I think you will have to loop through each individual record. I do not tink you can just seperate each file by a comma and have it work. $deleted_items = $_POST["deleted_items"]; foreach ($deleted_items as $filename) unlink($filename); Unsure if that will work since I cannot see the form, but yea.
-
public function query($query) { if(!$this->db) { $this->connect(); } //now process the queries $result = mysql_query($query, $this->db); if(is_resource($result)) { return $result; } //now process the statement else { $stmt = new Mysql_statement($this->db, $query); $stmt->result = $result; return $stmt; } } return $result instead of return TRUE
-
Well I would not addslashes then, there is no need to. If you do it will look like this: Hello I can\'t decide... Etc. So remove that part, and if it is not an html email, the nl2br will not do much good. I think the basic text will display like it should with the line breaks. If it is html, then yea use the nl2br.
-
No, but I would suggest against using addslashes as it is in the process of being depreciated. If you are filtering this for db entry use mysql_real_escape_string instead and no it does not matter which order you use. And I would suggest storing the data in it's raw format and use nl2br before you display the data to the user.
-
I recall a similar problem and it was naming it x.php try changing it to a1.php or something like that and see if it works.
-
You can try this, add it to the top of the script: ini_set('memory_limit', '50M'); See if you are allowed to do that, if not you can try it in a .htaccess file: php_value memory_limit 16M Or if possible you can modify the php.ini and change: memory_limit = 16M ; Maximum amount of memory a script may consume (16MB) to memory_limit = 50M ; Maximum amount of memory a script may consume (16MB) And see what that does for you. I would change it back however, if you do not do this on a regular basis.
-
curl or file_get_contents Your server has to allow_fopen_url and or have cUrl installed.
-
magic_quotes_gpc = Off magic_quotes_runtime = Off When you look at the data in the database, does it have an extra slash in it before the \n ? If it does, magic_quotes was turned on at one point and doubled up the quotes, which is why you are having this issue. Have you tried entering in a new post and see if that doubles it up or if it displays right?
-
Unless I call in sick, I should be.
-
Check if get_magic_quotes_gpc is on. If it is then I would create a new function like so: <?php function myEscape($string) { return (get_magic_quotes_gpc())?mysql_real_escape_string(stripslashes($string)):mysql_real_escape_string($string); } ?> And use that instead, this way if your script ever goes onto another server you do not have to worry if magic_quotes is on or off. Then you would change the following: mysql_real_escape_string(trim($value)) To $value = myEscape(trim($value));