|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
SQL/PHP integration NOOB QUESTION
so I now know SQL database manipulation code, and I know PHP.
how do i establish connection to a SQL database from a PHP script, so i can manipulate the database from the PHP page/script? surprisingly could not find on W3. but maybe i missed something. thanks in advance |
|
#2
|
||||
|
||||
|
mysql_connect(), mysql_select_db(), mysql_query(), mysql_fetch_array(), mysql_num_rows(). Those should get you started. See the manual for details.
And I'm sure there's a lot of info on the subject in the WWW. There should be a basic database tutorial here at Codewalkers, too.
__________________
Fight Internet censorship! Code:
() ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments |
|
#3
|
|||
|
|||
|
AH, looking at PHP manual mysql_query allows usage of SQL code. such as insert and select statements; is this correct?
Last edited by WiscoLinks : January 3rd, 2008 at 12:16 PM. |
|
#4
|
||||
|
||||
|
That is correct.
__________________
There is no spoon. |
|
#5
|
|||
|
|||
|
if that is correct, then what is wrong with this SQL code used in the PHP function mysql_query:
PHP Code:
the mysql_error returned by the false value of this query was PHP Code:
I changed the comma at the end but that wasn't it; there is something else. I get the same exact error after removing the errant comma at the end of teh string concatenation for the query parameter Last edited by WiscoLinks : January 6th, 2008 at 09:41 PM. Reason: troubleshooting update |
|
#6
|
||||
|
||||
|
Try adding single quote marks around the values:
PHP Code:
Or, with simplified syntax: PHP Code:
|
|
#7
|
|||
|
|||
|
tkark is my hero
the first solution worked, i needed those single quotes;
i kick myself Quote:
|
|
#8
|
||||
|
||||
|
echo is a wonderful thing - sometimes just echoing out the SQL command that is being sent to the DB can help you pin point what may be wrong with it. Especially for a Syntax error - least in my opinion.
__________________
life is a game.... Have fun ----------------------------- http://www.phpwomen.org strength in unity PHPCommunity IRC #phpc on freenode |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > SQL/PHP integration NOOB QUESTION |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|
|