Hello all,
Is anyone aware of a font reader class where I can pass in a font file (ttf or otf) and I can find out the font name, the model, artist etc. The meta data really.
Thanks all for any help
I have the table :
id id_products id_atribut name value
1 13 8 autdio 2.1
2 13 9 hdd 200 Gb
3 13 10 cd-rom 2
4 20 8 audio 2.1
the problem is, how can i select from this table where id_products=13 and name="audio" and value="2.1" and name="hdd" and value="200 gb" ....
How can i do this?
$this->totplpremium is 2400
$this->minpremiumq is 800
So why would this ever return true?!
if ($this->totplpremium < $this->minpremiumq){
The figures are definitely correct and I am definitely using the 'less than' symbol. I can't work it out.
Hey All.
Trying to create a 1-liner to loop through a mysql result set.
Example:
$sql = "SELECT uid, role FROM usr WHERE uid = '$this-uid'";
$r = db::q($sql);
if($r-rows()) {
$q = mysql_fetch_assoc($r-result);
while(list($k, $v) = each($q)) { // would like to omit line above and consolidate here
$_SESSION['usr'][$k] = $this->$k = $v;
}
}
problem is that consolidating while loop like so:
while(list($k, $v) = each(mysql_fetch_assoc($r-result))
returns an error a la each() not getting object or array, even though of course it is. I think the problem is a casting issue, but it does not seem you can do:
each( (array) mysql_fetch_assoc($r-result))
Any ideas? I like to code as tersely as possible, and having "$q = mysql_fetch_assoc($r-result)" everywhere will annoy me, does already.
Keep posted...
Thanks!
I wrote a shell method in CakePHP 1.3 that has a return value.
I'd like to be able to access that method from within a controller, so that I can pass its return value into the View.
I'm not sure how to access those methods appropriately from within the controller. Have I done it wrong?
I could easily duplicate the code, but I'd like to "keep it DRY", and the actual functionality, I believe, doesn't belong with this particular controller - I just need it's return value in this particular view.
Hi everyone,
When trying memcache:get, I'll get the following error message back:
Message: Memcache::get() [memcache.get]: Server localhost (tcp 11211) failed with: Failed reading line from stream (0)
I run a Windows 32bit test environment (XP) and here's how my code looks:
function getMulti(array $keys) {
$items = $this->memcache->get($keys);
return $items;
}
My memcache servers are two local computers in the LAN that my dev. environment is connected to.
Sure, I can turn the error logging off or just put an @ before the get function call, but that doesnt solve this issue. What can I do?
Thanks a lot!
Hi frns,
Am using the strip_tags() to remove the HTML tags from one content . but i wants to remove the html (<DIV></DIV>,<P></P>,<SPAN></SPAN>) tags apart from the <img> tag and <a> , i don't want to remove the <img ><a> tag from that . but need to remove other all html tags from that content how can i do help me.
thanks
I want my users to be logged out automatically after X minutes of inactivity. I also want to have all sessions destroyed.
How can this be done? How can I check for inactivity then perform a function to log them out???
I'm trying to replicate the browser post parameters on http://www.ebayclassifieds.com/m/PostAd?scrid=3465450-2253858851033189948 but for some reasons I can't find where the values for 2 of them are comming from . The parameters are
btn-previwe-ad.x and
btn-previwe-ad.y
but I can't find such as parameters in the html source itself or any hidden value.
Hello,
I have a requirement in which, i need to upload an excel file into MSSQL database. It is working well till this point.
But sometimes i am getting excel file in such a way, that the first 2 rows and columns are empty rows. That is not even fixed everytime. so the format of the table after upload is not as expected. It is assigning F1, F2 as column names for the table in mssql.
It varies from file to file. I want to program it in such away so that the user can enter the row number and the column number from where the actual data is starting. So that while upload it should from line 3 and column 2.
I dont know how to specify that row and column while uploading.
Please help me to solve the same.
Hey all, just wondering how I can add 30 seconds on to this?
$time = date("m/d/Y h:i:s a", time());
Thankyou, again.
I wasn't sure how to do it because it is showing lots of different units of time, when I only want to add 30 seconds.
Hi,
I built a class that allows me to do:
$db->query($query);
and it works perfectly, although if I want to do:
$db->query($query);
while($row = $db->fetch_assoc()){
$db->query($anotherquery);
echo $db->result();
}
it "breaks" the class. I don't want to constantly have to redeclare my class (eg: $seconddb = new database()), is there a way to get around this? I want to be able to reuse $db within $db, without overwriting the "outside" db. currently I'm create an array of data (from db-fetch_assoc() then doing a foreach and then doing the db call inside that:
$db->query('SELECT * FROM table');
while($row = $db->fetch_assoc()){
$arr[] = $row;
}
foreach($arr as $a){
$db->query(); // query and processing here
}
Is this the best method or am I missing the obvious? Should I consider passing a connection link ID with the database connection?
I see extra characters like â showing because of encoding issues as I found out here -
HTML encoding issues - "Â" character showing up instead of " "
I understand that if I set the browser meta encoding to UTF-8, these will not affect anything but I need to strip these extra characters from the database for other purposes.
For eg. :
Text: ↑ should be become Text: ?
But if I run it through utf8_decode it gives me Text: ???
For every other occurrence of the â character, it converts properly to a blank space. Any help will be appreciated.
I want to do something like this for simplifying logging operations. Any idea what I should put in for ?[1]? and ?[2]??
function log_var($var) {
$line = ?[1]?;
$var_name = ?[2]?;
$line--;
$filepath = 'log-' . date('Y-m-d'). '.txt';
$message = "$line, $var_name = $var\n";
$fp = fopen($filepath, "a");
fwrite($fp, $message);
fclose($fp);
@chmod($filepath, 0666);
return TRUE;
}
This how I'd use the function in code (numbers are assumed to be line numbers in actual code):
23 $a = 'hello';
24 log_var($a);
25 $b = 'bye';
26 log_var($b);
And this is what I want to be written to the log file:
23, a = hello
25, b = bye
I am trying to implement a 'shopping cart' where, if the 'Add to Cart' has been clicked, the respective item is either added to the cart or incremented by one if already present. However, the following code isn't working and giving me a "Cannot use a scalar value as an array" error. Any help would be highly appreciated.
if (isset($_POST['fan']) && ($_POST['fan']=="Add to Cart")) {
if (($_SESSION['cart']['fan']==0) || (!isset($_SESSION['cart']['fan']))) {
$_SESSION['cart']['fan']=1;
} else {
$_SESSION['cart']['fan']++;
}
}
hi ,
i am using jquery stars plugin and asking users to rate . the form works well,but caching has become a big problem. even after refresh of the page .it does not show the latest ratings . only after i clear the cache new ratings gets showed.
Hi,
How can I take a line like this:
Digital Presentation (10:45), (11:30), 12:00, 12:40, 13:20, 14:00, 14:40, 15:20, 16:00, 16:40, 17:20, 18:00, 18:40, 19:20, 20:00, 20:40, 21:20, 22:00, 22:40, 23:10, 23:40.
And match all the 24 hour times so I can convert to a more human readable format using date()?
Also I want to match times in the 24:00-24:59 range too
Thanks!
I always see people in serious projects use :: everywhere, and - only occasionally in local environment.
I only use - myself and never end up in situations when I need a static value outside of a class. Am I a bad person?
As I understand, the only situation when -> won't work is when I try following:
class StaticDemo {
private static $static
}
$staticDemo = new StaticDemo( );
$staticDemo->static; // wrong
$staticDemo::static; // right
But am I missing out on some programming correctness when I don't call simple public methods by :: ?
Or is it just so that I can call a method without creating an instance?
With the following code, my browser is returning 'image not created or saved'. I assure you the location of the image exists. So the line within the if statement is returning false for some reason, and yes GD is installed. Any ideas?
if ($img = @imagecreatefromjpeg("/var/www/images/upload/1/1.jpg")) {
$image_width = imagesx($img);
$image_height = imagesy($img);
$target_width = 150;
$target_height = 150;
if ($image_width > $image_height) {
$percentage = ($target_width / $image_width);
} else {
$percentage = ($target_height / $image_height);
}
$new_image_width = round($image_width * $percentage);
$new_image_height = round($image_height * $percentage);
$imgResized = imagecreatetruecolor($new_image_width, $new_image_height);
imagecopyresampled($imgResized, $img, 0, 0, 0, 0, $new_image_width, $new_image_height, $image_width, $image_height);
imagejpeg($imgResized, $this->path, 100);
imagedestroy($img);
imagedestroy($imgResized);
$this->storeThumbnailLocation();
} else {
die ("image was not created or saved");
}