ShawnCplus 456 Code Monkey Team Colleague

It's as if what doesn't handle it at all. define doesn't return anything accept true/false whether it successfully declared the constant or not. What exactly are you trying to do?

ShawnCplus 456 Code Monkey Team Colleague

There's no such thing as a conditional insert, it just appends to the end of the table. Do your conditional in PHP.

ShawnCplus 456 Code Monkey Team Colleague

You don't need a switch statement

<?php
$day = intval($_GET['day']);
if($day >0 && $day <8) {
  include('day' . $day . '.php');
} else {
  echo  'Invalid page';
}
?>
Ezzaral commented: Much better. +19
ShawnCplus 456 Code Monkey Team Colleague

I mean post the query. There is a query being passed to the 'executeQuery' function that is incorrect, that is why the function is failing.

ShawnCplus 456 Code Monkey Team Colleague

The query is failing, post the query and we might be able to fix it.

ShawnCplus 456 Code Monkey Team Colleague

ORMs exist to make the life of a developer easier, so you aren't manually dealing with physical resultsets from mysql_fetch_array all the time.

Also, having an ORM allows you to attach functions to certain objects ie., you want to be able to perform drawCircle on every Circle saved to the database.

In the end it is just good OOP practice, allows for code reuse, code maintainability, and ease of expansion.

ShawnCplus 456 Code Monkey Team Colleague

Yeah, try that giant SITE SEARCH on the right that takes about 30% of the top of the site.

ShawnCplus 456 Code Monkey Team Colleague

There is no way to force a user to automatically open a file. If there was it would be a huge security risk.

ShawnCplus 456 Code Monkey Team Colleague

You forgot your closing " on $query

ShawnCplus 456 Code Monkey Team Colleague

well cURL is actually a program in and of itself which can send http requests along with a large number of different protocols. Usually an "HttpRequest" is a Javascript object used to make AJAX calls.

ShawnCplus 456 Code Monkey Team Colleague

That's not actually running the PHP function onchange. It's running a Javascript function onchange. The PHP function only runs once when the page is loaded.

ShawnCplus 456 Code Monkey Team Colleague
preg_match('/^[\w\-]+$/', $value)
ShawnCplus 456 Code Monkey Team Colleague

Your best bet would be to read the Drupal tutorials on their homepage

ShawnCplus 456 Code Monkey Team Colleague

Vectors use the empty method

vector <int> test;
if(test.empty()) ...
ShawnCplus 456 Code Monkey Team Colleague

Why is it you can't use AUTOINC for your primary key? I don't really get your explanation of why you can't.

ShawnCplus 456 Code Monkey Team Colleague

Do you understand what these lines do?

*(boardSkin +(row * columns) + column)

You're setting a memory address to a value, that above line is the same thing as saying boardSkin[((rows*columns)+column)] . (I think, its been a LONG, LONG time since I've used *(array + offset) notation, probably because it unnecessarily obfuscates code. So ask yourself, does that index in the char array exist?

ShawnCplus 456 Code Monkey Team Colleague
$keywords = array('value2','value1','value');
$replace = '<a href="webpage.php?view&id=\1">\1</a>';
$search = '/('.join('|',$keywords).')/';
preg_replace($search, $replace, $source);

I've reversed the keywords because the grouping will be non-greedy so if you place 'value' first it will never find value1 or value2

ShawnCplus 456 Code Monkey Team Colleague

Actually, the php.net page does have an installation guide.
http://us3.php.net/manual/en/svn.installation.php

ShawnCplus 456 Code Monkey Team Colleague

Well, given that you know AJAX it seems a bit strange for you to ask this question

So basically i need the user to be able to click a specific link, which then updates the database, and then shows a success message, all without refreshing the page.

Which is essentially the exact definition of what the purpose of AJAX is. Also, I find it hard to believe you've been a PHP programmer for 3 years and a "flourishing web developer" for 1 year without knowing at least the basics of AJAX.

So I guess I'll go ahead and apologize for serkan's whoring of ASP and my direct answer to the original question for no apparent reason. Glad we could help.

ShawnCplus 456 Code Monkey Team Colleague

okay, talking through it got me searching different terms. Apparently, sed can do this, but I need to insert a "^J" or "ctrl-J". I've not figured out how to do that with my keyboard that doesn't spit me out to a prompt, though.

It seems like this should work (pipes "|" are the separators):

cat tivo.xml | 's|>\<|\>\"ctrl-J"\<|g'

The "tr" command can too, and the other site suggested using octal notation to get that to work, but again, I'm hitting a roadblock...

crop tivo.xml | tr -d '\076\074' '\076\012\074' > tivo.result


gives me the following:

"blank line"
?xml version="1.0" encoding="utf-8"?>
TiVoContainer xmlns="http://www.tivo.com/developer/calypso-protocol-1.6/">
Details>
ContentType>x-tivo-container/tivo-videos
/ContentType>
SourceFormat>x-tivo-container/tivo-dvr
/SourceFormat>
Title>Now Playing
/Title>
LastChangeDate>0x49B7F8FF
/LastChangeDate>
TotalItems>73
/TotalItems>
UniqueId>/NowPlaying
/UniqueId>
/Details>
SortOrder>Type,CaptureDate
/SortOrder>
GlobalSort>Yes
/GlobalSort>
ItemStart>0
/ItemStart>
ItemCount>73
/ItemCount>
Item>
Details>
ContentType>video/x-tivo-raw-pes
/ContentType>
SourceFormat>video/x-tivo-raw-pes
/SourceFormat>
Title>The Daily Show With Jon Stewart
/Title>
SourceSize>783286272
/SourceSize>
Duration>3600000
/Duration>
CaptureDate>0x49B7535F
/CaptureDate>
SourceChannel>48
/SourceChannel>
SourceStation>COMEDYP
/SourceStation>
HighDefinition>No
/HighDefinition>
ProgramId>EP2930531384
/ProgramId>
SeriesId>SH293053
/SeriesId>
EpisodeNumber>14034
/EpisodeNumber>
ByteOffset>0
/ByteOffset>
/Details>
Links>
Content>
Url>http://192.168.1.20:80/download/The%20Daily%20Show%20With%20Jon%20Stewart.TiVo?Container=%2FNowPlaying&amp;id=3207375
/Url>
ContentType>video/x-tivo-raw-pes
/ContentType>
/Content>
TiVoVideoDetails>
Url>https://192.168.1.20:443/TiVoVideoDetails?id=3207375
/Url>

This works, but the output deletes the "<" off of each tag. I mean, I'm not complaining. Technically, it is what I want, but I guess I just wanted to know why it does this...

Regards,
Bryan

I just posted the way to do it correctly

ShawnCplus 456 Code Monkey Team Colleague

replace test.html with the name of your file

sed -r "s/<Url>([^<]+)<\/Url>/\nURL: \1\n/g" test.html | grep ^URL: | sed -r "s/^URL: //g"

This will give you a newline delimited list of the URLs

Also, in the future you can use the following command to clean the XML (requires Tidy)

tidy -xml -i -q <file>
ShawnCplus 456 Code Monkey Team Colleague

It's called AJAX, once you know the term you'll have more articles then you'll know what to do with. Have fun.

ShawnCplus 456 Code Monkey Team Colleague

1. It's of no importance that strtoul returns unsigned long int, there is a legal conversion from this type to int. Probably, that microcontroller is not capable to send unsigned long (long) numbers ;)
2. Yes, return 0.0 was in the 1st variant of this improvisation. Fortunately, there is a proper downgrade conversions chain in C++: double => int => bool ;)

Yeah, I just don't particularly like implicit type conversion in strictly typed language so I try to avoid it.

ShawnCplus 456 Code Monkey Team Colleague

strtoul(<string>, NULL, <base to convert, 16 for hex>); Also, ArkM, strtoul returns an unsigned long, not an int. And in your first function why are you type coercing 0.0 (double) to bool?

ShawnCplus 456 Code Monkey Team Colleague

Also, you don't need a ; at the end of a while and mysql_fetch_assoc is the same as mysql_fetch_array($resultset, MYSQL_ASSOC)

ShawnCplus 456 Code Monkey Team Colleague

I just realized I was in the C++ forum, haha, oh well. Here's the C++ equivalent

In C++ you can use the following

#include <cstdio>
int main(int argc, char** argv)
{
  char* somehex = "05a1";
  unsigned long somelong = strtoul(somehex, 16);
  printf("%d", somelong);
  return 0;
}
ShawnCplus 456 Code Monkey Team Colleague

there is no such thing as a double in hex. Use hexdec to convert to an integer then explicitly cast the return to a double.

$someHEx = "0x01A";
$someDouble = (double)hexdec($someHex);
ShawnCplus 456 Code Monkey Team Colleague
serkan sendur commented: i am not whoring .net -1
Rashakil Fol commented: good +9
Comatose commented: Nice Post +12
ShawnCplus 456 Code Monkey Team Colleague

C++ does not have anonymous functions. However, C++0x standard does using the following syntax (using a std::for_each as an example)

std::map<int, int> someMap;
// ... ...
std::for_each(someMap.begin(), someMap.end(), []( std::pair<int, int> map_entry ) {
  // ... lambda body
});

The initial [] leading the arguments defined what should be passed to the lamda, [&] says pass everything by reference, [=] says pass everything by value, you can also pass variables individually which default to being passed by reference (Deference with * obviously)

But take note that this is only an initial standard and as far as I known there hasn't been a definite date nailed down.

ShawnCplus 456 Code Monkey Team Colleague

Well, looking through a few of them they could use some improvement, most notably the hex to rgb function, hexdec is your friend.

function torgb($string)
{
  $string = str_replace("#","",$string);
  $r = substr($string, 0, 2);
  $g = substr($string, 2, 2);
  $b = substr($string, 4, 2);
  return array(hexdec($r), hexdec($g), hexdec($b));
}
ShawnCplus 456 Code Monkey Team Colleague

Make sure you don't have IIS installed or running or that any other program you have running is starting a web server.

ShawnCplus 456 Code Monkey Team Colleague

http://php.net is an amazing resource if you're using PHP its a good idea to get very familiar with it.

ShawnCplus 456 Code Monkey Team Colleague

Depends on your needs. If you only need GET parameters then file_get_contents should be fine. cURL on the other hand allows for much more customization in headers sent.

ShawnCplus 456 Code Monkey Team Colleague

Remove the space, the url variable is still a variable, never put spaces in variables.

ShawnCplus 456 Code Monkey Team Colleague

Hi frnds...
I need to integrate php variable with vedio scripting file.....

i fetch my vedio file path from database...here i need to replace the file=videos/movieimgae.swf ....with $vedio..

<?php $video="vedios/aaa.php"; ?>
<script type="text/javascript">
  var s1 = new SWFObject('player.swf','player','400','300','9');
  s1.addParam('allowfullscreen','true');
  s1.addParam('allowscriptaccess','always');
  s1.addParam('flashvars','file=[B]<?php echo $video ?>[/B]');
  s1.write('preview');
</script>
ShawnCplus 456 Code Monkey Team Colleague

Posting the code would help

ShawnCplus 456 Code Monkey Team Colleague

ugh, php can be so hacky sometimes. Though I guess you could just put that in a wrapper function or something.

Setting a cookie to the past has nothing to do with PHP being hacky, it forces the browser (which is what's being hacky) to delete the cookie which is a file on the client computer. There is no way PHP could touch a client filesystem (when used in a browser, obviously it could do it if used outside of a web environment)

ShawnCplus 456 Code Monkey Team Colleague

Honestly, you have been given the proper solutions. Sending (and therefore, reading) your forms with the POST method sends variables through the headers sent. For this purpose, however, I would recommend SESSIONs as people could potentially look at the header information. SESSION variables are contained solely on the server (aside from the associated client COOKIE which only contains the SESSION ID).

Well that's a good approach except for the fact that you somehow have to get the data to the PHP script first so the data can be placed in the session :)

ShawnCplus 456 Code Monkey Team Colleague

Exactly, that's why most people here probably wont and shouldn't help you with this.

ShawnCplus 456 Code Monkey Team Colleague

You could just use form method POST

ShawnCplus 456 Code Monkey Team Colleague

Careful about misleading people. A hash is not encryption. There is no way to decrypt a hash. There is also no such thing as a "dehasher", the only way to "reverse" a hash is to create huge libraries (called rainbow tables) of pre-created hashes and check against them. MD5, SHA1/256/etc are hashes, Vigenere, WEP, etc. are encryption.

ShawnCplus 456 Code Monkey Team Colleague

It might not be the error that's causing your problem but remove the semicolon after the second if statement

ShawnCplus 456 Code Monkey Team Colleague

Split and explode are the same thing, they are just two different names.

ShawnCplus 456 Code Monkey Team Colleague

1) You're missing an ending ) on the first line of your JS

2) "Gray" isn't a safe CSS color, use #ccc

ShawnCplus 456 Code Monkey Team Colleague

^(.+?):(.+?)$ That's pretty much it. That's a pretty simple regex, you might want to study them for yourself http://www.regular-expressions.info/, it's a pretty decent resource.

ShawnCplus 456 Code Monkey Team Colleague

Firstly, this should be in the HTML forum, secondly

<img height="32" width="32" src="blah.jpg />

... ...

ShawnCplus 456 Code Monkey Team Colleague

It's just me but I'm pretty sure you would contact Paypal about that sort of thing.

ShawnCplus 456 Code Monkey Team Colleague

A) Don't iterate through POST variables if you're doing any sort of key/value assignment. I (as a user) can put anything I want into POST and given that you're eval ing the code you immediately just opened yourself up to every attack under the sun

B) Why the heck are you using eval?

ShawnCplus 456 Code Monkey Team Colleague

There's no need to use a regular expression for that

$string =  'Name: Bob, Age: 20, Details: Likes chocolate';
  $properties = explode(",", $string);
  $result = array();
  foreach($properties as $property) {
    $split = explode(":", $property);
    $result[$split[0]] = $split[1];
  }
  print_r($result);
  /*
    Array
      (
        [Name] => ' Bob',
        [Age]  => ' 20',
        [Details] => ' Likes chocolate'
      )
  */
ShawnCplus 456 Code Monkey Team Colleague
  1. Build Website
  2. Advertise
  3. ...
  4. Profit