Jump to content

mysql_query thinks string is a rescource


need

Recommended Posts

I have Mysql 5.1.54, and whenever i execute the following it says that mysql_query expected a string but received a rescource. I've been looking around and can't find a way to fix this.

 

$query="CREATE TABLE POSTS(num_rows int NOT NULL AUTO_INCREMENT, PRIMARY KEY(num_rows),Name varchar(30),Text varchar(200))";

$result=mysql_query($query);

 

okay, i checked the line number and that is the spot where the error is, but here is the full thing

<?php

//have it check if database already exists b4 creating it.
$data=mysql_connect("localhost","root","");
if (!$data)
{
	die('Could not connect: ' . mysql_error());
}

if (mysql_query("CREATE DATABASE site_data",$data))
{
	echo "Database created";
}
	else
{
	echo "Error creating database: " . mysql_error();
}

//mysql_query($data);

mysql_select_db("site_data", $data);

$query="CREATE TABLE POSTS(num_rows int NOT NULL AUTO_INCREMENT, PRIMARY KEY(num_rows),Name varchar(30),Text varchar(200))";

$result=mysql_query("CREATE TABLE POSTS(num_rows int NOT NULL AUTO_INCREMENT, PRIMARY KEY(num_rows),Name varchar(30),Text varchar(200))");

if($result){
echo "Table Created";
}else{
echo "Error Making table";
}

mysql_query($data);

mysql_close($data);
?>

 

here is the error message:

Warning: mysql_query() expects parameter 1 to be string, resource given in C:\Program Files (x86)\EasyPHP-5.3.5.0\www\test site\create database.php on line 40

 

Thanks pikachu! that cleared it up, and i do have a program that allows line number counting, the error was telling me that it was at the first usage of mysql_query

 

Sorry if this was a retarded problem, the tutorials i have found have been... lacking.....

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.