What Am I Doing Wrong?

So…I made a site in 2012 and it had a MySQL database with tables and whatnot…well, 3 years later, I’m back to revive it, but I totally forget how to fully get it working again.

My question is:
On this page (http://zardians.com/newpost.php) if you just click “Add new post,” it’ll give this error:
[php]Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in /home4/namehere/public_html/global.php on line 15[/php]

So I go to my global.php file and this is line 15:
[php]function fetch($query) { return mysql_fetch_row(mysql_query($query)); }[/php]

Here’s the full code:
[php]

table th { background-color: #111; } table td { background-color: #000066; padding: 0px; } a { color: #FFCC00; } <?php $db = mysql_connect('localhost:3306', 'database_name', 'password'); $db = mysql_select_db("database_name"); function fetch($query) { return mysql_fetch_row(mysql_query($query)); } ?>[/php]

^This only shows 12 lines because I took out unneeded spacing^

Hi, you should be using mysqli instead of mysql. Do you not receive any errors on your webpage?

I suspect a production website would have all the warnings turned off. MySQL has changed quite a bit since then!

Perhaps have a look at using a database abstraction which will take the headache out of wondering whether the core functions will work.

Dibi or cde4php will do fine.

Ummmm, well, in 2012 I did it how I did it this time I believe. Just imported my .sql file to my Database to create my tables. Then just uploaded the .php files to my main index or whatever on the site.
You can see the error when you go to the link I posted above, then click “add new reply.”
But also: In 2012, I was able to create forums from my Database and I could actually make a reply, then it would bring the user back to the thread after submitting the reply…I basically coded my own forum from scratch. It was basic, but it was awesome to me. I’m having trouble replicating what I did back then because I forgot how to do it all, haha.
The .php and .sql files are all ones I had in my E-Mail from 2012 when I first built it.

(see above post).
Hmm…I could show my SQL file? Because when I import it to my database, I got errors, but then if I refresh the database page, it imports the tables anyway.

Another issue is when a user entered their name on the make a post/reply pages, it would be logged on the database, as well as their password in encrypted form…however, nothing gets logged anymore either.

Send me ALL the files and DB SQL and I will look at it.

It works. I think you for got to pass the fid in $_GET;

viewforum.php?fid=1

Your code is completely outdated and obsolete and insecure… You really need to do a complete re-write.

So what and where exactly do I change it to be able to do that?
On the viewpost.php page on the site, there’s an error near the top.

EDIT: In 2012 I also had a “users” table that logged each username in the database…how could I make that table again?

I cant help you put up bad code and no one else should either. Learn PDO or at the least Mysqli and prepared statements.

I have provided a download of a PDO bump start database in my signature link to get you going.

Once you have current code we will be happy to help you.

  • It sounds like you need to start learning coding from the beginning. Take some time and go through some PDO tutorials and CSS layout. You dont use tables to lay out a page.

So you couldn’t update the .php and .sql files if I paid, then I’d use those for future reference?

I am willing to re-write what you have to current code.

Sponsor our Newsletter | Privacy Policy | Terms of Service