Jump to content
xisto Community
Sign in to follow this  
nightfox1405241487

Problems With A Database Table & PHP Syntax

Recommended Posts

Yup that missing semicolon would surely give you the same error. So you need to check for them. Do you use an editor that supports syntax highlighting and brace (paranthesis) matching - I use one and that helps be cut down the errors by half - right when I'm doing the first pass.

Share this post


Link to post
Share on other sites

New errors:
If I add a semi colon to line 24:
Line 24:

if ( mysql_num_rows ( $result ) == 1 ) {

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/coco563/public_html/test_page.html on line 24

Semi-colon in Line #24, bracket on a new line:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/coco563/public_html/test_page.html on line 24
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/coco563/public_html/test_page.html on line 28

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/coco563/public_html/test_page.html on line 31

Well, at least there are new errors which is a good sign that we're getting close!

Btw, m^e, I asked for those two books for Christmas, not sure if I'll get 'em but hey, worth a shot!

[N]F

Share this post


Link to post
Share on other sites

It would help to add the AUTO_INCREMENT attribute to the ID field, plus I noticed that they suggested to make a connection.php file kind of like the config.php file in the little tutorial that the link lead to, but he is going to have to use PHP and not HTML for what all he is trying to do.MySQL would help just by learning a few basics like creating databases and tables and adding the structure of the tables. The tutorial was how to create a database driven tutorial site. I just glanced over it and it would at least get you started, but it does start out by assuming that you have a basic knowledge of MySQL and PHP.

Share this post


Link to post
Share on other sites

Several things:1) The id isn't a number. When the page is created, you specify the ID. So in a string, the id is in the URL, page.html?id=<idHere>2) With .htaccess magic, .html is parsed as .php :huh:3) I do have basic knowledge of PHP and MySQL... except I am VERY weak on the MySQL side of things! I've worked mostly in PHP and never really used databases before.[N]F

Share this post


Link to post
Share on other sites

New errors:

If I add a semi colon to line 24:

Line 24:

if ( mysql_num_rows ( $result ) == 1 ) {

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/coco563/public_html/test_page.html on line 24

 

 


Wait a second - this error probably means, your $result doesn't contain a valid MySQL ResultSet - which means, you query might have never been executed. You need to check the database parameters. Where are you using this code ? Your local database or at Xisto ? Depending on that you might need to change your database name and database username.

 

 

Semi-colon in Line #24, bracket on a new line:

 

Well, at least there are new errors which is a good sign that we're getting close!

 

Btw, m^e, I asked for those two books for Christmas, not sure if I'll get 'em but hey, worth a shot!

 

[N]F

1064333355[/snapback]


As for the bracket on same line or next, wouldn't really matter - but I think your semicolon is again misplaced.

 

See, the structure of an if statement is as follows:

if ( expression ) {    code......     ...........}else{  code......   ............}

OR

 

if ( expression ) {    code......     ...........} else {  code......   ............}

You can see that the placement of braces won't really matter - but what will matter is if you place the semicolon after the if statemnt. For example:

if (expression); {

....

}

 

will give you grave errors - as semicolon is a command terminator. If you place the semicolon after the if statement - the expression if simply evaluated and left at that.. the following branched code, which is supposed to be executed depending on the evaluation of the if expression - will never get associated with it - as the statement has ended even before reaching that block.

 

Anyway, all your errors are on the lines of: Warning: ..... supplied argument is not a valid MySQL result resource in - which clearly indicates that the $resource variable doesn't contain the correct connection resource id - causing the following statement to execute incorrectly.

 

As I mentioned aboved, you need to check the connection settings - and do let me know where your database is situated. I might be able to give you some hints if I know that.

Share this post


Link to post
Share on other sites

Ok, just to see what would happen, I moved the files over to Xisto. I fixed one thing I found in the code that I overlooked and fixed it here too...
http://forums.xisto.com/no_longer_exists/
In Firefox, all you see on the page is:



I've tried several things but it just grinds to a hult at whatever that is.
Also, I've noticed that in both databases (the one on Xisto and on my other server) it seems to contain "0 rows" and the MySQL user accounts are given full access to each database too... pherhaps it is my script that is supposed to enter the data is making an error? I think this because you can't "browse" the database like you can with any other database... it appears "empty"

[N]F

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.