-
Posts
1,469 -
Joined
-
Last visited
-
Days Won
12
Everything posted by CroNiX
-
Not quite because you didn't put quotes around the Saturday or Sunday strings in your comparisons.
-
$from should contain an actual email address on your server as well, or at least the correct domain. There are a lot of spam filters out there that won't accept just "From: Jarrod" where "From: email@this_site.com" would work, as long as "this_site.com" is the actual site name sending the email.
-
Need help with using session outside foreach loop
CroNiX replied to helloworld001's topic in PHP Coding Help
$userid = $_SESSION['userid'][]; What's the extra [] for? There isn't "a" user id. You said you wanted ALL user ids. $_SESSION['userid'] is now a string of comma separated IDs that now looks like: 1,2,5,6,7,8,[...]. But, your query below makes no sense. $stmt = $db->prepare("SELECT user_id FROM records WHERE user_id = :user_id"); So if the user_id is 1, you will just get back 1, which is what you started with. What's the point of that? I think you need to give us more of the big picture on what you're trying to accomplish with the code you're having problems with. -
Need help with using session outside foreach loop
CroNiX replied to helloworld001's topic in PHP Coding Help
if(count($result) > 0) { $ids = array(); //store ids in a separate array foreach($result as $row) { $ids[] = $row['user_id']; } $_SESSION['userid'] = implode(',', $ids); //turn the array of IDs into a comma separated string } -
Need help with using session outside foreach loop
CroNiX replied to helloworld001's topic in PHP Coding Help
$_SESSION['userid'][] = $userid; //add userid to array instead of overwriting it -
I need to add a check box that will change status of a record
CroNiX replied to kat35601's topic in PHP Coding Help
echo"<td><input class='cb' type='checkbox' name='short[]' value='$serial' </input></td>"; That's not a valid HTML input. There is no closing > at the end in the input, and you have </input> instead (which there is no such thing) -
For what you gave, you'd have 2 tables. Users and Schools. Each user would belong to a school. Schools -id -name Users -id -first_name -last_name -username -password -email -school_id (references "id" in Schools table) You wouldn't store the school name in the Users table like you suggested. You'd store it in the Schools table, and reference that schools ID in the Users table.
-
Also, in your loop, you aren't assigning any values to the <option>'s, so nothing will get sent with that field.
-
If you gave your <select> a name of "fruitid", did you get rid of the hidden form field with the name "fruitid"? <input type="hidden" value="<?php echo $fruitid;?>" name="fruitid"/>
-
Two errors with mysql_num_rows and mysql_fetch_array functions HELP ME
CroNiX replied to Sketro's topic in PHP Coding Help
Well, don't assume your query actually runs before continuing on. See the very first example in the documentation for mysql_query() for how to detect query errors. Also notice the big pink notice at the top of the page that says that the mysql extension is deprecated and will be removed from PHP soon. Best not to use it if you want your code to run in the future. -
{filename: "filename"} is the opposite of what it should be, as Barand pointed out. Compare his original code to what you have.
-
Also, you are kind of blind when running your queries. You don't check for an error and just assume it runs. How are you supposed to troubleshoot this if you don't see any errors? I'd really change this line: mysql_query($sql); to this: if ( ! mysql_query($sql)) { echo 'Invalid query: ' . mysql_error() . '<br><br>'; die("Query: $sql); } so it will show you the exact problem MySQL is complaining about. You can always tell your teacher how smart you are and checked the PHP manual how to show errors like the first example on the mysql_query() page.
-
Several things I see. You do your DB inserts without first checking to see if the form submitted. So whenever you load the page it will be trying to insert things into the db, whether or not you filled anything out on the form. The second thing is your genre checkboxes. Since they're checkboxes, many can be checked. You need to send those form values as an array, or only a single checkbox will be sent with your form (probably the last checked value). In order to submit it as an array, you'd need to add [] just after the NAME of that element. <input type="checkbox" name="genre[]" value="Urban">Urban After doing that, this will be an array: $i=$_POST["genre"]; If you only want ONE genre to be selected, use radio buttons instead of checkboxes. Or another <select>. How are you storing the genres in your db? That is not clear by the code you've provided. Can a movie have multiple genres?
-
I really don't know. If it's coming to/from the browser than most likely. I haven't used sockets like that so am really unsure. It does affect things like CURL requests, if the cert is self signed. You have to set extra options to ignore that, so it's entirely possible sockets might have something similar.
-
Self-signed certs are secure. They are just certs. The difference is they aren't VERIFIED by a 3rd party to ensure you (the website) are who you say you are. So modern browsers will yell about that. When getting a cert from godaddy or other 3rd party, they certify who you are and has been verified by a trusted source. http://webdesign.about.com/od/ssl/a/signed_v_selfsi.htm
-
Do you know how to make a <select> element, with <option>'s? You have no <options>. You're creating <select>$lname</select> over and over in a loop....but no options
-
What error? From what I can see you don't have $staffOpts defined anywhere.
-
No, see the documentation for jQuery's $post function. It's the "success" callback function and is already defined as part of $post.
-
Nothing to be sorry about. Really. While you are learning, I would just suggest starting with something a lot smaller with a lot less moving parts. You can't just walk in and build a house without knowing and understanding all of the underlying concepts, like first excavating, then building the foundation, plumbing, electrical, etc. Something like a "contacts" application, where you can created/edit/delete single contacts. Then after that's working, get a bit more complex, and allow for things like being able to have multiple children per contact (which would need a secondary db table, and using joins), etc. Start simple and expand it. The purpose of this site isn't to write code/applications for people. It's to help them with individual problems they are having with their own code, when they run into it.
-
How to get variable in another page and submit/update in database
CroNiX replied to Tasos's topic in PHP Coding Help
You're not linking to your index.php script, which is where I presume you are trying to do your update code? example.com/index.php?url=... -
I'm sorry to be blunt and at the risk of offending you, the problem is this project is way over your head right now and you don't seem to want to accept that. You don't understand what the code is doing. You're just copy/pasting code that Barand has been more than generous in writing FOR YOU, but then you just post back that it doesn't work when you try and expect him to come to the rescue. Again, that's because you don't understand the underlying code. Most of these problems you should be able to sort out yourself, or take the code Barand has supplied and alter it to your needs. This is a fairly complex project for someone just starting out. Most wouldn't be able to do it with your level of PHP knowledge. I'm not trying to put you down. I just don't think your coding skills are to a level where you could do this fairly complex project. What would you do if Barand wasn't here to write it for you? I haven't seen much of your own code in here...just what Barand is writing.
-
How can one images in a format like Google images?
CroNiX replied to helloworld001's topic in PHP Coding Help
It's just a bunch of divs containing the images, with the divs having the css of display: inline-block. Just view the source code or use your browsers developer tools so you can hover over something on the page and see it's HTML/CSS. -
Checking if value exists in database. Getting error.
CroNiX replied to cloudll's topic in PHP Coding Help
Your query failed, but you have no code in place to check for it. Never a good idea to just assume everything is fine. You need to check for errors. $sql=mysql_query("SELECT FROM banned (id, ip) WHERE ip=$user_ip"); //will return FALSE if failed query if ( ! $sql) { //query failed, handle it, display mysql error, etc. } But I bet the problem is you don't have quotes around $user_ip in your query. As a side note, you'd be a lot better off using PDO or MySQLi database extensions. The original MySQL extension is deprecated and will be removed from PHP very soon, so you'd have to rewrite all of your DB code. Best to use current extensions.