First, the premises: PHP loaded on IIS6 on Win2003 STD R2 SP2, PHP_5213 using FastCGI, MySQL_5145.
Customer sent me the site files, which I unzipped to C:\InetPub\wwwroot\<site root>, then I created a new site in IIS, pointed to <site root>, added test.php to the site files for testing and it works, but visiting index.php produces a blank page with no errors. The readme.txt file present makes reference to application.php and explains root folder var and sets it to a non-existent file.
I don't know PHP syntax, but I tried several logical changes with zero results. At this point I'm not even sure if that is the problem anymore. With PHP, MySQL & site debugging have put in over 20 hours. Still confused, I have resorted to heavy drug use and purchased a small firearm, loaded with a single round (even this seemed to take an inordinate amount of time). I've given up all hope.
Someone please help save a new server and/or old administrator.
Hi All guys!
this time i have a math question for you!
Assuming we have three numbers one is the Number of Votes the second is the Total Values and the last is the Units Ratings.
units_ratings can be a number from 1 to 10;
if ( total_values / units_ratings != number_of_votes ) {
//do something for let the "number_of_votes" fit the division!
}
I ask this to you, cause i want know the best (fastest) way of achieve this!
Thanks!
i am building a string that i check in mysql db.
eg:
formFields[] is an array - input1 is: string1
array_push(strings, formFields)
1st string and mysql query looks like this:
"select * from my table where id in (strings)"
formFields[] is an array - input2 is: string1, string2
array_push(strings, formFields)
2nd string and mysql query looks like this:
"select * from my table where id in (strings)"
formFields[] is an array - input3 is: string1, string2,string3
array_push(strings, formFields)
3rd string and mysql query looks like this:
"select * from my table where id in (strings)"
i will like to add single quotes and a comma to the array so that i have this for the array strings:
"select * from my table where id in ('string1', 'string2','string3')"
i tried using array implode, but still no luck any ideas? thanks
Hi, I'm trying to build a navigation system using categories table with hierarchies. Normally, the table would be defined as follows:
id (int) - Primary key
name (varchar) - Name of the Category
parentid (int) - Parent ID of this Category referenced to same table (Self Join)
But the catch is that I require that a category can be child to multiple parent categories.. Just like a Has and Belongs to Many (HABTM) relation.
I know that if there are two tables, categories & items, we use a join table categories_items to list the HABTM relations. But here i'm not having two tables but only table but should somehow show HABTM relations to itself. Is this be possible using a single table? If yes, How? If not possible, what rules (table naming, fields) should I follow while creating the additional join table?
I'm trying to achieve this using CakePHP, If someone can provide CakePHP solution for this problem, that would be awesome. Even if that's not possible, any solution about creating join table is appreciated. Thanks for your time.
I know that this has been asked and answered before, but for the life of me I cannot find where I am going wrong. My code is below.
$backa = array("1", "7", "8", "9", "12");
$backaa = implode(",", $backa);
/* code to create connection object $wkHook */
$getOpt=$wkHook->prepare("select movementId, movementName from Movement where movementId IN ($backaa) order by movementName asc");
$getOpt->execute();
$getOpt->store_result($id, $name);
Every time I run this I get one of two errors depending upon how I use the $backaa variable. More often than not I get a call to a non-object error indicating that $getOpt is not a proper Mysql query. I have tried every fashion of quoting, bracketing, etc for the $backaa variable but it's just not working for me. What obvious thing am I missing?
Hi my question
Need to get the 10 word before and 10 words after for the given text . i mean need to start the 10 words before the keyword and end with 10 word after the key word.
Given text : "Twenty-three"
The main trick the having some html tags tags need to keep that tag with this
content only the words from 10before - 10after
content is bellow :
<div id="hpFeatureBoxInt"><h2><span class="dy">Top News Story</span></h2><h3><a href="/go/homepage/i/int/news/world/1/-/news/1/hi/world/europe/8592190.stm">Suicide bombings hit Moscow Metro</a></h3><p>Past suicide bombings in Moscow have been blamed on Islamist rebels At least 35 people have been killed after two female suicide bombers blew themselves up on Moscow Metro trains in the morning rush hour, officials say.<img height="150" width="201" alt="Emergency services carry a body from a Metro station in Moscow (29 March 2010)" src="http://wwwimg.bbc.co.uk/feedengine/homepage/images/_47550689_moscowap203_201x150.jpg">Twenty-three died in the first blast at 0756 (0356 GMT) as a<a href="#"> train stood </a>at the central Lubyanka station, beneath the offices of the FSB intelligence agency.About 40 minutes later, a second explosion ripped through a train at Park Kultury, leaving another 12 dead.No-one has said they carried out the worst attack in the capital since 2004. </p><p id="fbilisten"><a href="/go/homepage/i/int/news/heading/-/news/">More from BBC News</a></p></div>
Thank you
I have a class to read and output the image content, if $width is set, it will resize the image, and then output it.
If I call the function like this $image-readImage('123.jpg'); , it can output the image file correctly, but when I call $image-readImage('123.jpg'); , it just display a black image with resized width & height.
And I tried to replace the code from
@imagejpeg($thumb, null, 100);
to
@imagejpeg($image, null, 100);
will works~
-
protected function readImage($fileName, $width = 0)
{
if ($width <= 0) {
return @file_get_contents($this-destination . '/' . $fileName);
} else {
$imageSize = @getimagesize($this-destination . '/' . $fileName);
$actualWidth = $imageSize[0];
$actualHeigth = $imageSize[1];
if ($actualWidth <= $width) {
return @file_get_contents($this-destination . '/' . $fileName);
}
$height = (100 / ($actualWidth / $width)) * .01;
$height = @round($actualHeigth * $height);
$image = @imagecreatefromjpeg($this-destination . '/' . $fileName);
$thumb = @imagecreatetruecolor($width, $height);
@imagecopyresampled($thumb, $image, 0, 0, 0, 0, $width, $height, $actualWidth, $actualHeight);
ob_start();
@imagejpeg($thumb, null, 100);
$bits = ob_get_contents();
ob_end_clean();
return $bits;
}
}
Any experts know what happened and help me to solve it ?
Thanks.
Awhile ago I wrote a database class which uses PDO in order to connect to SQL Server databases and also to MySQL databases. It has always replaced the question marks fine when using it on the MySQL databases, but for the SQL Server database I had to create a work around which basically replaces the question marks manually. Here is the code for that.
if($this->getPDODriver() == 'odbc' && !empty($values_a) && substr_count($query_s, "?") > 0) {
$query_s = preg_replace(array_fill(0, substr_count($query_s, "?"), '/\?/'), $values_a, $query_s, 1);
$values_a = NULL;
}
Now, I understand that this completely defeats the purpose of the question marks and PDO, but it has been working fine for me. What I would like to do now though, is find out why the question marks are not getting replaced in the first place, and remove this workaround.
If I have a select statement like the following
SELECT * FROM database WHERE value = ?
That is what the query looks like when I go to prepare it, but when I display the query results, it is a blank array.
Just remember, this class is working fine with MySQL, and it is working fine with the work around above. So I know it has something to do with the question marks.
Hi guys, i'm trying to make a "update user's power" page.
It is something similar to those you can find in say, invisionfree forums.
I need it to generate a list of members with checkbox [done]
Add an option for it [done]
What i don't know how to do is to update, to say, give all the selected users the selected power.
Then i went searching for something and found most of them uses array to do this, but i never found one that actually explains how it works.
The example i took (with my own modification) was this:
while($row = mysql_fetch_array($result))
{
echo '<tr>'.$id[]=$rows['id'].'';
echo '<td width="50px" align="center" class="TableFormCell"><input type="checkbox" name="option[]" /></td>';
echo '<td width="170px" align="center" class="TableFormCell">'.$row['uname'].'</td>';
echo '</tr>';
}
I'm not sure what exactly
$id[]=$rows['id'] does
I know after the row, my option[] would become an array of option[1], option[2], option[3]
for what power should be given, i've got no problem with that but on how to update the database i'm got no clue...
for($i=0;$i<$count;$i++){
$sql1="UPDATE ninos SET power='$power' WHERE id='$option[$i]'";
$result1=mysql_query($sql1);
}
So Say i have 5 users, Aye, Bee, Cee, Dee, Eee with IDs of 1,2,3,4,5 how can i make it so that my script would run like
$sql1="UPDATE ninos SET power = '$power' Where id='1','2','3','4','5'";
Please help, thanks.
mkdir() is working correctly this question is more about catching an error. Instead of printing this when the directory exists I would just like to have it write to a message to me in a custom log. How do I create this exception.
Warning: mkdir() [function.mkdir]: File exists
This is my first question on this wonderful website.
Lets say I have a string $a="some text..%PROD% more text" There will be just one %..% in the string. I need to replace PROD between the % with another variable content. So I used to do:
$a = str_replace('%PROD%',$var,$a);
but now the PROD between % started coming in different cases. So I could expect prod or Prod. So I made the entire string uppercase before doing replacement. But the side effect is that other letters in the original string also became uppercase. Someone suggested me to use regular expression. But how ?
Thanks,
Rohan
I have a multidimensional array. The array itself is fine. My problem is that the script takes up monster amounts of memory, and since I'm running this on my MAMP install on my iBook G4, my computer freezes up. Below is the full script.
$query = "SELECT * FROM posts ORDER BY id DESC LIMIT 10";
$result = mysql_query($query);
$posts = array();
while($row = mysql_fetch_array($result)){
$posts[$row["id"]]['post_id'] = $row["id"];
$posts[$row["id"]]['post_title'] = $row["title"];
$posts[$row["id"]]['post_text'] = $row["text"];
$posts[$row["id"]]['post_tags'] = $row["tags"];
$posts[$row["id"]]['post_category'] = $row["category"];
foreach ($posts as $post) {
echo $post["post_id"];
}
Is there a workaround that still achieves my goal (to export the MySQL query rows to an array)?
-Dylan
I want the user to be able to type in a fraction like:
1/2
2 1/4
3
And convert it into its corresponding decimal, to be saved in MySQL, that way I can order by it and do other comparisons to it.
But I need to be able to convert the decimal back to a fraction when showing to the user
so basically i need a function that will convert fraction string to decimal:
fraction_to_decimal("2 1/4");// return 2.25
and a function that can convert a decimal to a faction string:
decimal_to_fraction(.5); // return "1/2"
How can I do this?
Thanks!
By using javascript am trying to cal a webservice.That service return response as follows..
<envelope>
<date_time>
Test', callbackTest Wednesday, March 31, 2010 2:28:55 AM
</date_time>
</envelope>
I am using firefox as browser to execute the application.Thats why after creating the object of XMLHttpRequest try to read as follows
_xmlDoc.responseXML.getElementsByTagName('date_time')[0].firstChild.nodeValue;
But it is showing output like undefined.please help me to solve this problem.What is actual problem ?
Here's a regex that I've cobbled up:
/(.*={76}\s)?\s*(.*?)\s\-\-\s(\d{2}\/\d{2}\-\d{2}\s\d{2}:\d{2})\s\s(.*?)\s(http:\/\/service.*?)\s(\-{76})/is
and here's the text I will be parsing: http://p.linode.com/7015
and here's the replacement for the matched text:
<item>\n\t<title>$2</title>\n\t<pubDate>$pubDate</pubDate>\n\t<description>$4</description>\n\t<link>$5</link>\n</item>\n\n
I have almost come up with a regex needed to parse a block of text into RSS 2.0 XML markup. I've tested it with RegExr and RegexBuddy and it works perfectly except for the last "item" where there is no line breaks after the link (Line 269). In short, the problem is the "iProperty" article in the text is not matched.
Any regex gurus willing to help me troubleshoot what's wrong? I've tried
/(.*={76}\s)?\s*(.*?)\s\-\-\s(\d{2}\/\d{2}\-\d{2}\s\d{2}:\d{2})\s\s(.*?)\s(http:\/\/service.*?)\s*(\-{76})/is
Here's the output that I get: http://p.linode.com/7016
but that didn't work as I expected (i.e. a newline would be optional).
Thanks!
Hi. I have a MySQL query
SELECT * FROM 'redirect'
WHERE 'user_id'= \''.$_SESSION['user_id'].' \'
ORDER BY 'timestamp'`
I want to paginate 10 results per page. How Can I do it?
At first I was going to use doctrine ORM as the main one but it was an overkill, unneeded features and probably excessive calls. One of the main reasons was the "helper" that handled traverse trees (the hierarchy tree) easily but I'm starting to prefer building my own class.
This is what I'm looking for:
1) Can manage multiple database connections, (sort of like doctrine manager)
2) Models
3) flexible
All suggestions are welcome
I'm trying to get content from an RSS2 feed from one of my sites and use it in another site.
The feed is here. And the code I'm using is taken from this nice site and has been modified like the following:
$doc = new DOMDocument();
$doc->load('http://tripleax.com/john/?feed=rss2');
$arrFeeds = array();
foreach ($doc->getElementsByTagName('item') as $node) {
print('<div style="width:100%" class="option"><strong>');
$a = $node->getElementsByTagName('title')->item(0)->nodeValue;
print("$a");
print('</strong><br /><span class="option">');
$a = $node->getElementsByTagName('description')->item(0)->nodeValue;
print("$a");`
}
The problem I'm having is, I want to display the entire post's contents. And the description is a sort of the teaser. Changing $node->getElementsByTagName('description')->item(0)->nodeValue to $node->getElementsByTagName('content')->item(0)->nodeValue gives me nothing, and content:encoded is no better.
Can someone please point me in the right direction to solving this?
Thanks!
I have a multidimensional array. The array itself is fine. My problem is that the script takes up monster amounts of memory, and since I'm running this on my MAMP install on my iBook G4, my computer freezes up. Below is the full script.
$query = "SELECT * FROM posts ORDER BY id DESC LIMIT 10";
$result = mysql_query($query);
$posts = array();
while($row = mysql_fetch_array($result)){
$posts[$row["id"]]['post_id'] = $row["id"];
$posts[$row["id"]]['post_title'] = $row["title"];
$posts[$row["id"]]['post_text'] = $row["text"];
$posts[$row["id"]]['post_tags'] = $row["tags"];
$posts[$row["id"]]['post_category'] = $row["category"];
foreach ($posts as $post) {
echo $post["post_id"];
}
Is there a workaround that still achieves my goal (to export the MySQL query rows to an array)?
-Dylan
Okay. Now I give up. I have been playing with this for hours.
I have a variable name $data.
The variable contains these contents:
array (
'headers' =>
array (
'content-type' => 'multipart/alternative; boundary="_689e1a7d-7a0a-442a-bd6c-a1fb1dc2993e_"',
),
'ctype_parameters' =>
array (
'boundary' => '_689e1a7d-7a0a-442a-bd6c-a1fb1dc2993e_',
),
'parts' =>
array (
0 =>
stdClass::__set_state(array(
'headers' =>
array (
'content-type' => 'text/plain; charset="iso-8859-1"',
'content-transfer-encoding' => 'quoted-printable',
),
'ctype_primary' => 'text',
)),
),
)
I removed some non-essential data.
I want to access the headers value (on the second line above) - simple: $data->headers
I want to access the headers value (on the fourteenth line after the stdClass:: stuff) - how?
How can I possibly access the values within the stdClass::__set_state section?
I tried var_export($data->parts); but all I get is
NULL
Hi,
I have an array:
$arr = array('foo', 'bar', 'bash', 'monkey', 'badger');
I want to have the elements in that array appear as the variables in my list():
list($foo, $bar, $bash, $monkey, $badger) = $data;
Without actually specifying the variables, I tried;
list(implode(",$", $arr)) = $data; and
list(extract($arr)) = $data;
But they don't work, I get:
Fatal error: Can't use function return value in write context
Does anyone have any idea whether this is possible?
Cheers,
Mike
Hi, i was wondering if it was possible to create email forwading accounts on the fly as I have created subdomains for uses profiles i.e. user.profile.com and was wondering if I could create [email protected] to forward to their email account?
Regards,
Phil