-
Posts
1,807 -
Joined
-
Last visited
Everything posted by hitman6003
-
Change your query to: [code]$query="select adddate('2006-02-01',interval $counter day)";[/code] With the single quotes on the outside, then using them again for the date, you were escaping the string, which would cause you to get an errror. If it had made it as far as your variable, it would not have replaced the $counter variable with it's value, as the single quotes cause it to take all text literally.
-
Well, since the error is happening in your included db.php file, there isn't anything we can do to help you fix your code. However, since the error plainly states that you can not connect to mysql through a socket, I would say you could probably fix this by not trying to connect to mysql through a socket.
-
Checking a variable against a number of values
hitman6003 replied to AbydosGater's topic in PHP Coding Help
There are lots of other ways. [!--quoteo(post=354205:date=Mar 12 2006, 11:11 AM:name=AbydosGater)--][div class=\'quotetop\']QUOTE(AbydosGater @ Mar 12 2006, 11:11 AM) [snapback]354205[/snapback][/div][div class=\'quotemain\'][!--quotec--] I find this very confusing, [/quote] in_array is probably the easiest, especially if you have more than 3 or 4 values that you are wanting to compare. Alternatives include using a very long if statement: if ($value == '1' || $value == '2' || $value == '3' etc...) { or using a switch statement: [a href=\"http://www.php.net/switch\" target=\"_blank\"]http://www.php.net/switch[/a] -
Uploading image to directory on my website
hitman6003 replied to brown2005's topic in PHP Coding Help
Please refer to the numerous tutorials on this site regarding file uploads, or look in the manual, there is several pages devoted to file uploads. [a href=\"http://www.php.net/manual/en/features.file-upload.php\" target=\"_blank\"]http://www.php.net/manual/en/features.file-upload.php[/a] [a href=\"http://www.phpfreaks.com/tutorials/36/0.php\" target=\"_blank\"]http://www.phpfreaks.com/tutorials/36/0.php[/a] -
[!--quoteo(post=354202:date=Mar 12 2006, 11:01 AM:name=Spixxx)--][div class=\'quotetop\']QUOTE(Spixxx @ Mar 12 2006, 11:01 AM) [snapback]354202[/snapback][/div][div class=\'quotemain\'][!--quotec--] But it still gets the same error... [/quote] Did you see the other things that I fixed...? Also, turn on error reporting to see exactly what your error is: [code]ini_set("display_errors", "1"); ini_set("error_reporting", "E_ALL");[/code]
-
Apparently your not passing a valid IP address to your gethostbyaddr function. There's no way we can help you beyond that point without seeing the code for at least that function.
-
To get the user's ip: [code]$ip = $_SERVER['REMOTE_ADDR'];[/code]
-
You had the file_name variable in your second form, and then Uploadedfile or something like that in your upload php code... [code] <?php $number = $_POST['number']; $submit1 = $_POST['submit1']; $submit2 = $_POST['submit2']; $folder = "upload/"; if(!$submit1){ echo "How many files are you uploading[?]<br><br>"; echo "<form action='$PHP_SELF' method='post'>"; echo "<input type='text' name='number' maxlength='1'>"; echo "<br>"; echo "<input type='submit' name='submit1' value='Create Form'>"; echo "</form>"; } if($submit1 == "Create Form"){ echo "<form action='$PHP_SELF' method='post'>"; for($x = 0; $x < $number; $x++){ echo "<input type='file' name='file_name$x'><br>"; } echo "<input type='hidden' name='number' value='$number'>"; echo "<input type='hidden' name='MAX_FILE_SIZE' value='1000000'>"; echo "<input type='submit' name='submit2' value='Upload'>"; echo "</form>"; } if($submit2 == "Upload"){ for($x = 0; $x < $number; $x++){ $file_name = $_FILES['file_name'. $x]['name']; $file_name = stripslashes($file_name); $file_name = str_replace("'","",$file_name); $copy = copy($_FILES['file_name'. $x]['tmp_name'],$file_name); if($copy){ echo "$file_name was uploaded"; } else { echo "$file_name | could not be uploaded!<br>"; } } } ?>[/code]
-
Create a js function: [code]<script type="text/javascript"> function selectpops(a) { var value = a.selectedIndex.value; var win = window.open("breaktype.php?value=" + value, 'Edituser', 'width=500,height=400,scrollbars=1'); } </script> echo "<select onchange=\"selectpops(this)\">"; echo "<option>--Select--</option>"; echo "<option value='C'>Coffee</option>"; echo "<option value='F'>Fag</option>"; echo "<option value='L'>Lunch</option>"; echo "<option value='O'>Others</option>"; echo "</select>";[/code]
-
You have very, very messy code. There were quite a few syntax errors that you would have seen if you had formatted the code even a little. Another major thing is to put quotes around all of your values for tags. I'm sure it was causing some sort of error that you didn't have them around the alt values for your img tags. It may be a pain, but it's necessary in most cases to put them there. Make sure to escape them using \ if they are within an echo statement that is opened and closed with double quotes, or use single quotes. Why are you passing the "num" variable around...I don't see you using it anywhere, except as something else to pass around in the url and retrieve from it. While I'm on the subject, it's good practice to use the array that defines where your variables are coming from, not just "REQUEST". It makes it easier for you to figure out what's going on with your code later on if something should go wrong. Beside that...does it really require any more brain power to use GET or POST? Make sure you read through the comments and compare what you had to what I have... [code] <?php $genre = $_POST['genre']; if ($genre == "") { $genre = $_GET['genre']; } $column = 'genre_id'; require_once ('../mysql_connect.php'); if(!isset($_GET['page'])){ $page = 1; } else { $page = $_GET['page']; } //results per page $max_results = 20; $from = (($page * $max_results) - $max_results); echo ' <table width="527" cellpadding="10"> <tr> <td><img src="tsearch.jpg" width="527" height="57"></td> </tr> <tr align="center"> <td> <table width="500" cellpadding="0" cellspacing="0"> <tr> <td><h1>Title</h1></td> <td><h1>Artist</h1></td> <td><h1>Album</h1></td> <td><h1>Votes</h1></td> <td align="right"><h1>Rating</h1></td> </tr>'; $query = "SELECT track_name, track_id, album_name, artist_name, rating_total, no_of_rating FROM trackcombo WHERE $column = '$genre' ORDER BY rating_total DESC LIMIT $from, $max_results"; $sql = mysql_query($query); while($row = mysql_fetch_array($sql)){ if ($bgcolor == "#E0DFE3"){ $bgcolor = "#FFFFFF"; }else{ $bgcolor = "#E0DFE3"; } $track_id = $row[1]; $alb = $row[2]; $art = $row[3]; $rating_total = $row[4]; $no_of_rating = $row[5]; echo ' <tr bgcolor="' . $bgcolor . '"> <td align="left" valign="middle"><span class="track"><a href="track.php?track_id= ' .$track_id . '">' . $row[0] . '</a></span></td> <td align="left"><span class="subtitle">' . $art . '</span></td> <td align="left"><span class="subtitle">' . $alb . '</span></td> <td align="left"><span class="subtitle">' . $no_of_rating . '</span></td> <td align="right"> <table width="70"> <tr> <td>'; if (($rating_total >= 0) && ($rating_total <= 0.99)){ echo "<img src=\"0.jpg\" alt=\"$rating_total of 5\" width=\"70\" height=\"18\">"; } if (($rating_total >= 1.00) && ($rating_total <= 1.99)){ echo "<img src=\"05.jpg\" alt=\"$rating_total of 5\" width=\"68\" height=\"14\">"; } //I'm going to remove all of your other if's for sake of my time and the size of the post, but follow the above examples to do them correctly...the primary thing being to put escaped quotes around your values...especially the alt tags. echo ' </td> </tr> </table> </td> </tr>'; } // find out number of results $result = mysql_query("SELECT COUNT(*) as Num FROM trackcombo WHERE ($column) = '$value'"); $total_results = mysql_result($result,0, 'Num'); //find out how many pages, round up $total_pages = ceil($total_results / $max_results); // Page number links echo " <tr align=\"center\"> <td colspan=\"5\"><h1>"; // back button if($page > 1){ $prev = ($page - 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev&genre=$genre\"> < </a> "; } //numbers of pages for($i = 1; $i <= $total_pages; $i++){ if(($page) == $i){ echo "$i "; } else { echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i&genre=$genre\">$i</a> "; } } // forward button if($page < $total_pages){ $next = ($page + 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next&genre=$genre\"> > </a></h1>"; } echo " </td> </tr> </table>"; //Where are you closing your mysql connection? ?>[/code]
-
[!--quoteo(post=353941:date=Mar 11 2006, 11:09 AM:name=AV1611)--][div class=\'quotetop\']QUOTE(AV1611 @ Mar 11 2006, 11:09 AM) [snapback]353941[/snapback][/div][div class=\'quotemain\'][!--quotec--] Ouch... [/quote] yeah...I'm a jerk... [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Hitman... At least the guy posted in the NEWBIE forum... not the regular forum...[/quote] Sometimes I forget which one I'm on.... I can only assume that you aren't posting all your code. What are you trying to limit...I know you said the number of jobs, but I don't see that value being defined anywhere. I'm guessing that you are trying to prevent them from adding another "watched job" if they are not at least a gold member...so you would need to do your limiting check before adding the job. I cleaned up your code below, but I still can't really make sense of what your trying to do. How are you adding the job to be watched? When they select it, and ask that it be watched for them, that's where you need to do your check for their membership level...then use an if statement to determine the action: [code]$sql = "SELECT watchedjobs FROM table WHERE username = '$username'; $result = mysql_query($sql); if (mysql_num_rows($result) > 25 && $member_level != 'Gold') { do whatever to disallow access } else { allow access }[/code] [code] <?php //if you are going to use a session, make sure you have session_start() at the top... /* //what's all this? SELECT membershipcategory.userid AS userid_1, login.userid, mydepartments.username, mydepartments.idcode, mydepartments.depid, membershipcategory.mem_id FROM ((mydepartments LEFT JOIN login ON login.username=mydepartments.username) */ //why are you doing this query? You don't use it anywhere. $query="SELECT COUNT(*) FROM 'username' AND 'DEPID'"; //you missed the closing quote and semicolon here $result = mysql_query($query); //= sets the value, == compares the values, use == in this case if ($mem_id == 1 && $username > 5 && $depid > 5) //don't put a semicolon here { //throw is not a php command, nor is exception...use die to do the same thing //throw new Exception('You have reached your limit of Departments to add'); die("You have reached your limit of Departments to add"); } //follow the same comments as above to fix this part if (mem_id=12 and (username AND depid >10); { throw new Exception('You have reached your limit of Departments to add'); } //I removed the block of code that was here cause it was the same as the first if statement //What's this? //if (depid='gold') then limit 25; //make sure you close your php tags before going back to html... //the code below here looks pretty good... ?> <form id="form2" name="form2" method="POST" action="<?php echo $editFormAction; ?>"> <label>depid</label> <label>username <input name="textfield" type="text" value="<?php echo $_SESSION['MM_Username']; ?>" /> </label> <p> <label> <input name="textfield2" type="text" value="<?php echo $row_rs_mydepartment['depid']; ?>" /> </label> <input type="submit" name="Submit" value="Submit" /> </label> </p> <input type="hidden" name="MM_insert" value="form2"> </form> [/code]
-
Try this: [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] Submissions.Submission_ID, Submissions.Conference_ID, Submissions.Subject_ID, Submissions.Title, Submissions.Summary, Submissions.Keywords, Submissions.Timestamp, forum_members.M_FIRSTNAME, forum_members.M_SURNAME, forum_members.M_NAME, forum_members.MEMBER_ID MATCH(Submissions.Title, Submissions.Summary, Submissions.Keywords) AGAINST ([color=red]'$searchstring'[/color]) [color=green]AS[/color] score [color=green]FROM[/color] [color=orange]Submissions[/color] [color=green]LEFT[/color] [color=green]JOIN[/color] forum_members on Submissions.MEMBER_ID [color=orange]=[/color] forum_members.MEMBER_ID [color=green]WHERE[/color] MATCH(Submissions.Title, Submissions.Summary, Submissions.Keywords) AGAINST ([color=red]'$searchstring'[/color]) [color=blue]AND[/color] Submissions.Conference_ID [color=orange]=[/color] [color=red]'$CurrentConfID'[/color] [color=green]ORDER BY[/color] score [color=green]DESC[/color] [!--sql2--][/div][!--sql3--]
-
[!--quoteo(post=353810:date=Mar 10 2006, 09:13 PM:name=abcabc)--][div class=\'quotetop\']QUOTE(abcabc @ Mar 10 2006, 09:13 PM) [snapback]353810[/snapback][/div][div class=\'quotemain\'][!--quotec--] I did refer to that manual beforehand, and used it to put together this code. Also, look at [a href=\"http://www.developershome.com/wap/detection/detection.asp?page=readHeader\" target=\"_blank\"]http://www.developershome.com/wap/detectio...page=readHeader[/a] and scroll down to header "Retrieving HTTP Headers with PHP" and you will see it listed as OK. [/quote] Fair enough...I never actually looked at all the elements in the server array before. On my home server, the value of that particular element is: [HTTP_ACCEPT_LANGUAGE] => en-us,en;q=0.5 So, I don't see any reason, off hand, why your code wouldn't work.
-
Have you ever used php before? I can't even begin to list the basic syntax errors that are in your code...no $ before your variables, your if statements are written, incorrectly, in pseudocode. Pretty much I can sum up your code in one word...FUBAR. Please read at least one tutorial on this website on the basics of php. Please read at least one tutorial [!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]anywhere[!--colorc--][/span][!--/colorc--] on the basics of php.
-
According to the manual, $_SERVER['HTTP_ACCEPT_LANGUAGE'] is not one of the predefined variables available. Refer to [a href=\"http://us2.php.net/manual/en/reserved.variables.php#reserved.variables.server\" target=\"_blank\"]http://us2.php.net/manual/en/reserved.vari...ariables.server[/a] to see which variables are available by default.
-
/single_A.php[!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]?[!--colorc--][/span][!--/colorc--]partnumber=100.01 The first variable in your url must be seperated from the file name by a question mark (?) not an ampersand(&).
-
[!--quoteo(post=353715:date=Mar 10 2006, 03:55 PM:name=adrianR)--][div class=\'quotetop\']QUOTE(adrianR @ Mar 10 2006, 03:55 PM) [snapback]353715[/snapback][/div][div class=\'quotemain\'][!--quotec--] People how can I get the number of field in a table? [/quote] mysql_num_fields -- Get number of fields in result [a href=\"http://www.php.net/mysql_num_fields\" target=\"_blank\"]http://www.php.net/mysql_num_fields[/a] to get the number of columns in a table: [code]$query = "SHOW COLUMNS FROM tablename"; $result = mysql_query($query); $colcount = mysql_num_rows($result); [/code] [!--quoteo(post=353715:date=Mar 10 2006, 03:55 PM:name=adrianR)--][div class=\'quotetop\']QUOTE(adrianR @ Mar 10 2006, 03:55 PM) [snapback]353715[/snapback][/div][div class=\'quotemain\'][!--quotec--] and how can i get the number of entrys in a field? [/quote] Not sure what you mean. You could do an sql query: [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] [color=blue]COUNT[/color](fieldname) [color=green]FROM[/color] [color=orange]tablename[/color] [color=green]WHERE[/color] fieldname ![color=orange]=[/color] NULL [color=blue]AND[/color] fieldname ![color=orange]=[/color] "" [!--sql2--][/div][!--sql3--] [!--quoteo(post=353715:date=Mar 10 2006, 03:55 PM:name=adrianR)--][div class=\'quotetop\']QUOTE(adrianR @ Mar 10 2006, 03:55 PM) [snapback]353715[/snapback][/div][div class=\'quotemain\'][!--quotec--] thanks in advance:) [/quote] Your welcome, afterward.
-
Javascript is "sandboxed" and has no interaction with your local computer's file system execpt through cookies, so there is no way to check with js. Use the getimagesize function: [code]list($width, $height, $type, $attr) = getimagesize("img.jpg"); $pixels = $width * $height; if ($pixels > $maxpixels) { do something } else { do something else }[/code]
-
Part of it, I think, depends on your browser, but you can't rely on your users having a specific browser. Another alternative would be to use javascript to set a cookie, then each time a field is changed, have the js set a value in the cookie. Then just have it retrieve the values from the cookie. However, if your collecting credit card data and other sensitive stuff, that would probably be a bad idea as well...which brings me back to what I originally suggested.
-
problems with loading a url to send a txt msg
hitman6003 replied to p_tru's topic in PHP Coding Help
Don't post usernames, passwords, or phone numbers in your posts. Echo out your $url variables to ensure that they are correct and that nothing is failing with those. I don't know where your located, but if it's in the US, you don't have enough numbers in the phone number to send the message...I'm sure since it's a url you'll need an area code. Come to think of it, you'll probably need to ad some additional numbers regardless of where you are. Local numbers will not work with something like that, you may even need a country code. -
If they hit the back button, there isn't anything you can do. However, if, in your code you determine that something is incorrect, you can direct them back to the form and fill in the fields for them with the values that were posted. In other words, rather than them going "back", they would continue "forward" with you determining what happens.
-
You may want to look at jpgraph: [a href=\"http://www.aditus.nu/jpgraph/index.php\" target=\"_blank\"]http://www.aditus.nu/jpgraph/index.php[/a] Specifically the canvas function.
-
How are you storing the responses for the nonregistered voters? Is each response a db entry (meaning lots of db entries), or does each response have a line, and a field on that line (hits) indicated how many times it's been answered (meaning one line for each reponse, with the responses counted in that line)?
-
Effeciently Pushing SQL Results into an array
hitman6003 replied to XenoPhage's topic in PHP Coding Help
Well, your query is probably going to fail, desc is a reserved word in SQL. Other than that, I don't think that you can really reduce that any more than it already is. Not sure what your hoping for. -
Using this: [code] <?php //$query = "SELECT * FROM nuke_fa_bids"; //$r = mysql_query($query) or die("Could not query: " . mysql_error()); //while ($row = mysql_fetch_array($r, MYSQL_ASSOC)) { $temp = array( Array('id' => '1','Team' => 'Cowboys','Player' => 'Chris Redman','Position' => 'QB','Years' => '2','Thousand' => '0','Million' => '1.2','Bthousand' => '.100','Bmillion' => '0','Fbid' => '0.7','ip' => 'xx.xx.xx.xx','user_name' => 'thecommish'), Array('id' => '2','Team' => 'Lions','Player' => 'Chris Redman','Position' => 'QB','Years' => '2','Thousand' => '0','Million' => '2.0','Bthousand' => '.500','Bmillion' => '0','Fbid' => '1.5','ip' => 'xx.xx.xx.xx','user_name' => 'thecommish'), Array('id' => '3','Team' => 'alpha','Player' => 'Ch Redman','Position' => 'QB','Years' => '2','Thousand' => '0','Million' => '2.0','Bthousand' => '.500','Bmillion' => '0','Fbid' => '1.0','ip' => 'xx.xx.xx.xx','user_name' => 'thecommish'), Array('id' => '4','Team' => 'bravo','Player' => 'Ch Redman','Position' => 'QB','Years' => '2','Thousand' => '0','Million' => '2.0','Bthousand' => '.500','Bmillion' => '0','Fbid' => '1.5','ip' => 'xx.xx.xx.xx','user_name' => 'thecommish'), Array('id' => '5','Team' => 'charlie','Player' => 'Ch Redman','Position' => 'QB','Years' => '2','Thousand' => '0','Million' => '2.0','Bthousand' => '.500','Bmillion' => '0','Fbid' => '2.5','ip' => 'xx.xx.xx.xx','user_name' => 'thecommish'), Array('id' => '6','Team' => 'delta','Player' => 'Chris Red','Position' => 'QB','Years' => '2','Thousand' => '0','Million' => '2.0','Bthousand' => '.500','Bmillion' => '0','Fbid' => '.5','ip' => 'xx.xx.xx.xx','user_name' => 'thecommish'), Array('id' => '7','Team' => 'echo','Player' => 'Chris Red','Position' => 'QB','Years' => '2','Thousand' => '0','Million' => '2.0','Bthousand' => '.500','Bmillion' => '0','Fbid' => '10.5','ip' => 'xx.xx.xx.xx','user_name' => 'thecommish') ); foreach ($temp as $row) { $player = $row['Player']; if (!$result[$player] || $result[$player]['bid'] < $row['Fbid']) { $result[$player]['bid'] = $row['Fbid']; $result[$player]['team'] = $row['Team']; $result[$player]['position'] = $row['Position']; } } $count = 0; echo ' <table border="1" cellpadding="3" cellspacing="0"> <tr> <th>Team</th> <th>Player Name</th> <th>Position</th> <th>Winning Bid</th> </tr>'; foreach ($result as $key => $value) { if (($count % 2) == "0") { $color = "D6CFCE"; } else { $color = "0000FF"; } echo ' <tr style="background-color:' . $color . ';"> <td align="left"><img src="images/smalllogos/'. $value[team] .'.gif"></td> <td align="center" class="boldblacktext">' . $key . '</td> <td align="center" class="boldblacktext">' . $value[position] . '</td> <td align="center" class="boldblacktext">' . $value[bid] . '</td> </tr>'; $count++; } echo '</table>';[/code] It works fine for me, so I'm at a loss.