User Profile
Collapse
-
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. -
From an Array to a Variable
I've tried these:Code:$lang = array( 'red' => 'red', 'green' => 'green', 'brown' => 'brown' );
But the variable will not pick up the color. What's wrong?Code:$thiscolor = "{$lang['green']}"; $thiscolor = {$lang['green']}; $thiscolor = $lang['green'];
Thanks -
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:
... -
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....Leave a comment:
-
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
-
OK, I found the problem with that which I posted above. The query should have been this:
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...Code:$query = "SELECT recipe_id FROM favorite_recipes WHERE favorite_user_id='" . $_SESSION['user_id'] . "' AND recipe_id='$recipe_id'"; $result = mysql_query ($query);
Leave a comment:
-
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 WHERELeave a comment:
-
When you say SQL Injection I guess you're referring to this:I changed to this:Code:$recipe_id = $_GET['recipe_id'];
I have an escape_data function in my database connection include that handles mysql_real_esca pe_string.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...Leave a comment:
-
sessions gone wild
I start sessions on all pages with:at the top of the page before anything else.Code:ob_start(); session_start();
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'] -
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:
Notice the parentheses around the word...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> -
Looks interesting, but I can't read German and I didn't see an English translation link.
ThanksLeave a comment:
-
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... -
-
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...Leave a comment:
-
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....Leave a comment:
-
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',
Leave a comment:
-
How many sessions can I have at one time
I'm using this in a form:
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.Code:value='"; if (isset($_POST['title'])) echo $_POST['title']; echo "'
I'm not quite sure what to do at this point. I'm already using a login in session that keeps up with the... -
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...Leave a comment:
-
-
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. It's being sent byCode:$id = $_GET["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....Code:delete_picture.php?id=$id
No activity results to display
Show More
Leave a comment: