yana Posted August 2, 2006 Share Posted August 2, 2006 I am trying to create a database and table in MySQL using PHP and I get the following error when I run the script (not sure what's wrong with line 2):[tt]Fatal error: Call to undefined function: mysql_connect() in /home/yana/html/online_survey/test.php on line 2[/tt]Here is my code:[code]<?php$con = mysql_connect("devdbyana","","");if (!$con) { die('Could not connect: ' . mysql_error()); }// Create database $sql = "CREATE DATABASE online_survey";if (mysql_query($sql,$con)) { echo "Database online_survey created"; }else { echo "Error creating database: " . mysql_error(); }// Create table in the online_survey database mysql_select_db("online_survey", $con);$sql = "CREATE TABLE Survey (CourseName varchar(15),Trainer varchar(15),QuestionOne varchar(2),QuestionTwo varchar(2),QuestionTwoComments varchar(15),QuestionThree varchar(2),QuestionFour varchar(2),QuestionFive varchar(2),QuestionSix varchar(2),QuestionSeven varchar(2),QuestionEight varchar(2),QuestionNine varchar(2),QuestionNineComments varchar(15),QuestionTen varchar(2),QuestionEleven varchar(2),QuestionTwelve varchar(15),QuestionThirteen varchar(15),QuestionFourteen varchar(15),QuestionFifteen varchar(15),QuestionSixteen varchar(15),Comments varchar(15))";mysql_query($sql,$con);mysql_close($con);?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16322-mysql-and-php/ Share on other sites More sharing options...
kenrbnsn Posted August 2, 2006 Share Posted August 2, 2006 What version of PHP?Ken Quote Link to comment https://forums.phpfreaks.com/topic/16322-mysql-and-php/#findComment-67778 Share on other sites More sharing options...
yana Posted August 2, 2006 Author Share Posted August 2, 2006 PHP Version 4.3.4 Quote Link to comment https://forums.phpfreaks.com/topic/16322-mysql-and-php/#findComment-67783 Share on other sites More sharing options...
wildteen88 Posted August 2, 2006 Share Posted August 2, 2006 When you complided PHP did you put [i]--without-mysql[/i] command? This the only reason I can think of why its not working with PHP4. As by defualt PHP4 is comipled with the --with-mysql command. Quote Link to comment https://forums.phpfreaks.com/topic/16322-mysql-and-php/#findComment-67798 Share on other sites More sharing options...
yana Posted August 2, 2006 Author Share Posted August 2, 2006 Not sure what you mean or where I would put that line of code in my case. This is a web-based system I am building...so I am running the page online in Internet Explorer. Quote Link to comment https://forums.phpfreaks.com/topic/16322-mysql-and-php/#findComment-67800 Share on other sites More sharing options...
wildteen88 Posted August 2, 2006 Share Posted August 2, 2006 Did you compile (install) PHP? Its not to do with your PHP code at all, but how PHP was installed. Or are you hosted by some webhost? If you didnt install PHP and are renting webspace I would contact your host and ask why you cannot use the mysql functions. Quote Link to comment https://forums.phpfreaks.com/topic/16322-mysql-and-php/#findComment-67801 Share on other sites More sharing options...
yana Posted August 2, 2006 Author Share Posted August 2, 2006 I didn't install PHP myself. I am working in IT department...I just wanted to figure out whether or not something is wrong with my code before asking the manager and looking dumb! ::)Could a reason for my error be that MySQL is not installed on the server? Quote Link to comment https://forums.phpfreaks.com/topic/16322-mysql-and-php/#findComment-67811 Share on other sites More sharing options...
wildteen88 Posted August 2, 2006 Share Posted August 2, 2006 No not really, however if you want to connect to a MySQL database you obviously want it installed but tihs wont affect PHP. You'll probably want ask the IT manager to see whats up. For now run this:[code]<?phpphpinfo();?>[/code]Look for anythink to do with mysql, about two thirds the way down the page there should be a mysql section. Also scroll to the top of the page and paste whats to the right of the Configure Command box here.Also make sure you're supposed to used mssql/msql database rather tha mysql. Quote Link to comment https://forums.phpfreaks.com/topic/16322-mysql-and-php/#findComment-67816 Share on other sites More sharing options...
yana Posted August 2, 2006 Author Share Posted August 2, 2006 The only thing I found that had to do with MySQL is at the top of the page in the CONFIGURE COMMAND section:[code]with-mysql=shared,/usr' '--[/code]Nothing else...though there is a whole section on [b]pgsql[/b] - PostgreSQL Support.Could this mean that PostreSQL is installed and MySQL isn't???? ??? Quote Link to comment https://forums.phpfreaks.com/topic/16322-mysql-and-php/#findComment-67823 Share on other sites More sharing options...
wildteen88 Posted August 2, 2006 Share Posted August 2, 2006 Prehaps you'll have to use pgSQL. But still ask your IT manager whether its possible to use mysql. Quote Link to comment https://forums.phpfreaks.com/topic/16322-mysql-and-php/#findComment-67832 Share on other sites More sharing options...
yana Posted August 2, 2006 Author Share Posted August 2, 2006 Alright! Thanks! I've asked and now waiting for response! Quote Link to comment https://forums.phpfreaks.com/topic/16322-mysql-and-php/#findComment-67834 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.