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);

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.....

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.