Jump to content

kasitzboym

Members
  • Posts

    26
  • Joined

  • Last visited

Everything posted by kasitzboym

  1. You know what i figured figured it out... i dont know why but it didnt like the number in the if statement i changed it to this and i had the variable set like $size = $_FILES["upload"]["size"]; i just type it like that when i was on here... but changing it to a variable seamed to have worked... ill have to do more reading on it maybe it is a bug in PHP they haven't found yet or something... But Anyway thanks for the help!!! $size = $_FILES["upload"]["size"]; $max_file_size = 1024000; if($size > $max_file_size){ echo'entered if statement<br />'; } else{ echo'entered else statement<br />'; }
  2. Thanks but im having more trouble with this than i am with my if else statement... If i take out the statement and just echo $_FILES["upload"]["size"] then it prints out the file size every time its just when i have it in an if statement that it has trouble. Any other ideas? i really would like to use this setup.
  3. I am trying to check to see if a file size is acceptable before an upload but cant seem to get the right result no matter what i do. if i have my if statement below coded like this if($_FILES["upload"]["size"] < 1024000){ echo'entered if statement<br />'; } else{ echo'entered else statement<br />'; } Then i always am entereing the if statememnt but if i have my if statement like this if($_FILES["upload"]["size"] > 1024000){ echo'entered if statement<br />'; } else{ echo'entered else statement<br />'; } then i always seem to enter the else staement. I have tried with a VIREITY of differnt size files some from like 2kb to 10mb... i believe somewhere near the > or < is my problem but i dont seem to see it
  4. Hey guys there is probably a simple fix to this but i am just not seeing it ... Im createing a form that has error catching and self submitting valuse. I am trying to use a for loop to create all of the values and if the form is returned with an error then the correct values will still be filled out but i cant seem to get this loop to work. Every time i submit the form it doesnt matter what option i select it always comes back with the last one in the list or 30 in this case. the problem code is below.. Any help would be appreciated. <?php for($i=1; $i<=30; $i++){ echo'<option value="'.$i.'"'; if(isset($_POST['petsAge'])== $i){ echo ' selected="selected"';} echo '>'.$i.'</option>'; } ?>
  5. That kind of makes since. Although i am kind of lost on the syntax that you are explaining do you mean someting like this? <?php require("includes_database/mysqli_connect.php"); //$query="SELECT * FROM phpbb_topics WHERE (forum_id='13' OR forum_id='14') AND topic_status = '0'"; //$query2="SELECT * FROM phpbb_topics WHERE (forum_id='15' OR forum_id='16') AND topic_status = '0'"; $query="SELECT * FROM phpbb_topics WHERE (forum_id='13' OR forum_id='14')"; $query2="SELECT * FROM phpbb_topics WHERE (forum_id='15' OR forum_id='16')"; $result=mysqli_query($dbc, $query); $result2=mysqli_query($dbc, $query2); $num = mysqli_num_rows($result); $num2 = mysqli_num_rows($result2); echo''.count($num).'<br>'; echo''.count($num2).'<br>'; echo "<table border=1 cellpadding=2>"; echo "<tr><td>Lost</td><td>Found</td></tr>"; while(($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) && ($row2 = mysqli_fetch_array($result2, MYSQLI_ASSOC))) { echo'<tr>'; if ($row){ while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){ echo "<td width='15%'><a href=/sahbb/viewtopic.php?f=".$row['forum_id']."&t=".$row['topic_id'].">".$row['topic_title']."</a></td>"; } } if($row2){ while($row2 = mysqli_fetch_array($result2, MYSQLI_ASSOC)){ echo "<td width='15%'><a href=/sahbb/viewtopic.php?f=".$row2['forum_id']."&t=".$row2['topic_id'].">".$row2['topic_title']."</a></td>"; } } echo'</tr>'; } echo "</table>"; mysqli_free_result($result); mysqli_free_result($result2); mysqli_close($dbc); ?>
  6. This seems to have returned the same result as my version. ManiacDan I will try this however i would like to keep a single table with two columns instead of splitting them up They are currently using the same div tag as they are both in a marque that scrolls.
  7. Hey everyone I've been working on converting my old mysql code to to the mysqli version and am running into some trouble. I am pulling posts form phpbb and displaying them in a script. My first script below works just fine. <?php require("connect.php"); $query="SELECT * FROM phpbb_topics WHERE (forum_id='13' OR forum_id='14') AND topic_status = '0'"; $query2="SELECT * FROM phpbb_topics WHERE (forum_id='15' OR forum_id='16') AND topic_status = '0'"; $result=mysql_query($query); $result2=mysql_query($query2); echo "<table border=0 cellpadding=2>"; echo "<tr><td>Lost</td><td>Found</td></tr>"; while($row=(mysql_fetch_array($result)) || $row2=(mysql_fetch_array($result2))) { $forum_id=mysql_result($result,$k,"forum_id"); $topic_id=mysql_result($result,$k,"topic_id"); $topic_title=mysql_result($result,$k,"topic_title"); $forum_id2=mysql_result($result2,$k,"forum_id"); $topic_id2=mysql_result($result2,$k,"topic_id"); $topic_title2=mysql_result($result2,$k,"topic_title"); echo "<tr><td width='15%'><a href=/sahbb/viewtopic.php?f=$forum_id&t=$topic_id>$topic_title</a></td> <td width='15%'><a href=/sahbb/viewtopic.php?f=$forum_id2&t=$topic_id2>$topic_title2</a></td> </tr>"; $k++; } echo "</table>"; mysql_close($connect); ?> however its not very clean or memory efficient so i have converted it to the following. <?php require("includes_database/mysqli_connect.php"); $query="SELECT * FROM phpbb_topics WHERE (forum_id='13' OR forum_id='14')"; $query2="SELECT * FROM phpbb_topics WHERE (forum_id='15' OR forum_id='16')"; $result=mysqli_query($dbc, $query); $result2=mysqli_query($dbc, $query2); echo "<table border=1 cellpadding=2>"; echo "<tr><td>Lost</td><td>Found</td></tr>"; while(($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) || ($row2 = mysqli_fetch_array($result2, MYSQLI_ASSOC))) { echo "<tr><td width='15%'><a href=/sahbb/viewtopic.php?f=".$row['forum_id']."&t=".$row['topic_id'].">".$row['topic_title']."</a></td> <td width='15%'><a href=/sahbb/viewtopic.php?f=".$row2['forum_id']."&t=".$row2['topic_id'].">".$row2['topic_title']."</a></td> </tr>"; } echo "</table>"; mysqli_free_result($result); mysqli_free_result($result2); mysqli_close($dbc); ?> I know the error is in my while loop but i cant seem to figure out exactly where. The new code displays all of the first query in the table and then below that it displays the next query insted of displaying them side by side below would be an example of what is happening [table Lost Found Lost, Australian Sheppard [/td] Lost German Shepherded / Collie Mix Lost Golden Retriever/Cocker Mix Lost Female Grey Tiger Lost Pitbull Mix Lost 2 Chihuahua Lost Black Lab Lost - German Shepard Mix and Lab Mix Lost - Female German Sheperd Aprox 8 Week Old Kitten Found! 2 Pugs FOUND Found 1 Corgi female/ 1 Shih Tzu male Found Tan and Black Australian Shepard Found Australian Shepard [td]Found Intact Male Pitbull/Lab Mix Any help that any of you could provide would be greatly appreciated!
  8. While working hard at trying to figure this out, I DID! Just for anyone who wants future reference here is what I did. I had my table separated into id--INT---auto Increment--just a unique id number event--TEXT--- title of the event to be displayed month--INT--- month event happens in day--INT---- day event happens in display--TEXT--- actual text to display on the site I figured it would be easier to read out the individual cells instead of an actual formatted date because im not yet familiar with it. I then looped through all of the rows to put it into an array and while inside the While loop i created an if statement that compared the month of the browser to the month colume of the table in MySQL. I then echoed the text in the display cell in the table into the website. <?php require("connect.php"); $sql="select * from yearly_anouncements"; $result=mysql_query($sql, $connect); $i=0; $monthd = date("n"); // if($monthd = "$month"){ while ($row=(mysql_fetch_array($result))) { $id=mysql_result($result,$i,"id"); $event=mysql_result($result,$i,"event"); $month=mysql_result($result,$i,"month"); $day=mysql_result($result,$i,"day"); $display=mysql_result($result,$i,"display"); $i++; if($monthd == "$month"){ echo "".$row['display'].""; } } ?> Thanks for the help anyway everyone!!
  9. Hello, I hope someone can help me out with this as i am out of ideas. I was trying to use today's date to display a message based on the information pulled from a MySQL database. As of right now i have it displaying absolutely everything in the database which is not what i want. Below is what i have so far to display at least something. <?php require("connect.php"); $sql="select * from yearly_anouncements"; $result=mysql_query($sql, $connect); $i=0; $month = date("m"); if($month = "07"){ while ($row=(mysql_fetch_array($result))) { $id=mysql_result($result,$i,"id"); $event=mysql_result($result,$i,"event"); $month=mysql_result($result,$i,"month"); $day=mysql_result($result,$i,"day"); $display=mysql_result($result,$i,"display"); echo "".$row['display'].""; $i++; } } ?> Right now i want it to pull in anything to do with the month of JULY which right now is just the phrase for INDEPENDENCE DAY! could anyone help me figure out where i am going wrong? Thanks in advance.
  10. Thanks for the advice... Ive looked over the Session commands but dont quite understand how they work... could someone help me to understand how to pull that username from the current session
  11. Sorry i dont quite understand... This is getting a little more advanced than im used to do you think you might be able to explain it a little to me please?
  12. Hi everyone... I have kind of a complicated problem that i hope someone can help me with. I have a registration section of my site already up and running... i am trying to create another section of my site so that the user that is logged in can create a posting and link it to their username.... currently i have two tables in a mysql database one named (users) to hold the username and password that i want to pull the username from and another that holds the information for posting called (laf).... My basic question is how can i pull the username from the (users) database and place it into the (laf) database when they post? This is a really hard thing to explain i know, if anyone can help or needs any more information let me know... Thanks in advance
  13. Hey Thanks ALOT!!!! That worked perfectly!!!
  14. Sorry i forgot it doesnt post numbers.... It is the very last line in the code with </html>
  15. Hey thanks for the help... i now have a code for registration of new users on my website although i am receiving an error that i cannot find. The error i am recieveing is Parse error: syntax error, unexpected $end in C:\xampp\htdocs\sahnew\Final\session tracking\register.php on line 137 The code i have written that has the error is below. <?php session_start(); include 'db.inc.php'; $db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD) or die ('Unable to connect. Please contact the webmaster.'); mysql_select_db(MYSQL_DB, $db) or die(mysql_error($db)); $state_list = array('AL, AK, AZ, AR, CA, CO, CT, DE, FL, GA, HI, ID, IL, IN, IA, KS, KY, LA, ME, MD, MA, MI, MN, MS, MO, MT, NE, NV, NH, NJ, NM, NY, NC, ND, OH, OK, OR, PA, PR, RI, SC, SD, TN, TX UT, VT, VA, WA, WV, WI, WY'); //filter incomming values $username = (isset($_POST['username'])) ? trim($_POST['username']) : ''; $password = (isset($_POST['password'])) ? trim($_POST['password']) : ''; $first_name = (isset($_POST['first_name'])) ? trim($_POST['firstname']) : ''; $last_name = (isset($_POST['last_name'])) ? trim($_POST['last_name']) : ''; $email = (isset($_POST['email'])) ? trim($_POST['email']) : ''; $city = (isset($_POST['city'])) ? trim($_POST['city']) : ''; $state = (isset($_POST['state'])) && is_array($_POST['state']) ? $_POST['state'] : array(); $zip = (isset($_POST['zip'])) ? trim($_POST['zip']) : ''; if(isset($_POST['submit']) && $_POST['submit'] == 'Register') { $errors = array(); //make sure manditory fields have been entered if(empty($username)) { $errors[] = 'Username cannot be blank.'; } //check if username already is registered $query = 'SELECT username FROM users WHERE username = "' . $username . '"'; $result = mysql_query($query, $db) or die(mysql_error()); if (mysql_num_rows($result)>0) { $errors[] = 'Username' .$username. ' is already registered.'; $username = ''; } mysql_free_result($result); if(empty($password)) { $errors[] = 'Password cannot be blank.'; } if(empty($first_name)) { $errors[] = 'First name cannot be blank.'; } if(empty($last_name)) { $errors[] = 'Last name cannot be blank.'; } if(empty($email)) { $errors[] = 'Email address cannot be blank.'; } if(count($errors) > 0) { echo '<p><Strong style="color:#FF000;">Unable to process your '.'registration.</strong></p>'; echo '<p>Please check the following errors:</p>'; echo '<ul>'; foreach ($errors as $error) { echo '<li>' .$error. '</li>'; } echo '</ul>'; } else { // No errors so enter the information into the database. $query = 'INSERT INTO users (user_id, username, password) VALUES (NULL, "' . mysql_real_excape_string($username, $db) . '", '.'PASSWORD("' . mysql_real_excape_string($password, $db) . '"))'; $result = mysql_query($query, $db) or die(mysql_error()); $user_id = mysql_insert_id($db); $query = 'INSERT INTO user_info (user_id, first_name, last_name, email, phone, city, state, zip) VALUES (' . $user_id. ' , ' . '"' .mysql_real_excape_string($first_name, $db) .'", ' . '"' .mysql_real_excape_string($last_name, $db) .'", '. '"' .mysql_real_excape_string($email, $db) . '", '. '"' .mysql_real_excape_string($phone, $db) . '", '. '"' .mysql_real_excape_string($city, $db) . '", '. '"' .mysql_real_excape_string(join(', ', $state),$db) . '", '. '"' .mysql_real_excape_string($zip, $db) . '")'; $result = mysql_query($query, $db) or die(mysql_error()); $_SESSION['logged'] = 1; $_SESSION['username'] = $username; header('Refresh: 5; URL=main.php'); ?> <html> <head> <title>Register</title> <style type="text/css"> td{ vertical-align: top;} </style> </head> <body> <form action="register.php" method="post"> <table> <tr> <td><label for="username">Username:</label></td> <td><input type="text" name="username" id="username" size="20" maxlength="20" value="<?php echo $username; ?>"/></td> </tr><tr> <td><label for="password">Password:</label></td> <td><input type="password" name="password" id="password" size="20" maxlength="20" value="<?php echo $password; ?>"/></td> </tr><tr> <td><label for="email">Email:</label></td> <td><input type="text" name="email" id="email" size="20" maxlength="50" value="<?php echo $email; ?>"/></td> </tr><tr> <td><label for="first_name">First name:</label></td> <td><input type="text" name="first_name" id="first_name" size="20" maxlength="20" value="<?php echo $first_name ?>"/></td> </tr><tr> <td><label for="last_name">Last name:</label></td> <td><input type="text" name="last_name" id="last_name" size="20" maxlength="20" value="<?php echo $last_name ?>"/></td> </tr><tr> <td><label for="city">City:</label></td> <td><input type="text" name="city" id="city" size="20" maxlength="20" value="<?php echo $city ?>"/></td> </tr><tr> <td><label for="state">State</label></td> <td><select name="state[]" id="state" multiple="multiple"> <?php foreach ($state_list as $states){ if(in_array($states, $state)) { echo '<option value="'.$states.'" selected="selected">' .$states . '</option>'; } else { echo '<option value="'.$states.'">'.$states.'</option>'; } } ?> </select></td> </tr><tr> <td></td> <td><input type="submit" name="submit" value="Register"/></td> </tr> </table> </form> </body> </html> If anyone can help me find the error i would greatly appreciate it
  16. Yes i have had experience with PHP and MYSQL... i am not actually looking for someone to write my code just someone to point me in the right direction
  17. I could use some help with creating a website login page with registration for new users. My goal is to create a page that uses mysql with php for people to post information to the database and delete it later... The actual Goal is to create a Lost and Found page for an Animal Hospital. This page Clients will create posts and it will display on the main page then only those clients or the administrator will be able to delete the posts.
  18. Alright i seam to be having some trouble with my code and i dont understand where it is hanging or why the code i have in staffmember.php is <?php require("connect.php"); $first=$_GET['first']; $last=$_GET['last']; $sql="select * from staff WHERE firstname=$first, lastname=$last"; $result=mysql_query($sql, $connect); while $row=(mysql_fetch_array($result)) { $id=mysql_result($result,"id"); $title=mysql_result($result,"title"); $firstname=mysql_result($result,"firstname"); $lastname=mysql_result($result,"lastname"); $bio=mysql_result($result,"bio"); $yearbegan=mysql_result($result,"yearbegan"); $imagename=mysql_result($result,"imagename"); echo "$firstname $lastname $bio $yearbegan }; ?> and the error it is giving me in the web browser is Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in C:\xampp\htdocs\sahnew\Final\staffmember.php on line 20 Line 20 is while $row=(mysql_fetch_array($result)) { Any ideas?
  19. Could you explain this part of the code for me... I haven't seen this format before $result=mysql_query($sql, $db); Thanks
  20. The url actually worked exactly like i wanted it and does display example.com/staff.php?name=BobJones So the url that its linking to doesn't actually have any problems i just have no idea how to display the information that is in the MYSQL database. I was told i have to put it into an array and use the $_GET[] function but i have no idea how to do that with mysql
  21. Hey everyone, Thanks in advance for any help i may get on this topic. I am trying to take the information from a table on MYSQL database and display the information, depending on the link in the URL, on the page. I have already created a page called staff.php I would like to take this page and display all of images of the staff members in the MYSQL database on this page with the images being link, this i have no problem with. I would then like to created it so that when they click on the staff members image then it will replace the entire page's information with the current staff members information that they have selected with the url showing their name such as example.com/staff.php?name=bob all of the code i have that already works is displayed below. Could someone help me with this as i need to finish this for the website to be posted online in a timely manner. staff.php <?php require("connect.php"); $query="SELECT * FROM staff"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $title=mysql_result($result,$i,"title"); $firstname=mysql_result($result,$i,"firstname"); $lastname=mysql_result($result,$i,"lastname"); $bio=mysql_result($result,$i,"bio"); $yearbegan=mysql_result($result,$i,"yearbegan"); $imagename=mysql_result($result,$i,"imagename"); echo "<a href=\staffmember.php?name=$firstname$lastname><img src=\"staffpicturesthumb/$imagename\" width=\"150\" height=\"200\" /></a> <br>"; $i++; } ?> Once again thanks for any help in advance!!!
  22. I apologize for not putting the tags around the code i will do that this time... As for the information not working... I can put staff.php in the url and it places the The Staff Member Does Not Exist text on the page which is correct but i have 9 staff members in the mysql database table called staff... when i place staff.php?id=1 it desplays the first member in the table but when i place the id=2, id=3 and so on it still only displays the first staff members information on the page. The page connect.php actually has the errors enabled and does not show any errors with the code. Once again i will place the code i am trying to use that i am having problems with <?php require("connect.php"); $id = ($_GET['id']); $query="SELECT * FROM staff"; $result=mysql_query($query); mysql_close(); $result = mysql_fetch_array($result); $id=$result['id']; $firstname=$result['firstname']; $lastname=$result['lastname']; $bio=$result['bio']; if (isset($_GET['id'])) { echo "$firstname <br> $bio "; } else { echo "The Staff Member Does Not Exist"; } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.