# Create .sql file for php script

**URL:** <https://www.phphelp.com/t/create-sql-file-for-php-script/32891>\
**Category:** Beginners - Learning PHP\
**Created:** [December 5, 2020, 6:03am UTC](https://www.phphelp.com/t/create-sql-file-for-php-script/32891 "2020-12-05T06:03:44Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![SnoopDogg](https://www.phphelp.com/letter_avatar_proxy/v4/letter/s/e8c25b/32.png) [@SnoopDogg](https://www.phphelp.com/u/SnoopDogg)\
**Post date:** [December 5, 2020, 6:03am UTC](https://www.phphelp.com/t/create-sql-file-for-php-script/32891/1 "2020-12-05T06:03:44Z")

</div>

Ok this may sound stupid but i’m trying to fix this php script and there’s no .sql file for the database so i’m trying to look at the code to see if i can figure out what the table and everything are suppose to be… so the question is is there a better/easier way to do it or am i outta luck and gotta do it by hand?

Thanks Snoop

---

<div class="post-metadata">

**Author:** ![phdr](https://www.phphelp.com/letter_avatar_proxy/v4/letter/p/91b2a8/32.png) [@phdr](https://www.phphelp.com/u/phdr)\
**Post date:** [December 5, 2020, 6:12am UTC](https://www.phphelp.com/t/create-sql-file-for-php-script/32891/2 "2020-12-05T06:12:41Z")

</div>

You can produce a .sql file using a database management tool like phpmyadmin or you can do it using a low-level command line command.

---

<div class="post-metadata">

**Author:** ![SnoopDogg](https://www.phphelp.com/letter_avatar_proxy/v4/letter/s/e8c25b/32.png) [@SnoopDogg](https://www.phphelp.com/u/SnoopDogg)\
**Post date:** [December 5, 2020, 5:29pm UTC](https://www.phphelp.com/t/create-sql-file-for-php-script/32891/3 "2020-12-05T17:29:58Z")

</div>

Thanks phpdr i’ll check that out you probally saved me alot of headaches lol thought i was gonna have to do it all manually lol

Thanks Snoop

---

<div class="post-metadata">

**Author:** ![phdr](https://www.phphelp.com/letter_avatar_proxy/v4/letter/p/91b2a8/32.png) [@phdr](https://www.phphelp.com/u/phdr)\
**Post date:** [December 5, 2020, 6:20pm UTC](https://www.phphelp.com/t/create-sql-file-for-php-script/32891/4 "2020-12-05T18:20:21Z")

</div>

> [@SnoopDogg](#):
>
> fix this php script

My reply was based on the above and that your statement means you just need the .sql file for troubleshooting information. If your statement actually means that you don’t have a database at all, and you are not actually trying to fix a php script, but to recreate the database design, then yes, you will need to go through the script to find the table, column, and data types needed. That then begs the question of how you have a php script without the corresponding database.

---

<div class="post-metadata">

**Author:** ![whispers](https://www.phphelp.com/letter_avatar_proxy/v4/letter/w/858c86/32.png) [@whispers](https://www.phphelp.com/u/whispers)\
**Post date:** [December 6, 2020, 3:36pm UTC](https://www.phphelp.com/t/create-sql-file-for-php-script/32891/5 "2020-12-06T15:36:06Z")

</div>

I agree with phdr here as well…

If no database or myphpadmin or something to check out/view and export from…

This is going to be a painful task IMO…

and maybe not even possible? There could be many cols that are there/not used in the PHP script?

---

<div class="post-metadata">

**Author:** ![SnoopDogg](https://www.phphelp.com/letter_avatar_proxy/v4/letter/s/e8c25b/32.png) [@SnoopDogg](https://www.phphelp.com/u/SnoopDogg)\
**Post date:** [December 6, 2020, 5:44pm UTC](https://www.phphelp.com/t/create-sql-file-for-php-script/32891/6 "2020-12-06T17:44:50Z")

</div>

Thanks phpdr and whispers heres what happened i downloaded a script frome some site can’t remember where so i extracted it and there was no sql file with the script at all, I am trying to fix the script and yes i’m trying to recreate the db sql file… there was no db sql file and i went to the site in the readme but the site doesn’t exist no more i was gonna try to email the author i may still try to… but most of the times i try they never answer me…

I did fix a few things but here is the errors i’m still getting

**Notice** : Undefined variable: HTTP\_SERVER\_VARS in **C:\UwAmp\www\phpstatus\includes\Template.php** on line **16**

**Notice** : Undefined variable: HTTP\_SERVER\_VARS in **C:\UwAmp\www\phpstatus\includes\functions.php** on line **16**  
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘-\_groups’ at line 1

I can’t figure that error out i have checked all the files and found it in only acouple of files not sure what it’s suppose to be doing

Heres the php code giving me problems

if(preg\_match("/Template.php/i",$HTTP\_SERVER\_VARS[‘PHP\_SELF’])) {  
header(“Location: …/index.php”);  
exit();  
}

$HTTP\_SERVER\_VARS seems to be the problem

I can Post what i have for the sql so far if that will help lol

BTW the name of the script is PHPStatus Server Status

Thanks Snoop

---

<div class="post-metadata">

**Author:** ![whispers](https://www.phphelp.com/letter_avatar_proxy/v4/letter/w/858c86/32.png) [@whispers](https://www.phphelp.com/u/whispers)\
**Post date:** [December 6, 2020, 6:18pm UTC](https://www.phphelp.com/t/create-sql-file-for-php-script/32891/7 "2020-12-06T18:18:47Z")

</div>

HTTP\_SERVER\_VARS

is most likely the DB credentials needed to connect/access your database…

update:  
Seems like a VERY (very) old way of defining variables in PHP?

Perhaps just trying upgrading to use: **$\_SERVER** instead?

For example, if your code uses a line like this:

`parse_str($HTTP_SERVER_VARS["QUERY_STRING"]);`

It should be replaced with:

`parse_str($_SERVER["QUERY_STRING"]);`

---

<div class="post-metadata">

**Author:** ![SnoopDogg](https://www.phphelp.com/letter_avatar_proxy/v4/letter/s/e8c25b/32.png) [@SnoopDogg](https://www.phphelp.com/u/SnoopDogg)\
**Post date:** [December 6, 2020, 7:52pm UTC](https://www.phphelp.com/t/create-sql-file-for-php-script/32891/8 "2020-12-06T19:52:39Z")

</div>

Man your good it got rid of the 2 errors  
**Notice** : Undefined variable: HTTP\_SERVER\_VARS in **C:\UwAmp\www\phpstatus\includes\Template.php** on line **16**

**Notice** : Undefined variable: HTTP\_SERVER\_VARS in **C:\UwAmp\www\phpstatus\includes\functions.php** on line **16**

now all i’m getting is this error which i have no idea were it’s at

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘-\_groups’ at line 1

Trying to locate that one now

Thanks Snoop

---

<div class="post-metadata">

**Author:** ![whispers](https://www.phphelp.com/letter_avatar_proxy/v4/letter/w/858c86/32.png) [@whispers](https://www.phphelp.com/u/whispers)\
**Post date:** [December 6, 2020, 7:56pm UTC](https://www.phphelp.com/t/create-sql-file-for-php-script/32891/9 "2020-12-06T19:56:04Z")

</div>

FInd where the text: ‘-\_groups’ is located…

and post the full context of its usage.

Some code (somewhere) is attempting to make a SQL call of some sort…no?

---

<div class="post-metadata">

**Author:** ![SnoopDogg](https://www.phphelp.com/letter_avatar_proxy/v4/letter/s/e8c25b/32.png) [@SnoopDogg](https://www.phphelp.com/u/SnoopDogg)\
**Post date:** [December 6, 2020, 8:20pm UTC](https://www.phphelp.com/t/create-sql-file-for-php-script/32891/10 "2020-12-06T20:20:56Z")

</div>

Here is the one file in phpstatus\admin\add\_group.php

> **[phpStatus - Pastebin.com](https://pastebin.com/NEZxi4bb)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

the \_groups is on lines 36 & 58

1. $sql = "SELECT name FROM “.$prefix.”\_groups WHERE

2. name=’$HTTP\_POST\_VARS[name]’"; $result = $db-\>query($sql);

3. 
4. $num = $db-\>num($result);

5. $sql = “INSERT INTO “.$prefix.”\_groups (name, ports) VALUES (’$HTTP\_POST\_VARS[name]’, ‘$ports’)”;

6. $result = $db-\>query($sql);

Thanks Snoop

---

<div class="post-metadata">

**Author:** ![whispers](https://www.phphelp.com/letter_avatar_proxy/v4/letter/w/858c86/32.png) [@whispers](https://www.phphelp.com/u/whispers)\
**Post date:** [December 7, 2020, 1:56am UTC](https://www.phphelp.com/t/create-sql-file-for-php-script/32891/11 "2020-12-07T01:56:18Z")

</div>

Looks like:

\_groups

Is part of a TABLE name .

Also looks like you have some of the OLD Server vars in there as well…

not clear where $prefix is coming from…

This also doesnt look like PDO type of syntax… this is very old script apparently… I would update things to use PDO.

---

<div class="post-metadata">

**Author:** ![SnoopDogg](https://www.phphelp.com/letter_avatar_proxy/v4/letter/s/e8c25b/32.png) [@SnoopDogg](https://www.phphelp.com/u/SnoopDogg)\
**Post date:** [December 7, 2020, 6:39am UTC](https://www.phphelp.com/t/create-sql-file-for-php-script/32891/12 "2020-12-07T06:39:47Z")

</div>

thanks whispers yeah \_group is a db table i believe… the $prefix is the db prefix. yeah i thinks its an older script i’m going to try to do what you said and update it to use pdo… i’ll keep this post updated

thanks for all the help everyone 😄

Thanks Snoop

---

<div class="post-metadata">

**Author:** ![whispers](https://www.phphelp.com/letter_avatar_proxy/v4/letter/w/858c86/32.png) [@whispers](https://www.phphelp.com/u/whispers)\
**Post date:** [December 8, 2020, 12:35am UTC](https://www.phphelp.com/t/create-sql-file-for-php-script/32891/13 "2020-12-08T00:35:46Z")

</div>

Is your server still running PHP 5.x?

if so… perhaps try working out the variable issues… to ensure the scrip is working… then convert/update to use PDO for parameterized queries…etc

---

<div class="post-metadata">

**Author:** ![SnoopDogg](https://www.phphelp.com/letter_avatar_proxy/v4/letter/s/e8c25b/32.png) [@SnoopDogg](https://www.phphelp.com/u/SnoopDogg)\
**Post date:** [December 9, 2020, 2:03am UTC](https://www.phphelp.com/t/create-sql-file-for-php-script/32891/14 "2020-12-09T02:03:47Z")

</div>

well yeah if you mean php i’m running 5.6.40 right now… i’m having problems with the pdo stuff lol i found a pdo db script i believe its using pdo mysql but i’m trying to modify the pdo to match the original db script… change the function names ect…

heres the original db script

> **[original db script - Pastebin.com](https://pastebin.com/dF3My7eJ)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

heres the pdo db script

> **[pdo db script - Pastebin.com](https://pastebin.com/SV70zVyG)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

can u look at the pdo one and tell me if i can make that work for what i need to do?

Thanks Snoop

---

<div class="post-metadata">

**Author:** ![whispers](https://www.phphelp.com/letter_avatar_proxy/v4/letter/w/858c86/32.png) [@whispers](https://www.phphelp.com/u/whispers)\
**Post date:** [December 9, 2020, 4:36am UTC](https://www.phphelp.com/t/create-sql-file-for-php-script/32891/15 "2020-12-09T04:36:58Z")

</div>

Well that was kinda my point…

get the OLD version working… so you know all old/depreciated code is gone… and all variables are there/working…etc…

THEN updating to PDO would be a lot simpler… knowing any bugs/errors are from the migration to PDO… and not some older, underlying error from this old script.

This is some DB class?? Not a simple connection select/insert type of routine…

---

<div class="post-metadata">

**Author:** ![SnoopDogg](https://www.phphelp.com/letter_avatar_proxy/v4/letter/s/e8c25b/32.png) [@SnoopDogg](https://www.phphelp.com/u/SnoopDogg)\
**Post date:** [December 9, 2020, 3:26pm UTC](https://www.phphelp.com/t/create-sql-file-for-php-script/32891/16 "2020-12-09T15:26:19Z")

</div>

Yeah that’s what i’m doing i all most fixed all of them except one and i still can’t figure out were it is heres the error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘-\_groups’ at line 1

i searched all the files for \_groups in them and found 11 files with \_groups in them so i’m going through all of them again to try to find  
i’ll let ya know what i find…

Thanks Snoop

---

<div class="post-metadata">

**Author:** ![phdr](https://www.phphelp.com/letter_avatar_proxy/v4/letter/p/91b2a8/32.png) [@phdr](https://www.phphelp.com/u/phdr)\
**Post date:** [December 9, 2020, 3:53pm UTC](https://www.phphelp.com/t/create-sql-file-for-php-script/32891/17 "2020-12-09T15:53:01Z")

</div>

Based on the ‘near…’ text in the error message, $prefix contains just a - (dash) or ends in a -. This character is not permitted in a plain identifier. Since the posted line of code using $prefix doesn’t contain the identifier quote character ` (back-tick), the simplest fix would be to make sure that $prefix only contains ASCII: [0-9,a-z,A-Z$\_] (basic Latin letters, digits 0-9, dollar, underscore).

---

<div class="post-metadata">

**Author:** ![SnoopDogg](https://www.phphelp.com/letter_avatar_proxy/v4/letter/s/e8c25b/32.png) [@SnoopDogg](https://www.phphelp.com/u/SnoopDogg)\
**Post date:** [December 11, 2020, 3:52am UTC](https://www.phphelp.com/t/create-sql-file-for-php-script/32891/18 "2020-12-11T03:52:17Z")

</div>

Thanks so much for helping me i believe i got all the other errors fixed but all i’m getting now is this error…

Table ‘phpstatus.\_\_groups’ doesn’t exist

i wanted to ask do u think it’d be ok to totally remove the prefix stuff  
because that’s what’s causing the problems i think

Thanks Snoop

---

<div class="post-metadata">

**Author:** ![SnoopDogg](https://www.phphelp.com/letter_avatar_proxy/v4/letter/s/e8c25b/32.png) [@SnoopDogg](https://www.phphelp.com/u/SnoopDogg)\
**Post date:** [December 11, 2020, 4:41am UTC](https://www.phphelp.com/t/create-sql-file-for-php-script/32891/19 "2020-12-11T04:41:22Z")

</div>

Ok i got all the errors with the script now i’m getting this error

Table ‘phpstatus.\_\_groups’ doesn’t exist

here is what i have figured out on the sql file i tried to rebuild it from looking at the files in the script i may have missed some not sure…

> **[PhpStatus SQL File - Pastebin.com](https://pastebin.com/2vZdwQqG)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

i still think that prefox is messing it up some how so i may try to remove the proefix and see what i get…

Thanks Snoop

---

<div class="post-metadata">

**Author:** ![whispers](https://www.phphelp.com/letter_avatar_proxy/v4/letter/w/858c86/32.png) [@whispers](https://www.phphelp.com/u/whispers)\
**Post date:** [December 12, 2020, 6:27pm UTC](https://www.phphelp.com/t/create-sql-file-for-php-script/32891/20 "2020-12-12T18:27:35Z")

</div>

does that table exist? with the period? same name matches table in your current DB?

[Next page](https://www.phphelp.com/t/create-sql-file-for-php-script/32891.md?page=2)
