Jump to content

Code Error || PHP / Mysql Update DB tables


bnovak

Recommended Posts

Hello!

 

Looking for a little more help on this one.

 

Trying to do this (profile and state_licenses are db tables within the same db)

 

mysql_query("UPDATE profile SET statecount='(LENGTH(stateLicenses) - LENGTH(REPLACE(stateLicenses, '|', ''))+1)' WHERE statecount='empty' ");

 

mysql_query("update profile SET statecount='empty' WHERE statecount='0'");

 

and keep getting a generic PHP Code error. (I've kept the connection details out for obvious reasons  ;D )

 

I got no red bangs when writing this in ZendStudio but there's probably something really simple in the syntax that I'm goofing up. I've read through a bunch of different tutorials but it's always about adding a specific entry to a table rather than an expression.

 

both mysql operations work fine in phpmyadmin without the php call. I had a similar issue to this before and someone was able to find it really quick (and of course, now I can't find that post!)

 

Any help?

Link to comment
https://forums.phpfreaks.com/topic/202782-code-error-php-mysql-update-db-tables/
Share on other sites

What's the PHP error you're getting? :3

 

Would love to tell ya, but it's a generic.

 

There were errors in your event: PHP CODE

 

con = mysql_connect("localhost","xxxx","xxxx");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

mysql_select_db("xxxx", $con);

 

mysql_query("UPDATE profile SET statecount='(LENGTH(stateLicenses) - LENGTH(REPLACE(stateLicenses, '|', ''))+1)' WHERE statecount='emtpy' ");

 

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.