jcbones
Staff Alumni-
Posts
2,653 -
Joined
-
Last visited
-
Days Won
8
Everything posted by jcbones
-
The only thing I see wrong, is your are sending the index "flag" in the $_GET array, but checking for it in the $_POST array. You are also appending it to an query string, but should be using an ampersand(&) instead of another question mark(?).
-
Hey, how did I miss the whole first part of the OP. It would accept dd-mm-yyyy or dd.mm.yy. Both of which could be fixed with a simple str_replace.
-
Is $dayoff a proper unix timestamp? Because, that is what the second parameter of date requires. If you are using a formatted date, then you need to use strtotime on it. However, as has been stated, don't store your date in the database this way, as you will lose all functionality of working with dates in the database. You should just cast the date to your desired output via the correct database functions.
-
If you want to make sure it returns images only, use: (using cmb's code). $dir = "path/to/directory/*.[pPjJgG][nNpPiI][gGfF]"; //case insensitive, gets only jpg, JPG, png, PNG, gif, GIF files. foreach(glob($dir) as $file){ //only displays files no subdirectorys echo "<a href='http://www.google.com' target='_blank'><img src='".$file."' width='570' height='270 alt='slide' /></a><br />"; }//close file check }//close foreach
-
You can have queries in the page, you just can't echo the results. The results must be sent to the image generator. So, if you want the query in the data variable. $query = mysql_query(" SELECT domain, COUNT(domain) AS domaincount FROM domaindata WHERE email_sent_date = '' GROUP BY domain"); while($run = mysql_fetch_array($query)) { $data[] = $run['domaincount']; } is the date_email_sent really suppose to be blank?
-
You cannot use an image header on any page you wish to echo text to. That must be done on a different page. When you send something with the header content as an image, then the whole document is treated and interpreted as an image. PHP's default header content type is 'text/html', that is why you don't have to set it for a regular page. If we had a clearer understanding of what you are trying to do, we could walk you through it.
-
Insert Checkbox Values Into Table As Delimited String
jcbones replied to acidking's topic in PHP Coding Help
I'm glad that people told(tell) me when I was(am) doing things wrong. Coding issues seem non-existant now. The best things I have learned since being told "you're doing it wrong": Database Normalization, Relational Database Design, Logical Programming, and... wait for it... forum sarcasm!!! -
You could use a separate table for an admin password for a certain user(s) linked by a foreign key. It adds a little bit of security. Of course, you can have a column in the users table that specifies if the users have a certain level of access.
-
Why Fetch_Assoc() Or Fetch_Row() Giving Error Always
jcbones replied to vishalonne's topic in PHP Coding Help
if($stmt = $mysqli -> prepare("SELECT * FROM $tbl_name1 WHERE confirm_code=?")) { $stmt -> bind_param("s", $passkey); //bind param. $stmt -> execute(); //execute the query. $stmt->bind_result($temp_firstname,$temp_lastname,$temp_sex,$temp_phone); //bind results. $rows = $stmt->fetch(); //fetch results. $count=$stmt->num_rows; //count of rows. echo "\n".$count; // getting the value 1 which is correct if($count==1) //if count is equal to 1 { echo $temp_firstname . ', ' . $temp_lastname . ', ' . $temp_sex . ', ' . $temp_phone; //echo the bound variables. } This should work. (should as in this excerpt). -
There are a number of reasons this could happen. You need the users that it is happening to, to give you the exact details (page, what they click, etc), to trouble shoot this problem. It could be anything from data collision (hashes), or a database query, or lack of database normalization. But, this will require extensive testing to find what causes it.
-
Some Advise On Editing This Code Please....
jcbones replied to roldahayes's topic in PHP Coding Help
Normalized data will always give normal results. Abnormalized data, will always give abnormal results. Things you need to look at: Database Normalization Join queries Looking at your current table, it should probably be 3 tables. -
Tree Menu From Database - 3 Levels (2 Records On First Level)
jcbones replied to wasssu's topic in PHP Coding Help
You need to line up the data, when it comes from the database, correctly. I would start with ordering it sorted by the parent ascending. Then I would sort that into an array, matching the id's to the parent. Finally, I would go through that array, and build the menu. -
I was simply showing how the array was built, and that you couldn't just output an implode to get your desired results. You should be looking at something along the lines of: <?php $player = array("Tim","Joe","Ben"); // The players who scored. $count = array("1","2","2"); // The number of trys the player had scored. $combine = array_combine($player, $count);//combine players to scores. foreach($combine as $names => $count) { //loop through the combined array. $store[] = $names . (($count > 1) ? '(' . $count . ')' : NULL ) . ' '; //optionally you could echo this line, but I stored it so I could add a comma with implode. } $result = implode(', ',$store); //implode the store array, using a comma and space as the glue. echo $result; //send it to the page. ?>
-
Run this: <?php $player = array("Tim","Joe","Ben"); // The players who scored. $count = array("1","2","2"); // The number of trys the player had scored. $combine = array_combine($player, $count); $result = implode($combine); echo '<pre>' . print_r($combine,true) . '</pre>'; ?>
-
You should probably be using mysqli::multi_query()
-
So the table is really a calendar in a table format. You would need to check the database date against the display date, if it doesn't exist then you would write an empty row.
-
Are you sure they are the same person? Try: $numbers = array(0,15,30,45,60); $actual_time = 16; foreach($numbers as $n) { if($n > $actual_time) { $time = $n; break; } }
-
You should have a separate table in your database with your handouts info. This should also have a week number, and a group number. Then join the data together, and get the current handouts. <-it may not be real clear, I'm losing it lately -- -- Table structure for table `handouts` -- CREATE TABLE IF NOT EXISTS `handouts` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(20) NOT NULL, `img_location` varchar(20) NOT NULL, `group` varchar(5) NOT NULL, `week` int(11) NOT NULL, PRIMARY KEY (`id`) ) You can join this table to your user table with a query similar to this: $sql = "SELECT a.name AS handout_title FROM `handouts` AS a JOIN user AS b ON a.group = b.group AND a.week = b.week WHERE b.username = '$user_data[first_name]'"; You could take it a lot further than that, and your database should be normalized (or it WILL run into problems), as data shouldn't be redundant. It will lead to collisions and produce undesired results. Things you could do. Use a base time subtracted from the current time to automatically find the week number. If you stored the group numbers as class numbers (2013) instead of a varchar (grp13), then you could get rid of the redundant blocks you have written and change it to: <?php require_once('../../includes/logged_in/li_overall/li_mid.php'); ?> <!--Class Welcome Message...... --> <div id="right_middle"> <h1>Welcome y <?php echo $user_data['first_name'];?>!</h1> <p>You have been assigned to Class of <?php echo $user_data['group']; ?>....</p> </div> <?php require_once('../../includes/logged_in/li_overall/li_footer.php'); ?> I know I went beyond what you asked for, so if I confuse the situation, I apologize.
-
Basic cross domain/server calls, how to do it?
jcbones replied to brentman's topic in PHP Coding Help
Basic cross domain server calls is called HTTP request. You would handle it just like any other form submission. If it were me, and other people were calling my domain for specific requests (like you describe), I would write an API for the purpose. 1. User from site A submits form to site A 2. Site A request a check from site B 3. Site B validates request, and outputs status of request. 4. Site A checks response from B, and outputs desired results. You shouldn't need anything other than file_get_contents() if fopen wrappers are on, or cURL if you need more functionality. Then you need to debug the script, and find out why it does that. Hope this helps, if you give a little current code, I could probably be more helpful. -
Whats the question?
-
Or, you could get it free from White Hat through their simpleImage class. Its a little dated, but works well.
-
Good grief, I gave the answer in the first reply. Maybe it needs a repeat, and/or clarification. preg_match /*<===== if that is really in your script, you need to remove it...*/ if (preg_match('^' . $stored_referer . '$', $temp[2])) $found = true; Read the comment, look at where it is pointing. If that "preg_match" really resides as the first line of your IF clause, then remove it, it is invalid syntax as it is a function call without arguments.
-
preg_match /*<-if that is really in your script, you need to remove it... */ if (preg_match('^' . $stored_referer . '$', $temp[2])) $found = true;
-
Mine too, Psycho, mine too.