Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 23rd, 2006, 1:58 PM   #11
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
First of all, I suggest you change your root password: having it blank is a huge security risk.

What operating system are you on?
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Apr 23rd, 2006, 2:03 PM   #12
piercy
Programmer
 
Join Date: Apr 2006
Posts: 35
Rep Power: 0 piercy is on a distinguished road
mac 10.4 and i know that its a risk but im not going to be creating anythign for the web yet im only just familiar with the basics(as you probably noticed). i know how to change it i think but i cant see too much of a point at the moment. at the moment im a bit confused why i am getting that error message. a friend said about the use of spaces in field names so ive changed that and ive also tried using strings rather than variables just to test but i constantly get the same error as above.
__________________
this forum rules you guys are great!
thanks to all who help
piercy
piercy is offline   Reply With Quote
Old Apr 23rd, 2006, 2:07 PM   #13
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Thought as much, but I wasn't sure. You need to find out what user your web server is using, and make sure it has the privileges to read the file specified:
/var/mysql/mysql.sock
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Apr 23rd, 2006, 2:10 PM   #14
piercy
Programmer
 
Join Date: Apr 2006
Posts: 35
Rep Power: 0 piercy is on a distinguished road
how do i do that? and i tried to naviagate to the mysql folder but it said it didnt exist.
__________________
this forum rules you guys are great!
thanks to all who help
piercy
piercy is offline   Reply With Quote
Old Apr 23rd, 2006, 3:27 PM   #15
clive
Newbie
 
Join Date: Apr 2006
Location: London, EU
Posts: 3
Rep Power: 0 clive is on a distinguished road
I'm clueless about PHP, but there isn't a reference to a database in there to start off with, only a table, try:

INSERT INTO databasename.messages ...

If you have some data in the table already try:

SELECT * from databasename.messages;

Where "databasename" is the real name of the database that you have listed in Navicat.

To get to /var/mysql/ just type cmd-shift-g in the Finder, you'll get a dialogue box, then type in "/var/mysql/" (to access this via a menu, in the Finder pull down the "Go" menu and select "Go to Folder").

To see the permissions on "mysql.sock" select it in the Finder and type cmd-i, the user privileges are shown at the bottom.
clive is offline   Reply With Quote
Old Apr 23rd, 2006, 3:32 PM   #16
piercy
Programmer
 
Join Date: Apr 2006
Posts: 35
Rep Power: 0 piercy is on a distinguished road
yes i did the go to folder thing earlier and it says it does not exist. i added the database anme in there and still same error as above. whats going on with this folder?
__________________
this forum rules you guys are great!
thanks to all who help
piercy
piercy is offline   Reply With Quote
Old Apr 23rd, 2006, 3:36 PM   #17
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Hmmz... perform a search for mysql.sock using the administrator account - let's find out where this bugger is.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Apr 23rd, 2006, 4:26 PM   #18
piercy
Programmer
 
Join Date: Apr 2006
Posts: 35
Rep Power: 0 piercy is on a distinguished road
i have done that. ive got remote assistance for now and they are going to search tomorrow. so hopefully it will be sorted by tomorrow if not i will probably post about 6 tomorrow (GMT).

thanks for your help
__________________
this forum rules you guys are great!
thanks to all who help
piercy
piercy is offline   Reply With Quote
Old Apr 24th, 2006, 10:29 AM   #19
clive
Newbie
 
Join Date: Apr 2006
Location: London, EU
Posts: 3
Rep Power: 0 clive is on a distinguished road
Fixed

Ok, I think I fixed this, there's still one minor problem with your code, but I'll get to that at the end.

The mysql.sock is actually at:

/tmp/mysql.sock

Which explains why PHP couldn't connect to it. The fix is to edit the php.ini file which is at:

/etc/php.ini

Well, except that by default there is no php.ini, so you have to take the /etc/php.ini.default, duplicate and rename it to php.ini. Then go to the line:

mysql.default_socket =

and change it to:

mysql.default_socket = /tmp/mysql.sock

Then restart Apache (turn off personal web sharing in the system preferences/sharing, then turn it back on again).

All this is done now.

Not sure why your system was messed up like this, because it was working ok, must have been some change between MacOS X versions.

Another way to achieve the changing of the socket connection location is in your PHP code. Take this line:

$link = mysql_connect("localhost","guest","password");

And change it to:

$link = mysql_connect("localhost:/tmp/mysql.sock","guest","password");

It's better to change the php.ini file though, because with the above method you'd have to specify the socket in every connection in your code/solution.

Right, the final problem is that your date input is ending up as "0000-00-00 00:00:00" when you look at it in MySQL via Navicat. There are two reasons for this, one is that your default value in MySQL is "0000-00-00 00:00:00" and the second is that the variable you are trying to input is not in MySQL date format.

MySQL date format is '2006-04-24 14:53:10" ie:

(four digit year)-(two digit month)-(two digit day) (24 hour two digit):(two digit minute):(two digit second)

In reality it's actually ok to input: 2006-4-1 14:5:2 rather than 2006-04-01 14:05:02. But you can see that it still follows approximately the same format.

Your date looks like this:

$date = date('l dS F Y at h:i:s A');

Which I think means that it looks like this:

"Monday 24th April 2006 at 3:07:03 PM"

Which is great for you to be able to read, but is invalid for the MySQL field type you are trying to put it into. So, you can either: change the field type, or change the formatting.

Tip: if you change the field type you won't be able to sort on that column in any way that makes any sense, and you won't be able to search for date ranges - which makes that type of input not a lot of use for a database.
clive is offline   Reply With Quote
Old Apr 24th, 2006, 10:44 AM   #20
clive
Newbie
 
Join Date: Apr 2006
Location: London, EU
Posts: 3
Rep Power: 0 clive is on a distinguished road
And there are some clues here:

http://uk.php.net/manual/en/function.date.php
clive is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:47 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC