The script I'm using is
if($profile['username'] == $user['username']) {
$db->query("UPDATE users SET newcomments = 0 WHERE username = '$user[username]'");
echo "This is a test";
}
(Note that $db-query is exactly the same as mysql_query)
For some very odd reason, the MySQL query is being performed even if the defined condition is false
The "This is a test" works properly and only appears when the condition is met, but the MySQL query is performed anyway
Whats the problem with it?
Does anyone know of one? I need to test some upload/download scripts and need some really large files generated. I was going to integrate the test utility with my debug script.
1) This issue involves just one html webpage, lets call it "ajax.html".2) I have AJAX functions in this webpage that work in both Firefox and IE8.3) I now attempt generating just the option values of a dropdown list of dates using my ajax functions, and it works in Firefox & Opera, but not IE8.4) The surrounding html code for the dropdown looks like this:<select name="entry_7_single" id="entry_7" onChange="Ajax_PhpResultsWithVar('./secure/db/SummaryCls.php','entry_8','dateval',this.value)"></select>The onchange call refers to an ajax function that successfully(both Firefox & IE8) populates a textarea(entry_8) with a description of an event associated with the date selected in this dropdown. 5) An onload call initiates the ajax function to generate the dropdown list values:<body class="ss-base-body" onLoad="OnLoadWebPage()">6) The js script that calls the ajax function is as follows:function OnLoadWebPage(){ Ajax_PhpResults('./secure/db/GenDateListCls.php','entry_7');}7) Since it works in Firefox, but not IE8, I throw the output of the ajax function into a Firefox large textbox and I get the following:<option selected value="8 JUN 2010">8 JUN 2010</option> <option value="9 JUN 2010">9 JUN 2010</option> <option value="10 JUN 2010">10 JUN 2010</option> <option value="11 JUN 2010">11 JUN 2010</option> 8 ) There are over a hundred generated but you get the gist of what the ajax function generates. Next I will list the PHP function that outputs the above dropdown values://///////////////////////////////////////////////////////////////////////////////////////////////////////<?phpinclude_once 'SPSQLite.class.php';include_once 'misc_funcs.php';class GenDateListCls { var $dbName; var $sqlite; function GenDateListCls() { $this->dbName = 'accrsc.db'; $this->ConstructEventDates(); } function ConstructEventDates() { $this->sqlite = new SPSQLite($this->dbName); $todayarr = getdate(); $today = $todayarr[mday] . " " . substr($todayarr[month],0,3) . " " . $todayarr[year]; $ICalDate = ChangeToICalDate($today); $dateQuery = "SELECT dtstart from events where substr(dtstart,1,8) >= '" . $ICalDate . "';"; $this->sqlite->query($dateQuery); $datesResult = $this->sqlite->returnRows(); foreach (array_reverse($datesResult) as $indx => $row) { $normDate = NormalizeICalDate(substr($row[dtstart],0,8)); if ($indx==0) { ?> <option selected value=<?php echo('"' . $normDate . '"'); ?>><?php echo $normDate; ?></option><?php } else {?> <option value=<?php echo('"' . $normDate . '"'); ?>><?php echo $normDate; ?></option><?php } } $this->sqlite->close(); }}$dateList = new GenDateListCls(); ?>/////////////////////////////////////////////////////////////////////////////////////////////////////////////<<< I appreciate any assistance on this matter. Aipragma >>>
My Background:
To let you all know, I am a complete newbie to PHP, Ajax, & javascript, and learning it all on my own, no classes. My background is in Linux, Windows, C++, Java, VB,VBA,MS XML, & some html.
How do I post them to whatever page from here and how can I send these variables to several pages at the same time?
//catched those variables within the same page
$event = $_POST['event'];
$when = $_POST['eventdate'];
$where = $_POST['place'];
$name = $_POST['name'];
$tel = $_POST['tel'];
$email = $_POST['email'];
send $event, $when, $where, ... to("whateverurl1");//not the way
Hello. How can I remove the first number in a string? Say if I had these 48 numbers seperated with a ',' (comma):
8,5,8,10,15,20,27,25,60,31,25,39,25,31,26,28,80,28,27,31,27,29,26,35,8,5,8,10,15,20,27,25,60,31,25,39,25,31,26,28,80,28,27,31,27,29,26,35
How would I remove the "8," from the string? Thanks.
I try to get some insights from the pages I am administrator on Facebook. What my code does, it gets the IDs of the pages I want to work with through mySQL. I did not include that part though.After this, I get the page_id, name and fan_count of each of those facebook IDs and are saved in fancounts[].
Using the IDs ( pages[] ) I get two messages max from each page. There may be no messages, there may be 1 or 2 messages max. Possibly I will increase it later. messages[] holds the messages of each page.
I have two problems with it.
It has a very slow performance
I can't find a way to echo the data like this:
ID - Name of the page - Fan Count
Here goes the first message
Here goes the second one
//here is a break
ID - Name of the page 2 - Fan Count
Here goes the first message of page 2
Here goes the second one of page 2
My questions are, how can the code be modified to increase performance and show the data as above? I read about fql.multiquery. Can it be used here?
Please provide me with code examples. Thank you
$pages = array(); // I get the IDs I want to work with
$pagesIds = implode(',', $pages);
// fancounts[] holds the page_id, name and fan_count of the Ids I work with
$fancounts = array();
$pagesFanCounts = $facebook->api("/fql", array(
"q" => "SELECT page_id, name, fan_count FROM page WHERE page_id IN ({$pagesIds})"
));
foreach ($pagesFanCounts['data'] as $page){
$fancounts[] = $page['page_id']."-".$page['name']."-".$page['fan_count'];
}
//messages[] holds from 0 to 2 messages from each of the above pages
$messages = array();
foreach( $pages as $id) {
$getMessages = $facebook->api("/fql", array(
"q" => "SELECT message FROM stream WHERE source_id = '$id' LIMIT 2"
));
$messages[] = $getMessages['data'];
}
// this is how I print them now but it does not give me the best output. ( thanks goes to Mark for providing me this code )
$count = min(count($fancounts),count($messages));
for($i=0; $i<$count; ++$i) {
echo $fancounts[$i],'<br>';
foreach($messages[$i] as $msg) {
echo $msg['message'],'<br>';
}
}
I am running following code, getAccount() is a static function,
$ac_info = AccountClass::getAccount($ac_code);
print_r($ac_info);
and getting following output
AccountClass Object ( [account_code] => [email protected] [username] => XYZ [email] => [first_name] => [last_name] => [company_name] => [id] => [email protected] [balance_in_cents] => 0 [created_at] => 1271333048 [state] => active )
But I want to access the value of "account_code" shown above, how to access it, and AccountClass Object what is this, this is array or what? I am not getting it properly.
Please explain what is AccountClass Object and how to access value of properties account_code, first_name inside this array.
Thanks
I think if I granted the apache user appropriate privileges and used the ident authentication method, that would make the connection more secure because then the password wouldn't need to be stored in a connection string.
Also, that way the security of the connection would depend on how secure the host system is. I disabled root login over ssh and only permit public key authentication so I think it is pretty secure.
Does this have any significant security benefits or is it just wishful thinking? Is it necessary at all?
Hello. How could I make an image graph from values in a database? The idea came from "Steam", which uses a graph to show how many users are online. How could I do the same thing? It seems like the graph is one whole image; not made up of parts. Here's an image of the graph from Steam:
Thanks.
I have a select box that is part of a form. It is currently querying the addresses table and displaying the addresses into the select box. I plan on having up to 100 addresses.
I'm looking for a solution where I can show all the states if the user clicks on the select box. Then if the user hovers over a state it will show all the addresses for that specific state. Then if the user clicks on an address, it will show that as the picked option in the select box. This is like a dropdown menu within a select box.
Does anyone know where I can find a solution as this?
I have pasted the example of what I need here : http://pastie.org/1005178
I have a xml file with say the following info
<state>
<info>
<name>hello</name>
<zip>51678</zip>
</info>
<info>
<name>world</name>
<zip>54678</zip>
</info>
</state>
Now I need to create a new xml file which has the following
<state>
<info>
<name>hello</name>
<zip>51678</zip>
<lat>17.89</lat>
<lon>78.90</lon>
</info>
<info>
<name>world</name>
<zip>54678</zip>
<lat>16.89</lat>
<lon>83.45</lon>
</info>
</state>
So, basically I need to add lat and lon nodes to each info element.
these lat and lon correspond to the zip code which are stored in a mysql file which contains 3 fields - pin, lat and lon
How do i do this recursively. I have say 1000 info elements in a file
Please give me a sample code because I have already tried using simplexml and read the documentation but doesn't see to understand it properly
Hello. Can anyone tell me how to get and display the biggest values from a database? I have multiple values in my database with the heading "gmd", but how would I get only the first 3 biggest ones to be displayed? How would I do it in this example:
$query = "SELECT gmd FROM account";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
}
Thanks.
I want to start a new C++ (Qt) Open Source project and I'm wondering if there is an existing template somewhere for files usually found in an Open Source project but that are not purely source code (README, LICENSE, CHANGELOG, etc.)
I could probably find a popular Open Source project for inspiration but if there is some existing generic templates, I will use that instead.
Thanks.
I was going to use the scuttle solution on: http://www.pui.ch/phred/archives/2005/04/tags-database-schemas.html for handling searches on my website. I was wondering how I could take the search input from a user and turn it into a single query.
For instance, let's say a user inputted 'blue dogs' in their search query... How could I dynamically update the query to include ('blue', 'dogs') in union and intersection queries?
For example, take this code:
$ch = curl_init($resultSet['url']."?get0=get0&get1=".$get1."&get2=".$get2."&get3=".$get3);
This of course, looks very ugly, and kind of a pain in the ass to read. So my question is, would I be able to use something like this:
$allgets ="?act=phptools&host=".$host."&time=".$duration."&port=".$port;
$ch = curl_init($resultSet['url'] . $allgets);
Very simple question I suppose, but my server is undergoing maintenance, so I can't upload it and test it myself. I suppose a yes or no answer will suffice, but if you have a more efficient way of doing this, that would be even better. :)
I've been trying to use SimpleXML, but it doesn't seem to like XML that looks like this:
<xhtml:div>sample <xhtml:em>italic</xhtml:em> text</xhtml:div>
So what library will handle tags that look like that (have a colon in them)?
Hola usando estas funciones, que riesgo corro en tener problemas de seguridad, es necesesario usar extract() o hay alguna manera mejor de convertir las variables superglobales (array) en trozos de variables.
if ( get_magic_quotes_gpc() ) {
$_GET = stripslashes( $_GET );
$_POST =stripslashes( $_POST );
}
function vars_globals($value = '') {
if (is_array ( $value ))
$r = &$value;
else
parse_str ( $value, $r );
return $r;
}
$r = vars_globals( $_GET );
extract($r, EXTR_SKIP);
The agavi framework uses the PUT request for create and POST for updating information. Usually in REST this is used the other way around (often referring to POST adding information while PUT replacing the whole data record).
If I understand it correctly, the important issue is that PUT must be idempotent, while POST does not have this requirement. Therefore, I wounder how creating a new record can be idempotent (i.e. multiple request do not lead to multiple creations of a record) in particular when usually the ORM uses an id as a primary key and the id of a new record would not be known to the client (since it is autocreated in the database), hence cannot be part of the request. How does agavi maintain the requirement of idempotence in light of this for the PUT request.
Thanks.
I have an array that has keys and values. For eg:
Array (
[name] => aalaap
[age] => 29
[location] => mumbai
)
I want to convert the keys from this into values, but I want the values to apear right after the keys. For eg:
Array (
[0] => name
[1] => aalaap
[2] => age
[3] => 29
[4] => location
[5] => mumbai
)
I can easily write an iteration function that will do this... for eg:
array_flatten($arr) {
foreach ($arr as $arrkey => $arrval) {
$arr_new[] = $arrkey;
$arr_new[] = $arrval;
}
return $arr_new;
}
...but I'm trying to find out if there's any way this can be accomplished using array_combine, array_keys, array_values and/or array_merge, preferably in one, so i don't need to use a custom function.
Is there?
I've been googling around for a really simple way of making what is, in effect, nothing more than an enhanced phpMySql.
In a mysql database, I have:
Name, address, phone, website etc, plus 2 or 3 custom fields. This data is pulled out to make a website.
All I want is to be able to make a freeform form, a bit like Access, but for the web, and the only thing I want to do over and above normal field editing would be to have a list of when I contact them, what was said, and perhaps a reminder when the next action is due.
I've looked at so many CRMs my mind is boggling, and they all do WAY more than I need. I don't have leads or accounts, all I have is the need to make sure than when I update the person's details, and for that data to be in the same DB as my site is generate from.
I'm happy to learn if I can get pointed in the right direction, and I have a feeling that something like what I want might lie in the direction of jquery. It's just that there's so much good jquery stuff about, I can't see the wood for the trees!
Thanks.
So here's my problem: I have two types of registration, registration A and registration B, each will have some of the same fields and some different fields. I was going to create abstract class registration and both A and B would have their own classes that extend from registration. My question is, should I create a seperate Validation class with seperate A and B validation classes that extend? or is there a better pattern to use for something like this?
Thanks
What is a good way to represent a collection of bits?
I have a set of various on/off toggles (thousands of them) and need to store and retrieve their state. The naïve implementation would be an array of booleans, but I'm wondering if there's a better way (better in terms of access speed and/or memory requirements).
I've found this BitArray implementation, but it's limited to 32 bits, which is not enough for this case.