Jump to content

IS there ANY reason why my DB should only partially work?


WilliamNova

Recommended Posts

I'm really not sure what's going on with my database. But it was working 100% fine a week ago. But some of it does work, such as, I can login to my website BUT I cannot register new accounts. I can't subscribe to other users and I can no longer upload photos, videos, etc.

 

I guess, in other words, I can only login.

 

But I haven't altered the code on most of these pages, just the video and image upload pages, so if it were code the registration page should work fine and the subscribe.

 

So I'm curious, is there any reason why the database would only partially work?

 

If it helps, phpMyAdmin did update on its own recently, around the same time some stuff stopped working.

I'm also using XAMPP and only running Apache and MYSQL.

Link to comment
Share on other sites

You may have accidentally altered your user's DB permissions so that you can only SELECT, not INSERT/UPDATE/DELETE. Do some debugging to find out why those things are not working. Add some error reporting code if you don't already have it, and look at the error message that you are receiving from mysql and see what it says.

Link to comment
Share on other sites

I put in some error reporting code and it returned nothing. But then I noticed in my database in the tables there's this snippet of code

SELECT *
FROM `subscriptions`
LIMIT 0 , 30

So, like you said, it's only allowing SELECT (or so I assume)

How can I change this to allow more than SELECT?

Link to comment
Share on other sites

Here's a pic. It's at the very top of every table in my database.

 

phpmyadmin_zps110073d0.png

 

 

Sorry if I'm not explaining this well. I'm new to databases.

 

Also, I went through my permissions for phpmyadmin users. I had all permissions checked for the user I'm using and just to be sure I granted all permissions to all users and still nothing.

Edited by WilliamNova
Link to comment
Share on other sites

i don't use phpmyadmin, but that is just the query it used to display the output on that tab when you browse to any particular table.

 

as kicken stated, you need to troubleshoot what your code IS doing in order to find what is causing the problem. just telling us code doesn't work is pointless as that doesn't pin down which of the 10 or so possible things that could be causing any one symptom, to the one thing that is causing it in your case.

 

you need to find out why your code doesn't allow you to register a new account. how do you know you cannot register a new account? what output or symptom are you getting? what execution path is your code taking? what are the data values your code is actually using as inputs? which comparisons/loops are working? which are not?

 

if you want us to help troubleshoot or even give specific hints of things to try or test, you must post the relevant code, as there are multiple different ways of accomplishing anything in programming. without seeing what your code/data/queries are, there is not one simple answer that will 'fix' your problem base on the symptom of "it's not working".

Link to comment
Share on other sites

The thing is, I haven't changed the code AND it worked fine before. phpmyadmin update itself at some point, I never really thought that it would have any effect, so never bothered to make sure information was still submitting. But once I made my video upload page and tried uploading a video, it never appeared in the database BUT I still got my "Success" page. I thought it was my code, redid it, but still nothing.

 

Then I tried my photo upload page which hadn't been touched since I completed it and tested it. It didn't work. BUT still got the "Success" page. Likewise for my registration. However, my login page works, I can login. All those codes haven't been altered in any way since I completed and tested them. That's why I believe it's not the code.

 

Anyways, here's my video upload page code, at the least the PHP side of it.

<?php
include ('./includes/header.php');

if (isset($_FILES['video'])) {
  $title = $_POST['video_title'];
  $desc = $_POST['video_description'];
  $keywords = $_POST['video_keywords'];
  $privacy = $_POST['privacy'];
  if (!empty($title) || ($desc) || ($keywords) || ($privacy)) {
    $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
   $video_id = substr(str_shuffle($chars), 0, 15);
   $video_id = md5($video_id);
  }
  else
  {
   die('empty fields');
  }
   if (($_FILES['video']['type']=='video/mp4')) {
   $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
   $random_directory = substr(str_shuffle($chars), 0, 15);

   if (file_exists('data/users/videos/' . $random_directory . ''.$_FILES['video']['name'])) {
     echo 'video exists';
   }
   else
   {

   move_uploaded_file($_FILES['video']['tmp_name'],'data/users/videos/' . $random_directory . ''.$_FILES['video']['name']);
   $img_name = $_FILES['video']['name'];
   $filename = "data/users/videos/".$random_directory.$_FILES['video']['name'];
   $md5_file = md5_file($filename);
   $check_md5 = mysql_query("SELECT file_md5 FROM videos WHERE file_md5='$md5_file'");
   if (mysql_num_rows($check_md5) != 0) {
     unlink($filename);
    die("This is a duplicate upload");
   }else {
     $date = date("F j, Y");
   $insert = mysql_query("INSERT INTO videos VALUES ('','$title','$desc','$keywords','$user','$privacy','$date','0','$video_id','')");
   mysql_query("UPDATE videos SET file_md5='$md5_file' WHERE video_id='$video_id'");
   die("<h2>Success!</h2><br />
		Please allow up to 15 minutes for your video to be visible to all users.<br /><br />
		<a href='upload.php'>Upload another</a><br />
		<a href='members.php'>Go home</a>");
   }
   }
   }

}
?>
Edited by WilliamNova
Link to comment
Share on other sites

you are outputting the 'success' message without checking if the insert query even worked and why are you running an additional update query instead if just inserting the file_md5 data in the insert query?

 

at a minimum, you need some error checking logic to test if the query ran without any errors and for debugging purposes to display any query error if there is one -

// i'm going to guess that last field value listed is for the $md5_file value. you should use the INSERT syntax that lists the field names
$insert = mysql_query("INSERT INTO videos VALUES ('','$title','$desc','$keywords','$user','$privacy','$date','0','$video_id','$md5_file')");
if(!$insert){
    // the query failed due to an error, do some debugging
    die(mysql_error());
} else {
    // the query ran without any errors
    die("<h2>Success!</h2><br />
        Please allow up to 15 minutes for your video to be visible to all users.<br /><br />
        <a href='upload.php'>Upload another</a><br />
        <a href='members.php'>Go home</a>");
}
Link to comment
Share on other sites

 

you are outputting the 'success' message without checking if the insert query even worked and why are you running an additional update query instead if just inserting the file_md5 data in the insert query?

 

at a minimum, you need some error checking logic to test if the query ran without any errors and for debugging purposes to display any query error if there is one -

// i'm going to guess that last field value listed is for the $md5_file value. you should use the INSERT syntax that lists the field names
$insert = mysql_query("INSERT INTO videos VALUES ('','$title','$desc','$keywords','$user','$privacy','$date','0','$video_id','$md5_file')");
if(!$insert){
    // the query failed due to an error, do some debugging
    die(mysql_error());
} else {
    // the query ran without any errors
    die("<h2>Success!</h2><br />
        Please allow up to 15 minutes for your video to be visible to all users.<br /><br />
        <a href='upload.php'>Upload another</a><br />
        <a href='members.php'>Go home</a>");
}

 

 

You're really like the most helpful guy in this entire community.

 

The mysql error was "Column count doesn't match value count at row 1"

At first I thought it was because I left "id" blank, which didn't make sense to me as its set to AI. But then I counted my columns in phpmyadmin (11). But my script was only inserting 10. Once I added the missing column it worked.

Link to comment
Share on other sites

this error is another good reason to always list the columns in the insert query syntax. the syntax you are using requires that you provide a value for every column in the table and that you know the order of the columns in the table so that the data doesn't get inserted into the wrong columns.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.