Jump to content

atticus

Members
  • Posts

    176
  • Joined

  • Last visited

Everything posted by atticus

  1. When I hit the submit button, it enters information from the second two fields, but does not display the first field, which is <select> input. It displays the information from the database in the form and submits fine with no errors. if(isset($_POST['add'])) { $username = $_POST['username']; $title = $_POST['title']; $video = $_POST['video']; $query = "INSERT INTO upload2 (cust_id, video_title, video) VALUES ('$username', '$title', '$video');"; mysql_query($query) or die('Error, insert query failed' . mysql_error()); echo "<b>Thank you! Video Added Successfully!<br />You will be redirected in 4 seconds"; echo "<meta http-equiv=Refresh content=4;url=index.php>"; } else { ?> <form method="post" action="<?php echo $PHP_SELF ?>"> <select name="username" id="username"> <?php $sql = "SELECT * FROM cust"; $query = mysql_query($sql); while($myrow = mysql_fetch_array($query)) { echo "<option>".$myrow['cust_id']."</option>"; } ?> </select><br /> Title: <input type="text" name="title" id="title"><br /> Video: <textarea name="video">Paste Embed Code Here</textarea><br /> <input name="add" type="submit" id="add" value="Add Video"></td> <?php } ?>
  2. I think it is, this is the link from the other page: echo "<div><b>Username:</b> ".$row['cust_id']." | <a href=\"cust_edit.php?id=$row[cust_id]\">Edit User</a><br />"; The cust_id is also showing in URL
  3. The page is blank. It is called to edit info in database. The form is not showing up at all. When I enter text before the first IF statement it does show up. When I echo in the elseiff section, I still get a blank page. When I echo "(" .$result.")"; I get a blank, not even any paranthesis <?php session_start(); // is the one accessing this page logged in or not? if (!isset($_SESSION['db_is_logged_in']) || $_SESSION['db_is_logged_in'] !== true) { // not logged in, move to login page header('Location: login.php'); exit; } ?> <html> <body> <?php include("config.php"); if(isset($_POST['submit'])) { $name = mysql_escape_string($_POST['name']); $password = mysql_escape_string($_POST['password']); $result = mysql_query("UPDATE cust SET cust_id='$name', cust_password='$password' WHERE cust_id ") or die('Error, query failed : ' . mysql_error()); echo "<b>Thank you! User UPDATED Successfully!<br />You will be redirected in 4 seconds"; echo "<meta http-equiv=Refresh content=4;url=index.php>"; } elseif(isset($_GET['cust_id'])) { $result = mysql_query("SELECT * FROM cust WHERE cust_id='$_GET[cust_id]' ") or die('Error, query failed : ' . mysql_error()); while($myrow = mysql_fetch_assoc($result)) { $name = $myrow['cust_id']; $password = $myrow['cust_password']; ?> <br> <h3>::Edit User</h3> <form method="post" action="<?php echo $PHP_SELF ?>"> Name: <input name="title" size="40" id="title" maxlength="255" value="<? echo $name; ?>"> <br> Password: <textarea name="description" id="description" rows="7" cols="30"><? echo $password; ?></textarea> <br> <input type="submit" name="submit" value="Update"> </form>" <?php }//end of while loop }//end else ?> </body> </html>
  4. The page is blank. It is called to edit info in database. The form is not showing up at all. When I enter text before the first IF statement it does show up. When I echo in the elseiff section, I still get a blank page. When I echo "(" .$result.")"; I get a blank, not even any paranthesis <?php session_start(); // is the one accessing this page logged in or not? if (!isset($_SESSION['db_is_logged_in']) || $_SESSION['db_is_logged_in'] !== true) { // not logged in, move to login page header('Location: login.php'); exit; } ?> <html> <body> <?php include("config.php"); if(isset($_POST['submit'])) { $name = mysql_escape_string($_POST['name']); $password = mysql_escape_string($_POST['password']); $result = mysql_query("UPDATE cust SET cust_id='$name', cust_password='$password' WHERE cust_id ") or die('Error, query failed : ' . mysql_error()); echo "<b>Thank you! User UPDATED Successfully!<br />You will be redirected in 4 seconds"; echo "<meta http-equiv=Refresh content=4;url=index.php>"; } elseif(isset($_GET['cust_id'])) { $result = mysql_query("SELECT * FROM cust WHERE cust_id='$_GET[cust_id]' ") or die('Error, query failed : ' . mysql_error()); while($myrow = mysql_fetch_assoc($result)) { $name = $myrow['cust_id']; $password = $myrow['cust_password']; ?> <br> <h3>::Edit User</h3> <form method="post" action="<?php echo $PHP_SELF ?>"> Name: <input name="title" size="40" id="title" maxlength="255" value="<? echo $name; ?>"> <br> Password: <textarea name="description" id="description" rows="7" cols="30"><? echo $password; ?></textarea> <br> <input type="submit" name="submit" value="Update"> </form>" <?php }//end of while loop }//end else ?> </body> </html>
  5. I want to query the database and return the username once for each record while returning all the files associated with the cust_id. I am using two while loops, but it is not working. Any suggestions: $sql = "SELECT * FROM upload2 ORDER BY cust_id"; $query = mysql_query($sql); while($myrow = mysql_fetch_array($query)) { echo "".$myrow['cust_id']."<br />"; while($row = mysql_fetch_array($query)) { echo "<a href=\"view.php?id=$row[id]\">".$row['title']."</a><br />"; echo "<br />"; } } I am not getting any errors, its only displaying the last record in the database.
  6. I am having problems with this query: $username = $_POST['username']; $password = $_POST['password']; $query = "INSERT INTO cust (cust_id, cust_password) VALUES ('$username', PASSWORD('$password');"; mysql_query($query) or die('Error, insert query failed' . mysql_error()); Error: Error, insert query failedYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
  7. You guys are both correct, if you haven't noticed, I am very new to PHP and server scripting in general. I took your advice and dropped the $_GET and used $_SESSION. I am still using the while loop because it simply works like a catalog, only the "products" are delivered based on the user name which acts like a categories field. I don't know if this is the best solution, it just happens to be the only solution I have come up with so far: Added to login.php $_SESSION['user_id'] = $userId; I changed my query to this... $sql = "SELECT * FROM cust where cust_id = '{$_SESSION['user_id']}'"; I would like to know the best/standard way to accomplish this and drop while loop. Thanks for the advice on debugging, that is what helped me solve this issue
  8. I am not getting any more errors but echo still doesn't work.
  9. thanks...however I am getting a syntax error: line: $query = mysql_query($sql) of die (mysql_error()); nevermind...found the error: of needs to be or
  10. When user logs in, needs to be redirected to customized page for that user login.php: session_start(); $errorMessage = ''; if (isset($_POST['txtUserId']) && isset($_POST['txtPassword'])) { include 'config.php'; $userId = $_POST['txtUserId']; $password = $_POST['txtPassword']; // check if the user id and password combination exist in database $sql = "SELECT user_id FROM tbl_auth_user WHERE user_id = '$userId' AND user_password = PASSWORD('$password')"; $result = mysql_query($sql) or die('Query failed. ' . mysql_error()); if (mysql_num_rows($result) == 1) { // the user id and password match, // set the session $_SESSION['db_is_logged_in'] = true; // after login we move to the main page header('Location: index.php'); exit; } else { Session on index page: <?php session_start(); // is the one accessing this page logged in or not? if (!isset($_SESSION['db_is_logged_in']) || $_SESSION['db_is_logged_in'] !== true) { // not logged in, move to login page header('Location: login.php'); exit; } ?> This is the echo: <?php include("config.php"); $sql = "SELECT {$_GET['user_id']} FROM table_auth_user"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { echo "".$row['user_id'].""; echo "<br /></div>"; } ?> error message: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in
  11. I am getting this error from the previous code Fatal error: Call to undefined function: mysql_real_escape_chars() in
  12. I could have named user_id, user_name; I have two tables...one table contains the user authentication and the other one contains file info. Both tables contain the field user_id When the admin uploads a file, she has the option to select a user from a drop down menu. When that user logs in, the user will only be able to see the files associated with their name I don't understand how to display just that user's info based on their login. Do you need to see the login page?
  13. database structure: field: user_id varchar(primary) field: password char <?php session_start(); // is the one accessing this page logged in or not? if (!isset($_SESSION['db_is_logged_in']) || $_SESSION['db_is_logged_in'] !== true) { // not logged in, move to login page header('Location: login.php'); exit; } ?> <?php include("config.php"); $sql = "SELECT " . $_GET['user_id'] . " FROM table_auth_user"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { echo "".$row['user_id'].""; echo "<br /></div>"; } ?>
  14. oops: error on above query: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in .././..//
  15. I would like to display the database info based on the user's login. I am getting the following error: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' Code: $sql = "SELECT $_GET['user_id'] FROM table_auth_user"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { echo "".$row['user_id'].""; echo "<br /></div>"; }
  16. I can't find the error: Error, query failed : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') VALUES ('album1.jpg', '38916', 'image/pjpeg', 'album1.jpg', '' $title = $_POST[title]; $cust = $_POST[cust_id]; $query = "INSERT INTO upload2 (name, size, type, path, title, cust_id,) ". "VALUES ('$fileName', '$fileSize', '$fileType', '$filePath', '$title', '$cust')"; mysql_query($query) or die('Error, query failed : ' . mysql_error()); it seems to come after "'$filePath',"
  17. For the option box; this is what I came up with: <form method="post" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="2000000"> <label> <select name="cust_id> <?php $sql = "SELECT * FROM cust"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { echo "<option>".$row['cust_id']."</option>"; } ?> </select> <label>Title:</label><input type="text" name="title" id="title"><br /><br /> <label>File:</label><input name="userfile" type="file" id="userfile"><br /><br /> <label></label><td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "> </form> However, this looks promising for retrieving the info: However, i am not sure how to use it. How do I associate the user name with the file when they are in two different tables? Do I do it on the upload or in the results?
  18. I need help building a an option box. Basically, the admin will select a user from one table and upload files to another table. When that user logs in, they should be able to see those files that are associated with their name. However, I do not know the best way to do it. I would post my code, but I think I am going about the wrong way. Any suggestions on how to do this would be greatly appreciated. This is how my table structures are laid out table_cust field: cust_id field: password table_upload: field:id fields: (file info) field: cust_id
  19. I am adding this to my script: ini_set('post_max_size','500M');//Upload up to 500 Megabytes ini_set('upload_max_file_size','500M');//Upload up to 500 Megabytes Where is the best place to put it?
  20. I am trying to upload videos to the server with a form using php. The address of the video is stored in mysql. It is not functioning properly. It works fine for images, but is not uploading the videos. $uploadDir = 'upload/'; if(isset($_POST['upload'])) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $filePath = $uploadDir . $fileName; $result = move_uploaded_file($tmpName, $filePath); chmod($filePath, 0755); if (!$result) { echo "Error uploading file"; exit; } if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); $filePath = addslashes($filePath); } mysql_connect($db_host, $db_user, $db_pwd); mysql_select_db($db_name); $query = "INSERT INTO upload2 (name, size, type, path, title, description, buy, sort) ". "VALUES ('$fileName', '$fileSize', '$fileType', '$filePath', '$_POST[title]', '$_POST[description]', '$_POST[buy]', '$_POST[sort]')"; mysql_query($query) or die('Error, query failed : ' . mysql_error()); any suggestions...
×
×
  • 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.