Jump to content

chrisshennan

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

About chrisshennan

  • Birthday 07/12/1982

Contact Methods

  • Website URL
    http://www.chrisshennan.com

Profile Information

  • Gender
    Male
  • Location
    Edinburgh, United Kingdom

chrisshennan's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, To use associative arrays you would use $var['foobar'] however $var[foobar] would result in a "use of undefined constant" unless you had specifically declared foobar as a constant. Typically you have to use quotes or apostrophes around associative array keys i.e. $var['foobar'] and numeric based keys don't have the quotes / apostrophe. i.e. $var[0] I hope this helps
  2. The basic rules I use with ', ` and " are:- I only use ` in MySQL and only where the field is a reserved word i.e. you have a field called date so the query ends up like SELECT title, `date` FROM sometable I use ' and " within PHP for different things: if we have a variable called $test with a value of "this is my sample data"; ' spits out exactly what's within the apostrophes (variable aren't evaluated) so echo 'My text is: $test'; will output My text is: $test " allows the variables to be evaluated so echo "My text is: $test"; will output My text is: this is my sample data I hope this helps
  3. Hi, It wouldn't be because you've got apostrophes around the fields in the ON part of the query would it? Try the following and let me know how you get on. SELECT * FROM surveyview_staging LEFT JOIN surveyallanswers_staging ON surveyallanswers_staging.response_id = surveyview_staging.response_id
  4. Hi The query looks fundamentally right and should always limit the search to the user_id but I agree with Maq that the part regarding term1 & term2 looks a bit weird in that you are using equals for one comparison and LIKE for another. Also, do you mean the LIKE clause to start with $term2 or be found anywhere in it? Maybe the following would work better (depending on what exactly you are using it for:- $query = "select * from table where (term1 LIKE '%$term1%' or term2 like '%$term2%') and user_id ='$id'";
  5. Hi, Having a quick look at http://pobox.com/~djb/docs/smtplf.html it would seem to suggest that the problem is because you are using \n instead of \r\n for the new lines in the email content. I think this may be more associated with the headers but it'll not do any harm to replace all the \n for \r\n. Let me know how you get on.
  6. Hi, How about something like:- $q1 = "SELECT cat, COUNT(*) as number_per_category FROM pics GROUP BY cat"; $r1 = mysql_query($q1) or die(mysql_error()); while ($row = mysql_fetch_assoc($r1)) { echo $row['cat'] . ' has ' . $row['number_per_category '] . ' pictures<br>'; } This will get you back all the categories and the number of pictures per category with a single query and you can then loop round the results to display them. This also has the benefit of including the additional categories that get added later on without having to add another section of code as per your example.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.