Put the command: error_reporting[E_ALL]; at the very top of the program, once you have all the errors debugged then change it to error_reorting[0]; anytime you neeed to debug change it back to E_ALL . E_ALL tells it to show you all errors no matter how small. A beginner should NOT be ignoring any errors.
.
Just realized, you pull author into a field called random_tags but you never do use it any where.
.
Yeah, thats for something a little further along the line, when it comes to adding new recipes to the DB via a form on the site.
Playing with the code you posted now, shall report back in a little while, thank you again for your help with this php stuff, I really appreciate your time and assistance
$title = ucwords($row['recipename']);
//Personal taste, but I like titles like that. The above makes each first character of a word uppercase: This Is A Great Title
$description = ucfirst($row['recipedescription']);
//Makes the first character of your string uppercase (in case it isn't stored that way in the database. It looks pretty bad in the search results if your description's first letter isn't uppercase.
Apologies for the late response, we lost power again last night while they were working on the lines to try and get the rest of the neighborhood up and running.
I played with the code you posted and seem to be getting a weird error where the data from the SQL isn't showing, its just giving me a blank page and there are no meta tags showing up either. (Didn't change anything until after the blank page showed).
Putting back the original code, the page works how it is supposed to, any thoughts?
Sorry about that. I didn't do a full test and that kind of shit happens when you meld 2 different sets of code together.
In this case, I grabbed my dbcreds file from my local machine and my hookup routine from a different place.
But that is what debugging is for, ya know?
I really didn't think you were just going to switch out to the new code I posted, I was just trying to get to a code set that made sense to me.
.
No apologies needed, I'm learning so figured grabbing your code was the easiest way to figure out what I'm actually fucking up on my end of things and having a 'working' code (that doesn't on occasion) is a good way for me to screw around and check what isn't working and why
I'm really appreciative of everyone's help, assistance and knowledge in this thread as I'm sure you all have other things you could be doing instead of sharing your expertise.
return new PDO("mysql:host=$dbhost;dbname=$dbname;charset=utf 8" ,$dbuser,$dbpass,array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
Also, a quick question sarettah, what is the purpose of having the charset=utf8 in there? Wont it do the same thing without that? Just pull the databases name, or is that a security thing?
Also, a quick question sarettah, what is the purpose of having the charset=utf8 in there? Wont it do the same thing without that? Just pull the databases name, or is that a security thing?
Your error: /blah/blah/domain.com/recipesnew.php(118): PDO->__construct('mysql:host=loca...', NULL, NULL, Array)
indicates that you are not passing in a username or password. The places that say NULL, NULL right before the Array indicate that $dbuser and $dbpass are coming in as NULL meaning there ain't nothing there.
Your error: /blah/blah/domain.com/recipesnew.php(118): PDO->__construct('mysql:host=loca...', NULL, NULL, Array)
So, if you are using the dbcreds.php file then the problem is in there. If you are not using that and have the user and password hardcoded then that would be where the issue is.
The charset=utf8 just tells it to accept utf8 characters. The routine I pulled it from has to handle various different languages. I pretty much have everything I do coded for utf8 (unicode).
$id=intval($_GET['id']);
if($id==0)
{
header( "Location: index.php" ); //or any other page like 404
exit;
}
As intval will also output 0 if $id is empty.
Yep, that would work.
I tend to, when trying to do code 101 stuff use old old school. First step intialize variable to default value then use it.
But yeah you are initializing it to whatever comes into the get if it is a valid int or zero if not so it does the same thing in a couple of less words.
indicates that you are not passing in a username or password. The places that say NULL, NULL right before the Array indicate that $dbuser and $dbpass are coming in as NULL meaning there ain't nothing there.
Okay, I think it has something to do with this part at the bottom of the coding (my version)...
{
require_once('dbcreds.php');
return new PDO("mysql:host=$dbhost;dbname=$dbname;charset=utf 8" ,$username,$password,array(PDO::ATTR_EMULATE_PREPA RES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
}
So, if you are using the dbcreds.php file then the problem is in there. If you are not using that and have the user and password hardcoded then that would be where the issue is.
Because I tried changing the dbpassword part and it still shows a blank page, I know 100% the information in the dbcreds.php is correct and there was a mismatch of the naming, which I (think) I corrected? Or does that entire string need to be included in quotation marks like this...
The code you are posting looks right The bottom part you posted at the end where you moved the quote marks is wrong.
The part of the error you are showing us indicated that there is nothing in the username and password variables which would mean the problem is in the dbcreds.php like I said earlier.
I just want to say thank you for all of your help, not only in this thread over the past week but also by PM, you truly do not know how appreciative I am of your time helping me to get this pet project working, I'm sure there are a hundred other things you could have been doing this afternoon instead of spending time to get this working for me.
I'm going to play around with a couple of other formatting issues that I'm having but other than that, I am really happy with how this site has turned out, even though its just a pet project of mine and not really going to be a money maker its good to start seeing it come to fruition
Comment