User Profile

Collapse

Profile Sidebar

Collapse
DavidPr
DavidPr
Last Activity: Jun 25 '13, 11:35 PM
Joined: Mar 18 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • DavidPr
    replied to From an Array to a Variable
    in PHP
    Hmmm, you're right...it is working. I must have inadvertently put an apostrophe or something in the actual code and missed it. Sorry for the trouble, but thanks for your help.
    See more | Go to post

    Leave a comment:


  • DavidPr
    started a topic From an Array to a Variable
    in PHP

    From an Array to a Variable

    Code:
    $lang = array(
    'red'       => 'red',
    'green'     => 'green',
    'brown'         => 'brown'
    );
    I've tried these:
    Code:
    $thiscolor = "{$lang['green']}";
    $thiscolor = {$lang['green']};
    $thiscolor = $lang['green'];
    But the variable will not pick up the color. What's wrong?
    Thanks
    See more | Go to post

  • DavidPr
    started a topic Store {$lang['name']} in database -> display on page?
    in PHP

    Store {$lang['name']} in database -> display on page?

    I have a language array page on each of my websites and this {$lang['name']} displays the name of the website.

    All the websites query the same MySQL table and I want to insert this {$lang['name']} into the table so when the other information is displayed it will also display the name of that website.

    But instead of displaying the website's name it simply displays {$lang['name']}. I'm query the table using this:
    ...
    See more | Go to post

  • DavidPr
    replied to Left Outer Join with Where clause
    in PHP
    Right, I was working with an if clause earlier and the two == was stuck in my mind.

    I tried a few various ways of working the WHERE clause but it just wasn't doing it for me. I used the mysql_error, but it wasn't throwing an error. It just didn't return anything or something that I didn't want. Oh well, I just went back to using an if clause. It list what I want just not in alphabetical order.

    I appreciate all the help....
    See more | Go to post

    Leave a comment:


  • DavidPr
    started a topic Left Outer Join with Where clause
    in PHP

    Left Outer Join with Where clause

    I can't seem to get this working:

    Code:
    $query = "SELECT c.c_id,c.c_name, COUNT( p.recipe_title ) as theCount
    FROM new_recipe_cat AS c
    LEFT OUTER JOIN new_recipes AS p ON c.c_id = p.c_id
    WHERE (c_id==11 && c_id==12 && c_id==13 && c_id==14
    && c_id==15 && c_id==16 && c_id==17 && c_id==22
    && c_id==23)
    AND r_allow=1
    GROUP BY
    ...
    See more | Go to post

  • DavidPr
    replied to sessions gone wild
    in PHP
    OK, I found the problem with that which I posted above. The query should have been this:
    Code:
    $query = "SELECT recipe_id
    FROM favorite_recipes
    WHERE favorite_user_id='" . $_SESSION['user_id'] . "'
    AND recipe_id='$recipe_id'";
    $result = mysql_query ($query);
    What this query was doing was checking to see if the user had already added this recipe into their favorites. If so, this section was to...
    See more | Go to post

    Leave a comment:


  • DavidPr
    replied to sessions gone wild
    in PHP
    See any reason why this would not display even though the session user_id is set and the recipe_id hasn't been added already? I have the user_id echo-ed above this script (as a test) to make sure that it is set and it is. I can't figure out why it isn't working.

    Code:
    if (isset($_SESSION['user_id']))
    {
    
    include('dbconnect.php');
    
    $query = "SELECT recipe_id
    FROM favorite_recipes
    WHERE
    ...
    See more | Go to post

    Leave a comment:


  • DavidPr
    replied to sessions gone wild
    in PHP
    When you say SQL Injection I guess you're referring to this:
    Code:
    $recipe_id = $_GET['recipe_id'];
    I changed to this:
    Code:
    $recipe_id = escape_data($_GET['recipe_id']);
    $user_id = escape_data($_SESSION['user_id']);
    
    $query = "INSERT INTO favorite_recipes (user_id, recipe_id) VALUES ('$user_id', '$recipe_id')";
    I have an escape_data function in my database connection include that handles mysql_real_esca pe_string.

    I...
    See more | Go to post

    Leave a comment:


  • DavidPr
    started a topic sessions gone wild
    in PHP

    sessions gone wild

    I start sessions on all pages with:
    Code:
    ob_start();
    session_start();
    at the top of the page before anything else.

    When I login these sessions are set:
    Code:
    $query = "SELECT *
    FROM users
    WHERE (email='$e' AND pass=SHA('$p'))
    AND active IS NULL";
    $result = mysql_query ($query);
    if (@mysql_num_rows($result) == 1) {
    $row = mysql_fetch_array ($result, MYSQL_NUM);
    $_SESSION['user_id']
    ...
    See more | Go to post

  • DavidPr
    started a topic Javascript popup window for pictures

    Javascript popup window for pictures

    I'm using a Javascript script that displays pictures in a popup window and it works fine except when there's a picture that contains parentheses:

    Code:
    <a href="javascript:popImage('http://www.mysite.com/gallery/pic1(small).jpg','Pictures')">
    <img src='http://www.mysite.com/gallery/thumbs/pic1(small).jpg' width='100' height='75' alt='Picture' >
    </a>
    Notice the parentheses around the word...
    See more | Go to post

  • DavidPr
    replied to Unique Website Counter
    in PHP
    Looks interesting, but I can't read German and I didn't see an English translation link.

    Thanks
    See more | Go to post

    Leave a comment:


  • DavidPr
    started a topic Unique Website Counter
    in PHP

    Unique Website Counter

    I made a website for a group of people and they want a visitor counter on it. I don't like hit counters because if the site is dead everyone will know it. But, it's their website.

    I did an Internet search but didn't find exactly what I was looking for. I did find an old tutorial, from which I've pasted the code below.

    I need it to be session controlled and I only want it to count unique visitors. I want to use a database...
    See more | Go to post

  • DavidPr
    replied to How many sessions can I have at one time
    in PHP
    Thanks, I'll take a look at them.
    See more | Go to post

    Leave a comment:


  • DavidPr
    replied to How many sessions can I have at one time
    in PHP
    I tried using these sessions. I have not tried to unset them yet. The information shows back up in the form OK except for the textareas aren't right. It was showing the textarea information with the \r\n\r\n instead of dropping down two lines.

    I used the str_replace and then it just replaced the \r\n\r\n with <br><br>, again instead of dropping down two lines.

    To get it to show right I had to do the below...
    See more | Go to post

    Leave a comment:


  • DavidPr
    replied to How many sessions can I have at one time
    in PHP
    I know there are tons of session tutorials on the web. I've seen them all. See one and you've basically seen them all, since they're pretty much the same tutorial with only the names changed.

    They assume that you're only going to use a session for a login feature and that's it. Well, I could use a dozen or more sessions at one time. I have many different forms on a single website.

    I use a generic session for a user login....
    See more | Go to post

    Leave a comment:


  • DavidPr
    replied to Delete not working
    in PHP
    I found that UPDATE worked better than DELETE in this instance.
    Code:
    $name = $_POST['name'];
    $address1 = $_POST['address1'];
    $address2 = $_POST['address2'];
    $phone = $_POST['phone'];
    $cell = $_POST['cell'];
    
    // variables may have a value or they may be empty
    
    query="UPDATE address_book SET
    name='$name',
    address1='$address1',
    address2='$address2',
    phone='$phone',
    ...
    See more | Go to post

    Leave a comment:


  • DavidPr
    started a topic How many sessions can I have at one time
    in PHP

    How many sessions can I have at one time

    I'm using this in a form:
    Code:
    value='"; if (isset($_POST['title'])) echo $_POST['title']; echo "'
    The idea was to save the inputs so that if a user had to go back and make a correction they wouldn't have to re-enter all of their information. Nice idea, but it doesn't work. At least not with the above method.

    I'm not quite sure what to do at this point. I'm already using a login in session that keeps up with the...
    See more | Go to post

  • DavidPr
    replied to Adding number to image upload name
    in PHP
    OK, nothing I've tried thus far has even remotely worked.

    I have to create a unique name for the image. I would like to use the user's user_id to do this. This way I can identify the photo as belonging to whomever.

    The images aren't stored in the database, just the name and sizes. But the image_name in the database will be the same as the image names of the photos in the folders - pgallery/ and pgallery/thumbs, and will...
    See more | Go to post

    Leave a comment:


  • DavidPr
    replied to Delete not working
    in PHP
    How would I sanitize that?
    See more | Go to post

    Leave a comment:


  • DavidPr
    started a topic Delete not working
    in PHP

    Delete not working

    This is a classified ads table which contains all the item's information.

    The item's "id" is received on this delete page using
    Code:
    $id = $_GET["id"];
    . It's being sent by
    Code:
    delete_picture.php?id=$id
    A query takes place which grabs the image_name from the database based on the id. Then it unlinks the images in the image/ and image/thumbs folders with this image_name. So the id variable is working, at least to this point....
    See more | Go to post
No activity results to display
Show More
Working...