![](https://forums.phpfreaks.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
The Little Guy
-
Posts
6,675 -
Joined
-
Last visited
Posts posted by The Little Guy
-
-
I want to upgrade my current HD to a SSD, I have been looking and I am not sure which one I should get.
This is the one that sticks out most to me:
http://www.newegg.com/Product/Product.aspx?Item=N82E16820233220
Any suggestions? Should I get this one or a different one?
-
Back in 2007 / 2008 I wrote a voting script which stores votes. The problem I have is I save the votes badly. I have 2 columns:
- voteTotal (sum of all the votes)
- votes (number of people who voted)
Here are two values of on item:
1394
431
I want to break these up into single Items. I know I cannot go back into time and get the values, but I would like to calculate what could have been used. So for the above example, I would insert 431 rows into a table, each with a value of 1-5 (int's) all rows adding up to 1394.
Any ideas of what I could do for this?
-
there are two ways to do this.
1. MySQL
insert into my_table (...) values (...); set @i1 = (select last_insert_id()); select * from my_table where id = @i1;
2. PHP
mysql_query("insert into my_table (...) values (...)"); $lid = mysql_insert_id(); mysql_query("select * from my_table where id = $lid");
-
maybe you want to use:
-
I noticed that the bottom two links were broken, they work now.
-
Looks cool, but ImageMagick does all those things and much, much more.
Yeah, but not everyone has IM.
Thanks for the comments, Any suggestions?
-
This is how yours should look:
select t1.user_email, t2.img_thumb from table_1 as t1 left join table_2 as t2 on t1.user_id = t2.img_id_fk having t2.img_thumb is not null order by rand() limit 5
Yours does NOT check NULLs after the result set is built, if a member doesn't have a row in table 2 you will get a NULL in your result set when using a left join and no HAVING.
My method will automatically ignore the NULLs, so I don't need to check for a null during a search and after the search.
-
But you need to check if they are null after you join.
-
// Your code above $id = (int)$_GET['id']; $q = "SELECT catID, cat FROM category where catID = $id"; // Your code below
-
You don't have to check for NULL if you do join instead of a left join, the is not null would also be in the having, not the where. Also you want to order by rand and limit it to 5 results.
select t1.*, t2.img_thumb from table1 t1 joint table2 t2 on (t1.user_id = t2.img_id_fk) order by rand() limit 5;
-
I haven't used smarty, but I would assume it would look like this:
$q = "SELECT * FROM categories WHERE category_id NOT IN (1,2,3)"; $res = mysql_query($q); while($row=mysql_fetch_array($res)) { Assign('categories',$row["Column_Name_Here"]); }
-
scootstah, I don't think your code will work, because it doesn't support multiline
This supports multiline:
$source = file_get_contents('test.txt'); $pattern = '/<blockquote class="postcontent restore">(.*)<\/blockquote>/isU'; preg_match_all($pattern, $source, $matches); print_r($matches);
-
Like this:
<?php $var = "Arson" ?> <script type="text/javascript" src="js/swfobject.js"></script> <script type="text/javascript"> swfobject.embedSWF( "open-flash-chart.swf", "my_chart", "550", "400", "9.0.0", "expressInstall.swf", {"data-file":"ofc-chart.php?crime=<?php echo $var; ?>"} ); </script>
-
so, something like this (pre-calculated data)...
select *, count(*) total from filedata where /* Search parameters here */ group by filesize, checksum
-
lets say I own a file, and you own a file, both these files are the exact same file, the only difference is the filename. So lets say we both have The Gimp 2.6 but one is named TG2.6.exe and the other is named the_Gimp-2.6.exe. What would be the best way to count the files that are the same even if they have a different file name? Another example would be:
I have a file called me.jpg and someone else has a file me.jpg but they are two completely different pictures. What would I do to tell that?
-
above the each as:
var newName = $("#file-input-name").val(); // From an input field
-
string is one of the following (loop through them):
Chrysanthemum.jpg
Cindy.jpg
Jaimee.jpg
string2 is:
Family.jpg
here is the actual code I am using if that helps:
$("td.basename").each(function(){ var itmid = $(this).parent().attr("id"); var type = $(this).parent().children(".type").text().toLowerCase(); if($(this).text() >= newName && !added && type != "folder"){ $("#"+itmid).before("<tr class='item' id='item_"+openFile+"'>"+rowData+"</tr>"); added = true; return; } });
-
What is the best way to compare two strings and alphabetize them?
if(string >= string2){ $("#"+currentTestID).before(html); }
But that doesn't seem to always work.
I had these three strings:
- Chrysanthemum.jpg
- Cindy.jpg
- Jaimee.jpg
I was then trying to decide where to place this string:
- Family.jpg
The code above decided it goes best between the two strings That start with "C", when really it should go after "Cindy.jpg".
So, Am I comparing strings wrong for alphabetizing?
-
Is there a way to get the binary data from an image?
So say I past this URL into a text field:
http://www.myfreewallpapers.net/nature/wallpapers/beagle-puppy.jpg
Submit the text filed, how can I grab the binary data of the image?
-
Sorry, I didn't read the full question, you want a CSV, well mysql can do that for you:
$query = 'SELECT * INTO OUTFILE '/tmp/name.csv' FIELDS TERMINATED BY \',\' OPTIONALLY ENCLOSED BY \'"\' ESCAPED BY \'\\\' LINES TERMINATED BY \'\n\' FROM '.$current_table_results.' where id between '.$start_id.' and '.$end_id; $result = mysql_query($query); $zip = new ZipArchive; $res = $zip->open('tables.zip', ZipArchive::CREATE); if ($res === TRUE) { $zip->addFile('/tmp/name.csv', 'name.csv'); $zip->close(); } header("content-type: application/zip"); header("Content-Length: ".filesize("tables.zip").";"); readfile('tables.zip');
-
here is what I would do:
Page to start the table builds:
$email = "something@site.com"; exec("nohup php /location/to/php/file.php $email 2>&1 &"); echo "You will receive an email with a link to the file shortly.";
file.php
exec("mysqldump --skip-lock-tables -h localhost -u username --password=mypassword database table1 table2 table3 > /path/to/download/location/file.sql"); $message = "To download your tables, follow the link below \n\n http://mysite.com/downloads/file.sql"; mail($argv[1], "Table Build Complete" $message);
-
Recently PHP had security issues with people being able to get data that shouldn't have been able to get (I don't remember which version it was). A few weeks after it was released a new version was released to patch the security hole.
Now lets say you have a site that grabs that data from a database, php releases a new version and you decide to upgrade your version of php which has a hole that allows people to grab variables on a page which now has all the data you grabbed from the database is now accessible.
-
Ever heard of a rainbow table?
And how do you know that the username/password isn't a login to a database?
-
Check Example #1:
http://www.php.net/manual/en/function.sqlsrv-errors.php
Do something like that with your errors, and lets see what they are.
Break cell up into rows
in MySQL Help
Posted
How do you decide the high?
Maybe I am wrong but I don't think this can be done with pure MySQL...